From 02b3cd119a5d8ac67dc05bd1be667ee668b02f75 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Tue, 14 Mar 2023 21:29:58 +0800 Subject: [PATCH] add `show_gcode_window` preference --- src/libslic3r/AppConfig.cpp | 3 +++ src/slic3r/GUI/GCodeViewer.cpp | 2 +- src/slic3r/GUI/GUI_App.cpp | 1 + src/slic3r/GUI/GUI_App.hpp | 8 +++++++- src/slic3r/GUI/Preferences.cpp | 7 +++++++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 8f0788eefd..7579311b13 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -175,6 +175,9 @@ void AppConfig::set_defaults() set_bool("show_hints", true); //#endif + if (get("show_gcode_window").empty()) + set_bool("show_gcode_window", true); + #ifdef _WIN32 diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index cb3bd05d3e..8818f5fd9d 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -579,7 +579,7 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, f static const ImVec4 PARAMETERS_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f }; static const ImVec4 COMMENT_COLOR = { 0.7f, 0.7f, 0.7f, 1.0f }; - if (!m_visible || m_filename.empty() || m_lines_ends.empty() || curr_line_id == 0) + if (!m_visible || !wxGetApp().show_gcode_window() || m_filename.empty() || m_lines_ends.empty() || curr_line_id == 0) return; // window height diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 1327a8eaf6..f12c23a11a 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1096,6 +1096,7 @@ void GUI_App::post_init() } #endif + m_show_gcode_window = app_config->get("show_gcode_window") == "true"; if (m_networking_need_update) { //updating networking int ret = updating_bambu_networking(); diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index c4e4655f96..d370a1fe6a 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -290,7 +290,9 @@ private: bool m_adding_script_handler { false }; bool m_side_popup_status{false}; HttpServer m_http_server; -public: + bool m_show_gcode_window{true}; + + public: void check_filaments_in_blacklist(std::string tag_supplier, std::string tag_material, bool& in_blacklist, std::string& action, std::string& info); std::string get_local_models_path(); bool OnInit() override; @@ -310,6 +312,10 @@ public: bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; } bool is_recreating_gui() const { return m_is_recreating_gui; } std::string logo_name() const { return is_editor() ? "OrcaSlicer" : "BambuStudio-gcodeviewer"; } + + // SoftFever + bool show_gcode_window() const { return m_show_gcode_window; } + void set_show_gcode_window(bool val) { m_show_gcode_window = val; } // To be called after the GUI is fully built up. // Process command line parameters cached in this->init_params, diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 2926903df1..adb0a3ae29 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -593,6 +593,11 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa } } + if (param == "show_gcode_window") { + bool pbool = app_config->get("show_gcode_window") == "true" ? true : false; + wxGetApp().set_show_gcode_window(pbool); + } + #endif // __WXMSW__ e.Skip(); @@ -821,6 +826,7 @@ wxWindow* PreferencesDialog::create_general_page() auto item_currency = create_item_combobox(_L("Units"), page, _L("Units"), "use_inches", Units); auto item_hints = create_item_checkbox(_L("Show \"Tip of the day\" notification after start"), page, _L("If enabled, useful hints are displayed at startup."), 50, "show_hints"); + auto item_gcode_window = create_item_checkbox(_L("Show g-code window"), page, _L("If enabled, g-code window will be displayed."), 50, "show_gcode_window"); auto title_sync_settings = create_item_title(_L("User sync"), page, _L("User sync")); auto item_user_sync = create_item_checkbox(_L("Auto sync user presets(Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset"); @@ -859,6 +865,7 @@ wxWindow* PreferencesDialog::create_general_page() sizer_page->Add(item_region, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_currency, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3)); + sizer_page->Add(item_gcode_window, 0, wxTOP, FromDIP(3)); sizer_page->Add(title_sync_settings, 0, wxTOP | wxEXPAND, FromDIP(20)); sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3)); #ifdef _WIN32