From 7b4aeef40cee995e7db49e4a882a13bc1c65d5d3 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 21 May 2018 21:04:03 +0200 Subject: [PATCH] Moved the "Flash firmware" menu to "Configuration", removed the "Check for updates" from the "Configuration" menu, added an "Open file explorer at the datadir" item to the Help menu. --- lib/Slic3r/GUI/MainFrame.pm | 3 ++ xs/src/slic3r/GUI/GUI.cpp | 55 ++++++++++++++++--------------------- xs/src/slic3r/GUI/GUI.hpp | 4 ++- xs/xsp/GUI.xsp | 4 ++- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index dbec97584..2b93351f8 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -334,6 +334,9 @@ sub _init_menubar { $self->_append_menu_item($helpMenu, L("System Info"), L('Show system information'), sub { wxTheApp->system_info; }); + $self->_append_menu_item($helpMenu, L("Show &Configuration Folder"), L('Show user configuration folder (datadir)'), sub { + Slic3r::GUI::desktop_open_datadir_folder(); + }); $self->_append_menu_item($helpMenu, L("Report an Issue"), L('Report an issue on the Slic3r Prusa Edition'), sub { Wx::LaunchDefaultBrowser('http://github.com/prusa3d/slic3r/issues/new'); }); diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 095ff6b10..99b63e1f9 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -305,6 +305,7 @@ enum ConfigMenuIDs { ConfigMenuUpdate, ConfigMenuPreferences, ConfigMenuLanguage, + ConfigMenuFlashFirmware, ConfigMenuCnt, }; @@ -318,11 +319,15 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l local_menu->Append(config_id_base + ConfigMenuWizard, ConfigWizard::name() + "\u2026", config_wizard_tooltip); local_menu->Append(config_id_base + ConfigMenuSnapshots, _(L("Configuration Snapshots"))+"\u2026", _(L("Inspect / activate configuration snapshots"))); local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _(L("Take Configuration Snapshot")), _(L("Capture a configuration snapshot"))); - local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); +// local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); local_menu->AppendSeparator(); local_menu->Append(config_id_base + ConfigMenuPreferences, _(L("Preferences"))+"\u2026\tCtrl+,", _(L("Application preferences"))); - local_menu->AppendSeparator(); local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); + local_menu->AppendSeparator(); + local_menu->Append(config_id_base + ConfigMenuFlashFirmware, _(L("Flash printer firmware")), _(L("Upload a firmware image into an Arduino based printer"))); + // TODO: for when we're able to flash dictionaries + // local_menu->Append(config_id_base + FirmwareMenuDict, _(L("Flash language file")), _(L("Upload a language dictionary file into a Prusa printer"))); + local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){ switch (event.GetId() - config_id_base) { case ConfigMenuWizard: @@ -377,47 +382,20 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l } } break; - } } - }); - menu->Append(local_menu, _(L("&Configuration"))); -} - -enum FirmwareMenuIDs { - FirmwareMenuFlash, - FirmwareMenuDict, - FirmwareMenuCnt, -}; - -void add_firmware_menu(wxMenuBar *top_menu) -{ - auto *menu = new wxMenu(); - wxWindowID id_base = wxWindow::NewControlId(FirmwareMenuCnt); - - menu->Append(id_base + FirmwareMenuFlash, _(L("Flash printer firmware")), _(L("Upload a firmware image into a Prusa printer"))); - // TODO: for when we're able to flash dictionaries - // menu->Append(id_base + FirmwareMenuDict, _(L("Flash language file")), _(L("Upload a language dictionary file into a Prusa printer"))); - - menu->Bind(wxEVT_MENU, [id_base](wxEvent &event) { - switch (event.GetId() - id_base) { - case FirmwareMenuFlash: + case ConfigMenuFlashFirmware: FirmwareDialog::run(g_wxMainFrame); break; - case FirmwareMenuDict: - // TODO - break; default: break; } }); - - top_menu->Append(menu, _(L("Fir&mware"))); + menu->Append(local_menu, _(L("&Configuration"))); } void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_language_change) { add_config_menu(menu, event_language_change, event_language_change); - add_firmware_menu(menu); } // This is called when closing the application, when loading a config file or when starting the config wizard @@ -951,4 +929,19 @@ void about() dlg.Destroy(); } +void desktop_open_datadir_folder() +{ + std::string cmd = +#ifdef _WIN32 + "explorer " +#elif __APPLE__ + "open " +#else + "xdg-open " +#endif + ; + cmd += data_dir(); + ::wxExecute(wxString::FromUTF8(cmd.c_str()), wxEXEC_ASYNC, nullptr); +} + } } diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index ce3c05616..4deee1910 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -158,7 +158,9 @@ void add_export_option(wxFileDialog* dlg, const std::string& format); int get_export_option(wxFileDialog* dlg); // Display an About dialog -void about(); +extern void about(); +// Ask the destop to open the datadir using the default file explorer. +extern void desktop_open_datadir_folder(); } // namespace GUI } // namespace Slic3r diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index f45ddfdfc..897e63693 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -95,4 +95,6 @@ void add_export_option(SV *ui, std::string format) int get_export_option(SV *ui) %code%{ RETVAL = Slic3r::GUI::get_export_option((wxFileDialog*)wxPli_sv_2_object(aTHX_ ui, "Wx::FileDialog")); %}; - \ No newline at end of file + +void desktop_open_datadir_folder() + %code%{ Slic3r::GUI::desktop_open_datadir_folder(); %};