keyboard and file menu shortcuts for save to sd card and eject

This commit is contained in:
David Kocik 2020-03-06 15:33:30 +01:00
parent 779f0cd915
commit e39e9b05ae
4 changed files with 34 additions and 2 deletions

View file

@ -122,6 +122,8 @@ void KBShortcutsDialog::fill_shortcuts()
{ ctrl + "G", L("Export G-code") }, { ctrl + "G", L("Export G-code") },
{ ctrl + "Shift+" + "G", L("Send G-code") }, { ctrl + "Shift+" + "G", L("Send G-code") },
{ ctrl + "E", L("Export config") }, { ctrl + "E", L("Export config") },
{ ctrl + "U", L("Export to SD card / Flash drive") },
{ ctrl + "T", L("Eject SD card / Flash drive") },
// Edit // Edit
{ ctrl + "A", L("Select all objects") }, { ctrl + "A", L("Select all objects") },
{ "Esc", L("Deselect all") }, { "Esc", L("Deselect all") },

View file

@ -327,6 +327,27 @@ bool MainFrame::can_send_gcode() const
return print_host_opt != nullptr && !print_host_opt->value.empty(); return print_host_opt != nullptr && !print_host_opt->value.empty();
} }
bool MainFrame::can_export_gcode_sd() const
{
if (m_plater == nullptr)
return false;
if (m_plater->model().objects.empty())
return false;
if (m_plater->is_export_gcode_scheduled())
return false;
// TODO:: add other filters
return wxGetApp().removable_drive_manager()->status().has_removable_drives;
}
bool MainFrame::can_eject() const
{
return wxGetApp().removable_drive_manager()->status().has_eject;
}
bool MainFrame::can_slice() const bool MainFrame::can_slice() const
{ {
bool bg_proc = wxGetApp().app_config->get("background_processing") == "1"; bool bg_proc = wxGetApp().app_config->get("background_processing") == "1";
@ -497,6 +518,9 @@ void MainFrame::init_menubar()
[this](wxCommandEvent&) { if (m_plater) m_plater->send_gcode(); }, "export_gcode", nullptr, [this](wxCommandEvent&) { if (m_plater) m_plater->send_gcode(); }, "export_gcode", nullptr,
[this](){return can_send_gcode(); }, this); [this](){return can_send_gcode(); }, this);
m_changeable_menu_items.push_back(item_send_gcode); m_changeable_menu_items.push_back(item_send_gcode);
append_menu_item(export_menu, wxID_ANY, _(L("Export G-code to SD card / Flash drive")) + dots + "\tCtrl+U", _(L("Export current plate as G-code to SD card / Flash drive")),
[this](wxCommandEvent&) { if (m_plater) m_plater->export_gcode(true); }, "export_to_sd", nullptr,
[this]() {return can_export_gcode_sd(); }, this);
export_menu->AppendSeparator(); export_menu->AppendSeparator();
append_menu_item(export_menu, wxID_ANY, _(L("Export plate as &STL")) + dots, _(L("Export current plate as STL")), append_menu_item(export_menu, wxID_ANY, _(L("Export plate as &STL")) + dots, _(L("Export current plate as STL")),
[this](wxCommandEvent&) { if (m_plater) m_plater->export_stl(); }, "export_plater", nullptr, [this](wxCommandEvent&) { if (m_plater) m_plater->export_stl(); }, "export_plater", nullptr,
@ -520,6 +544,10 @@ void MainFrame::init_menubar()
[this]() {return true; }, this); [this]() {return true; }, this);
append_submenu(fileMenu, export_menu, wxID_ANY, _(L("&Export")), ""); append_submenu(fileMenu, export_menu, wxID_ANY, _(L("&Export")), "");
append_menu_item(fileMenu, wxID_ANY, _(L("Ejec&t SD card / Flash drive")) + dots + "\tCtrl+T", _(L("Eject SD card / Flash drive after the G-code was exported to it.")),
[this](wxCommandEvent&) { if (m_plater) m_plater->eject_drive(); }, "eject_sd", nullptr,
[this]() {return can_eject(); }, this);
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
#if 0 #if 0

View file

@ -70,6 +70,8 @@ class MainFrame : public DPIFrame
bool can_export_supports() const; bool can_export_supports() const;
bool can_export_gcode() const; bool can_export_gcode() const;
bool can_send_gcode() const; bool can_send_gcode() const;
bool can_export_gcode_sd() const;
bool can_eject() const;
bool can_slice() const; bool can_slice() const;
bool can_change_view() const; bool can_change_view() const;
bool can_select() const; bool can_select() const;

View file

@ -876,8 +876,8 @@ Sidebar::Sidebar(Plater *parent)
}; };
init_scalable_btn(&p->btn_send_gcode , "export_gcode", _(L("Send to printer")) + "\tCtrl+Shift+G"); init_scalable_btn(&p->btn_send_gcode , "export_gcode", _(L("Send to printer")) + "\tCtrl+Shift+G");
init_scalable_btn(&p->btn_remove_device, "eject_sd" , _(L("Remove device"))); init_scalable_btn(&p->btn_remove_device, "eject_sd" , _(L("Remove device")) + "\tCtrl+T");
init_scalable_btn(&p->btn_export_gcode_removable, "export_to_sd", _(L("Export to SD card / Flash drive"))); init_scalable_btn(&p->btn_export_gcode_removable, "export_to_sd", _(L("Export to SD card / Flash drive")) + "\tCtrl+U");
// regular buttons "Slice now" and "Export G-code" // regular buttons "Slice now" and "Export G-code"