diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index c7f374085..d54083e36 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2199,6 +2199,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) // Initialize the Undo / Redo stack with a first snapshot. this->take_snapshot(_(L("New Project"))); + + //void Plater::priv::show_action_buttons(const bool is_ready_to_slice) const + RemovableDriveManager::get_instance().set_drive_count_changed_callback(std::bind(&Plater::priv::show_action_buttons, this, std::placeholders::_1)); } Plater::priv::~priv() @@ -4159,6 +4162,7 @@ void Plater::priv::update_object_menu() void Plater::priv::show_action_buttons(const bool is_ready_to_slice) const { + RemovableDriveManager::get_instance().set_plater_ready_to_slice(is_ready_to_slice); wxWindowUpdateLocker noUpdater(sidebar); const auto prin_host_opt = config->option("print_host"); const bool send_gcode_shown = prin_host_opt != nullptr && !prin_host_opt->value.empty(); diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index 99da30ed8..74197d677 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -414,7 +414,8 @@ RemovableDriveManager::RemovableDriveManager(): m_last_save_name(""), m_last_save_path_verified(false), m_is_writing(false), - m_did_eject(false) + m_did_eject(false), + m_plater_ready_to_slice(true) #if __APPLE__ , m_rdmmm(new RDMMMWrapper()) #endif @@ -495,6 +496,10 @@ std::vector RemovableDriveManager::get_all_drives() } void RemovableDriveManager::check_and_notify() { + if(m_drive_count_changed_callback) + { + m_drive_count_changed_callback(m_plater_ready_to_slice); + } 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) @@ -507,10 +512,18 @@ void RemovableDriveManager::add_remove_callback(std::function callback) { m_callbacks.push_back(callback); } -void RemovableDriveManager::erase_callbacks() +void RemovableDriveManager::erase_callbacks() { m_callbacks.clear(); } +void RemovableDriveManager::set_drive_count_changed_callback(std::function callback) +{ + m_drive_count_changed_callback = callback; +} +void RemovableDriveManager::set_plater_ready_to_slice(bool b) +{ + m_plater_ready_to_slice = b; +} void RemovableDriveManager::set_last_save_path(const std::string& path) { m_last_save_path_verified = false; diff --git a/src/slic3r/GUI/RemovableDriveManager.hpp b/src/slic3r/GUI/RemovableDriveManager.hpp index b5b5c0952..8ba2bc64d 100644 --- a/src/slic3r/GUI/RemovableDriveManager.hpp +++ b/src/slic3r/GUI/RemovableDriveManager.hpp @@ -46,8 +46,12 @@ public: bool is_path_on_removable_drive(const std::string &path); // callback will notify only if device with last save path was removed void add_remove_callback(std::function callback); - // erases all callbacks added by add_callback() + // erases all remove callbacks added by add_remove_callback() void erase_callbacks(); + //drive_count_changed callback is called on every added or removed device + void set_drive_count_changed_callback(std::function callback); + //thi serves to set correct value for drive_count_changed callback + void set_plater_ready_to_slice(bool b); // marks one of the eveices in vector as last used void set_last_save_path(const std::string &path); void verify_last_save_path(); @@ -71,6 +75,7 @@ private: std::vector m_current_drives; std::vector> m_callbacks; + std::function m_drive_count_changed_callback; size_t m_drives_count; long m_last_update; std::string m_last_save_path; @@ -78,6 +83,7 @@ private: std::string m_last_save_name; bool m_is_writing;//on device bool m_did_eject; + bool m_plater_ready_to_slice; #if _WIN32 //registers for notifications by creating invisible window void register_window();