eject button functionality

This commit is contained in:
David Kocik 2019-12-11 12:28:51 +01:00
parent 01f1bed060
commit f5e3750d23
4 changed files with 34 additions and 17 deletions

View file

@ -902,6 +902,7 @@ Sidebar::Sidebar(Plater *parent)
p->btn_send_gcode->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { p->plater->send_gcode(); });
p->btn_disconnect->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
// #dk_FIXME
p->plater->eject_drive();
});
}
@ -4149,7 +4150,7 @@ void Plater::priv::show_action_buttons(const bool is_ready_to_slice) const
const auto prin_host_opt = config->option<ConfigOptionString>("print_host");
const bool send_gcode_shown = prin_host_opt != nullptr && !prin_host_opt->value.empty();
const bool disconnect_shown = true; // #dk_FIXME
const bool disconnect_shown = !(RemovableDriveManager::get_instance().is_last_drive_removed()); // #dk_FIXME
// when a background processing is ON, export_btn and/or send_btn are showing
if (wxGetApp().app_config->get("background_processing") == "1")
@ -4992,6 +4993,22 @@ void Plater::send_gcode()
}
}
void Plater::eject_drive()
{
if (GUI::RemovableDriveManager::get_instance().update())
{
RemovableDriveManager::get_instance().erase_callbacks();
RemovableDriveManager::get_instance().add_callback(std::bind(&Plater::drive_ejected_callback, this));
RemovableDriveManager::get_instance().eject_drive(RemovableDriveManager::get_instance().get_last_drive_path());
}
}
void Plater::drive_ejected_callback()
{
p->show_action_buttons(false);
}
void Plater::take_snapshot(const std::string &snapshot_name) { p->take_snapshot(snapshot_name); }
void Plater::take_snapshot(const wxString &snapshot_name) { p->take_snapshot(snapshot_name); }
void Plater::suppress_snapshots() { p->suppress_snapshots(); }