Merge branch 'dk_remote_devices' of https://github.com/prusa3d/slic3r into dk_remote_devices
This commit is contained in:
commit
fad035137f
@ -3597,12 +3597,18 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
|
||||
}
|
||||
else if (wxGetApp().get_mode() == comSimple)
|
||||
show_action_buttons(false);
|
||||
else if(RemovableDriveManager::get_instance().get_is_writing())
|
||||
if(RemovableDriveManager::get_instance().get_is_writing())
|
||||
{
|
||||
RemovableDriveManager::get_instance().set_is_writing(false);
|
||||
//RemovableDriveManager::get_instance().erase_callbacks();
|
||||
//RemovableDriveManager::get_instance().add_callback(std::bind(&Plater::drive_ejected_callback, q));
|
||||
show_action_buttons(false);
|
||||
RemovableDriveManager::get_instance().verify_last_save_path();
|
||||
if (!RemovableDriveManager::get_instance().is_last_drive_removed())
|
||||
{
|
||||
|
||||
RemovableDriveManager::get_instance().erase_callbacks();
|
||||
RemovableDriveManager::get_instance().add_callback(std::bind(&Plater::drive_ejected_callback, q));
|
||||
show_action_buttons(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -4734,13 +4740,15 @@ void Plater::export_gcode()
|
||||
std::string path = output_path.string();
|
||||
RemovableDriveManager::get_instance().set_is_writing(true);
|
||||
RemovableDriveManager::get_instance().update(0, true);
|
||||
RemovableDriveManager::get_instance().set_last_save_path(path);
|
||||
p->export_gcode(std::move(output_path), PrintHostJob());
|
||||
RemovableDriveManager::get_instance().set_last_save_path(path);
|
||||
/*
|
||||
if(!RemovableDriveManager::get_instance().is_last_drive_removed())
|
||||
{
|
||||
RemovableDriveManager::get_instance().erase_callbacks();
|
||||
RemovableDriveManager::get_instance().add_callback(std::bind(&Plater::drive_ejected_callback, this));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -402,6 +402,7 @@ RemovableDriveManager::RemovableDriveManager():
|
||||
m_last_update(0),
|
||||
m_last_save_path(""),
|
||||
m_last_save_name(""),
|
||||
m_last_save_path_verified(false),
|
||||
m_is_writing(false),
|
||||
m_did_eject(false)
|
||||
#if __APPLE__
|
||||
@ -442,7 +443,6 @@ bool RemovableDriveManager::update(const long time,const bool check)
|
||||
return !m_current_drives.empty();
|
||||
}
|
||||
|
||||
|
||||
bool RemovableDriveManager::is_drive_mounted(const std::string &path)
|
||||
{
|
||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||
@ -461,12 +461,14 @@ std::string RemovableDriveManager::get_drive_path()
|
||||
reset_last_save_path();
|
||||
return "";
|
||||
}
|
||||
if (m_last_save_path != "")
|
||||
if (m_last_save_path_verified)
|
||||
return m_last_save_path;
|
||||
return m_current_drives.back().path;
|
||||
}
|
||||
std::string RemovableDriveManager::get_last_save_path()
|
||||
{
|
||||
if (!m_last_save_path_verified)
|
||||
return "";
|
||||
return m_last_save_path;
|
||||
}
|
||||
std::string RemovableDriveManager::get_last_save_name()
|
||||
@ -481,7 +483,7 @@ void RemovableDriveManager::check_and_notify()
|
||||
{
|
||||
if(m_drives_count != m_current_drives.size())
|
||||
{
|
||||
if(m_callbacks.size() != 0 && m_drives_count > m_current_drives.size() && m_last_save_path != "" && !is_drive_mounted(m_last_save_path))
|
||||
if(m_callbacks.size() != 0 && m_drives_count > m_current_drives.size() && m_last_save_path_verified && !is_drive_mounted(m_last_save_path))
|
||||
{
|
||||
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
|
||||
{
|
||||
@ -501,9 +503,14 @@ void RemovableDriveManager::erase_callbacks()
|
||||
}
|
||||
void RemovableDriveManager::set_last_save_path(const std::string& path)
|
||||
{
|
||||
std::string last_drive = get_drive_from_path(path);
|
||||
if(last_drive != "")
|
||||
m_last_save_path = path;
|
||||
}
|
||||
void RemovableDriveManager::verify_last_save_path()
|
||||
{
|
||||
std::string last_drive = get_drive_from_path(m_last_save_path);
|
||||
if (last_drive != "")
|
||||
{
|
||||
m_last_save_path_verified = true;
|
||||
m_last_save_path = last_drive;
|
||||
m_last_save_name = get_drive_name(last_drive);
|
||||
}
|
||||
@ -525,7 +532,7 @@ bool RemovableDriveManager::is_last_drive_removed()
|
||||
{
|
||||
//std::cout<<"is last: "<<m_last_save_path;
|
||||
//m_drives_count = m_current_drives.size();
|
||||
if(m_last_save_path == "")
|
||||
if(!m_last_save_path_verified)
|
||||
{
|
||||
//std::cout<<"\n";
|
||||
return true;
|
||||
@ -542,6 +549,7 @@ bool RemovableDriveManager::is_last_drive_removed_with_update(const long time)
|
||||
}
|
||||
void RemovableDriveManager::reset_last_save_path()
|
||||
{
|
||||
m_last_save_path_verified = false;
|
||||
m_last_save_path = "";
|
||||
m_last_save_name = "";
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
void erase_callbacks();
|
||||
// marks one of the eveices in vector as last used
|
||||
void set_last_save_path(const std::string &path);
|
||||
void verify_last_save_path();
|
||||
bool is_last_drive_removed();
|
||||
// param as update()
|
||||
bool is_last_drive_removed_with_update(const long time = 0);
|
||||
@ -70,10 +71,10 @@ private:
|
||||
size_t m_drives_count;
|
||||
long m_last_update;
|
||||
std::string m_last_save_path;
|
||||
bool m_last_save_path_verified;
|
||||
std::string m_last_save_name;
|
||||
bool m_is_writing;//on device
|
||||
bool m_did_eject;
|
||||
|
||||
#if _WIN32
|
||||
//registers for notifications by creating invisible window
|
||||
void register_window();
|
||||
|
Loading…
Reference in New Issue
Block a user