message box about succesful removal
This commit is contained in:
parent
81a2f8535a
commit
5a26be1150
3 changed files with 47 additions and 4 deletions
|
@ -3583,8 +3583,7 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
//added to show disconnect_button after writing
|
|
||||||
show_action_buttons(false);
|
|
||||||
|
|
||||||
if (canceled) {
|
if (canceled) {
|
||||||
if (wxGetApp().get_mode() == comSimple)
|
if (wxGetApp().get_mode() == comSimple)
|
||||||
|
@ -3593,6 +3592,11 @@ 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);
|
||||||
|
else if(RemovableDriveManager::get_instance().get_is_writing())
|
||||||
|
{
|
||||||
|
RemovableDriveManager::get_instance().set_is_writing(false);
|
||||||
|
show_action_buttons(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::priv::on_layer_editing_toggled(bool enable)
|
void Plater::priv::on_layer_editing_toggled(bool enable)
|
||||||
|
@ -4722,6 +4726,7 @@ 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);
|
||||||
p->export_gcode(std::move(output_path), PrintHostJob());
|
p->export_gcode(std::move(output_path), PrintHostJob());
|
||||||
RemovableDriveManager::get_instance().update(0, true);
|
RemovableDriveManager::get_instance().update(0, true);
|
||||||
RemovableDriveManager::get_instance().set_last_save_path(path);
|
RemovableDriveManager::get_instance().set_last_save_path(path);
|
||||||
|
@ -5016,6 +5021,8 @@ void Plater::eject_drive()
|
||||||
}
|
}
|
||||||
void Plater::drive_ejected_callback()
|
void Plater::drive_ejected_callback()
|
||||||
{
|
{
|
||||||
|
wxString message = "Unmounting succesesful. The device " + RemovableDriveManager::get_instance().get_last_save_name() + "(" + RemovableDriveManager::get_instance().get_last_save_path() + ")" + " can now be safely removed from the computer.";
|
||||||
|
wxMessageBox(message);
|
||||||
p->show_action_buttons(false);
|
p->show_action_buttons(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ void RemovableDriveManager::search_for_drives()
|
||||||
if (drive_type == DRIVE_REMOVABLE)
|
if (drive_type == DRIVE_REMOVABLE)
|
||||||
{
|
{
|
||||||
// get name of drive
|
// get name of drive
|
||||||
std::wstring wpath = std::wstring(path.begin(), path.end());
|
std::wstring wpath = boost::nowide::widen(path);//std::wstring(path.begin(), path.end());
|
||||||
std::wstring volume_name;
|
std::wstring volume_name;
|
||||||
volume_name.resize(1024);
|
volume_name.resize(1024);
|
||||||
std::wstring file_system_name;
|
std::wstring file_system_name;
|
||||||
|
@ -52,6 +52,7 @@ void RemovableDriveManager::search_for_drives()
|
||||||
BOOL error = GetVolumeInformationW(wpath.c_str(), &volume_name[0], sizeof(volume_name), NULL, NULL, NULL, &file_system_name[0], sizeof(file_system_name));
|
BOOL error = GetVolumeInformationW(wpath.c_str(), &volume_name[0], sizeof(volume_name), NULL, NULL, NULL, &file_system_name[0], sizeof(file_system_name));
|
||||||
if(error != 0)
|
if(error != 0)
|
||||||
{
|
{
|
||||||
|
volume_name.erase(std::find(volume_name.begin(), volume_name.end(), '\0'), volume_name.end());
|
||||||
/*
|
/*
|
||||||
if (volume_name == L"")
|
if (volume_name == L"")
|
||||||
{
|
{
|
||||||
|
@ -398,7 +399,9 @@ std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
||||||
RemovableDriveManager::RemovableDriveManager():
|
RemovableDriveManager::RemovableDriveManager():
|
||||||
m_drives_count(0),
|
m_drives_count(0),
|
||||||
m_last_update(0),
|
m_last_update(0),
|
||||||
m_last_save_path("")
|
m_last_save_path(""),
|
||||||
|
m_last_save_name(""),
|
||||||
|
m_is_writing(false)
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
, m_rdmmm(new RDMMMWrapper())
|
, m_rdmmm(new RDMMMWrapper())
|
||||||
#endif
|
#endif
|
||||||
|
@ -459,6 +462,10 @@ std::string RemovableDriveManager::get_last_save_path()
|
||||||
{
|
{
|
||||||
return m_last_save_path;
|
return m_last_save_path;
|
||||||
}
|
}
|
||||||
|
std::string RemovableDriveManager::get_last_save_name()
|
||||||
|
{
|
||||||
|
return m_last_save_name;
|
||||||
|
}
|
||||||
std::vector<DriveData> RemovableDriveManager::get_all_drives()
|
std::vector<DriveData> RemovableDriveManager::get_all_drives()
|
||||||
{
|
{
|
||||||
return m_current_drives;
|
return m_current_drives;
|
||||||
|
@ -491,8 +498,22 @@ void RemovableDriveManager::set_last_save_path(const std::string& path)
|
||||||
if(last_drive != "")
|
if(last_drive != "")
|
||||||
{
|
{
|
||||||
m_last_save_path = last_drive;
|
m_last_save_path = last_drive;
|
||||||
|
m_last_save_name = get_drive_name(last_drive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::string RemovableDriveManager::get_drive_name(const std::string& path)
|
||||||
|
{
|
||||||
|
if (m_current_drives.size() == 0)
|
||||||
|
return "";
|
||||||
|
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||||
|
{
|
||||||
|
if ((*it).path == path)
|
||||||
|
{
|
||||||
|
return (*it).name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
bool RemovableDriveManager::is_last_drive_removed()
|
bool RemovableDriveManager::is_last_drive_removed()
|
||||||
{
|
{
|
||||||
//std::cout<<"is last: "<<m_last_save_path;
|
//std::cout<<"is last: "<<m_last_save_path;
|
||||||
|
@ -515,5 +536,14 @@ bool RemovableDriveManager::is_last_drive_removed_with_update(const long time)
|
||||||
void RemovableDriveManager::reset_last_save_path()
|
void RemovableDriveManager::reset_last_save_path()
|
||||||
{
|
{
|
||||||
m_last_save_path = "";
|
m_last_save_path = "";
|
||||||
|
m_last_save_name = "";
|
||||||
|
}
|
||||||
|
void RemovableDriveManager::set_is_writing(const bool b)
|
||||||
|
{
|
||||||
|
m_is_writing = b;
|
||||||
|
}
|
||||||
|
bool RemovableDriveManager::get_is_writing()
|
||||||
|
{
|
||||||
|
return m_is_writing;
|
||||||
}
|
}
|
||||||
}}//namespace Slicer::Gui
|
}}//namespace Slicer::Gui
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
void eject_drive(const std::string &path);
|
void eject_drive(const std::string &path);
|
||||||
//returns path to last drive which was used, if none was used, returns device that was enumerated last
|
//returns path to last drive which was used, if none was used, returns device that was enumerated last
|
||||||
std::string get_last_save_path();
|
std::string get_last_save_path();
|
||||||
|
std::string get_last_save_name();
|
||||||
//returns path to last drive which was used, if none was used, returns empty string
|
//returns path to last drive which was used, if none was used, returns empty string
|
||||||
std::string get_drive_path();
|
std::string get_drive_path();
|
||||||
std::vector<DriveData> get_all_drives();
|
std::vector<DriveData> get_all_drives();
|
||||||
|
@ -50,6 +51,9 @@ public:
|
||||||
bool is_last_drive_removed();
|
bool is_last_drive_removed();
|
||||||
// param as update()
|
// param as update()
|
||||||
bool is_last_drive_removed_with_update(const long time = 0);
|
bool is_last_drive_removed_with_update(const long time = 0);
|
||||||
|
void set_is_writing(const bool b);
|
||||||
|
bool get_is_writing();
|
||||||
|
std::string get_drive_name(const std::string& path);
|
||||||
private:
|
private:
|
||||||
RemovableDriveManager();
|
RemovableDriveManager();
|
||||||
void search_for_drives();
|
void search_for_drives();
|
||||||
|
@ -64,6 +68,8 @@ private:
|
||||||
size_t m_drives_count;
|
size_t m_drives_count;
|
||||||
long m_last_update;
|
long m_last_update;
|
||||||
std::string m_last_save_path;
|
std::string m_last_save_path;
|
||||||
|
std::string m_last_save_name;
|
||||||
|
bool m_is_writing;//on device
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
//registers for notifications by creating invisible window
|
//registers for notifications by creating invisible window
|
||||||
|
|
Loading…
Reference in a new issue