Merge branch 'dk_remote_devices' into dk_copy_file
This commit is contained in:
commit
dafd768b34
2 changed files with 32 additions and 25 deletions
|
@ -3611,17 +3611,14 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
|
||||||
}
|
}
|
||||||
else if (wxGetApp().get_mode() == comSimple)
|
else if (wxGetApp().get_mode() == comSimple)
|
||||||
show_action_buttons(false);
|
show_action_buttons(false);
|
||||||
if(RemovableDriveManager::get_instance().get_is_writing())
|
|
||||||
{
|
|
||||||
RemovableDriveManager::get_instance().set_is_writing(false);
|
|
||||||
RemovableDriveManager::get_instance().verify_last_save_path();
|
|
||||||
if (!RemovableDriveManager::get_instance().is_last_drive_removed())
|
|
||||||
{
|
|
||||||
|
|
||||||
RemovableDriveManager::get_instance().erase_callbacks();
|
if(!canceled && RemovableDriveManager::get_instance().get_is_writing())
|
||||||
RemovableDriveManager::get_instance().add_callback(std::bind(&Plater::drive_ejected_callback, q));
|
{
|
||||||
|
//if (!RemovableDriveManager::get_instance().is_last_drive_removed())
|
||||||
|
//{
|
||||||
|
RemovableDriveManager::get_instance().set_is_writing(false);
|
||||||
show_action_buttons(false);
|
show_action_buttons(false);
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4755,19 +4752,20 @@ void Plater::export_gcode()
|
||||||
if (! output_path.empty())
|
if (! output_path.empty())
|
||||||
{
|
{
|
||||||
std::string path = output_path.string();
|
std::string path = output_path.string();
|
||||||
RemovableDriveManager::get_instance().set_is_writing(true);
|
|
||||||
RemovableDriveManager::get_instance().update(0, true);
|
|
||||||
p->export_gcode(std::move(output_path), PrintHostJob());
|
p->export_gcode(std::move(output_path), PrintHostJob());
|
||||||
|
|
||||||
|
RemovableDriveManager::get_instance().update(0, false);
|
||||||
RemovableDriveManager::get_instance().set_last_save_path(path);
|
RemovableDriveManager::get_instance().set_last_save_path(path);
|
||||||
/*
|
RemovableDriveManager::get_instance().verify_last_save_path();
|
||||||
|
|
||||||
if(!RemovableDriveManager::get_instance().is_last_drive_removed())
|
if(!RemovableDriveManager::get_instance().is_last_drive_removed())
|
||||||
{
|
{
|
||||||
|
RemovableDriveManager::get_instance().set_is_writing(true);
|
||||||
RemovableDriveManager::get_instance().erase_callbacks();
|
RemovableDriveManager::get_instance().erase_callbacks();
|
||||||
RemovableDriveManager::get_instance().add_callback(std::bind(&Plater::drive_ejected_callback, this));
|
RemovableDriveManager::get_instance().add_callback(std::bind(&Plater::drive_ejected_callback, this));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::export_stl(bool extended, bool selection_only)
|
void Plater::export_stl(bool extended, bool selection_only)
|
||||||
|
|
|
@ -116,7 +116,9 @@ bool RemovableDriveManager::is_path_on_removable_drive(const std::string &path)
|
||||||
{
|
{
|
||||||
if (m_current_drives.empty())
|
if (m_current_drives.empty())
|
||||||
return false;
|
return false;
|
||||||
int letter = PathGetDriveNumberA(path.c_str());
|
std::size_t found = path.find_last_of("\\");
|
||||||
|
std::string new_path = path.substr(0, found);
|
||||||
|
int letter = PathGetDriveNumberA(new_path.c_str());
|
||||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||||
{
|
{
|
||||||
char drive = (*it).path[0];
|
char drive = (*it).path[0];
|
||||||
|
@ -127,7 +129,9 @@ bool RemovableDriveManager::is_path_on_removable_drive(const std::string &path)
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
||||||
{
|
{
|
||||||
int letter = PathGetDriveNumberA(path.c_str());
|
std::size_t found = path.find_last_of("\\");
|
||||||
|
std::string new_path = path.substr(0, found);
|
||||||
|
int letter = PathGetDriveNumberA(new_path.c_str());
|
||||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||||
{
|
{
|
||||||
char drive = (*it).path[0];
|
char drive = (*it).path[0];
|
||||||
|
@ -391,10 +395,12 @@ bool RemovableDriveManager::is_path_on_removable_drive(const std::string &path)
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
||||||
{
|
{
|
||||||
|
std::size_t found = path.find_last_of("/");
|
||||||
|
std::string new_path = path.substr(0, found);
|
||||||
//check if same filesystem
|
//check if same filesystem
|
||||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||||
{
|
{
|
||||||
if (compare_filesystem_id(path, (*it).path))
|
if (compare_filesystem_id(new_path, (*it).path))
|
||||||
return (*it).path;
|
return (*it).path;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -443,7 +449,11 @@ bool RemovableDriveManager::update(const long time,const bool check)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
search_for_drives();
|
search_for_drives();
|
||||||
if(check)check_and_notify();
|
if (m_drives_count != m_current_drives.size())
|
||||||
|
{
|
||||||
|
if (check)check_and_notify();
|
||||||
|
m_drives_count = m_current_drives.size();
|
||||||
|
}
|
||||||
return !m_current_drives.empty();
|
return !m_current_drives.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,16 +495,12 @@ std::vector<DriveData> RemovableDriveManager::get_all_drives()
|
||||||
}
|
}
|
||||||
void RemovableDriveManager::check_and_notify()
|
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_verified && !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)
|
||||||
{
|
{
|
||||||
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
|
(*it)();
|
||||||
{
|
|
||||||
(*it)();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
m_drives_count = m_current_drives.size();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RemovableDriveManager::add_callback(std::function<void()> callback)
|
void RemovableDriveManager::add_callback(std::function<void()> callback)
|
||||||
|
@ -518,6 +524,9 @@ void RemovableDriveManager::verify_last_save_path()
|
||||||
m_last_save_path_verified = true;
|
m_last_save_path_verified = true;
|
||||||
m_last_save_path = last_drive;
|
m_last_save_path = last_drive;
|
||||||
m_last_save_name = get_drive_name(last_drive);
|
m_last_save_name = get_drive_name(last_drive);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
reset_last_save_path();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_drive_name(const std::string& path)
|
std::string RemovableDriveManager::get_drive_name(const std::string& path)
|
||||||
|
|
Loading…
Reference in a new issue