diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 7b74b2830f..fdd5a71edd 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1394,6 +1394,8 @@ std::string GUI_App::get_plugin_url(std::string name, std::string country_code) std::string curr_version = SLIC3R_VERSION; std::string using_version = curr_version.substr(0, 9) + "00"; + if (name == "cameratools") + using_version = curr_version.substr(0, 6) + "00.00"; url += (boost::format("?slicer/%1%/cloud=%2%") % name % using_version).str(); //url += (boost::format("?slicer/plugins/cloud=%1%") % "01.01.00.00").str(); return url; @@ -5246,6 +5248,8 @@ bool GUI_App::check_and_save_current_preset_changes(const wxString& caption, con int act_buttons = UnsavedChangesDialog::ActionButtons::SAVE; if (dont_save_insted_of_discard) act_buttons |= UnsavedChangesDialog::ActionButtons::DONT_SAVE; + if (remember_choice) + act_buttons |= UnsavedChangesDialog::ActionButtons::REMEMBER_CHOISE; UnsavedChangesDialog dlg(caption, header, "", act_buttons); if (dlg.ShowModal() == wxID_CANCEL) return false; diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 51ef98f67e..cf07bb3347 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -74,7 +74,7 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he for (auto mb : m_buttons) { delete mb.second->buttondata ; delete mb.second; } } -void MsgDialog::show_dsa_button() +void MsgDialog::show_dsa_button(wxString const &title) { m_checkbox_dsa = new CheckBox(this); m_dsa_sizer->Add(m_checkbox_dsa, 0, wxALL | wxALIGN_CENTER, FromDIP(2)); @@ -86,7 +86,7 @@ void MsgDialog::show_dsa_button() e.Skip(); }); - auto m_text_dsa = new wxStaticText(this, wxID_ANY, _L("Don't show again"), wxDefaultPosition, wxDefaultSize, 0); + auto m_text_dsa = new wxStaticText(this, wxID_ANY, title.IsEmpty() ? _L("Don't show again") : title, wxDefaultPosition, wxDefaultSize, 0); m_dsa_sizer->Add(m_text_dsa, 0, wxALL | wxALIGN_CENTER, FromDIP(2)); m_text_dsa->SetFont(::Label::Body_13); m_text_dsa->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#323A3D"))); diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index 32c4a339cf..5f44bd22e2 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -60,7 +60,7 @@ struct MsgDialog : DPIDialog MsgDialog &operator=(const MsgDialog &) = delete; virtual ~MsgDialog(); - void show_dsa_button(); + void show_dsa_button(wxString const & title = {}); bool get_checkbox_state(); virtual void on_dpi_changed(const wxRect& suggested_rect); void SetButtonLabel(wxWindowID btn_id, const wxString& label, bool set_focus = false); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 51796d8a16..8d60fa64ad 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7555,7 +7555,7 @@ int Plater::new_project(bool skip_confirm, bool silent) (yes_or_no ? _L("You can keep the modified presets to the new project or discard them") : _L("You can keep the modifield presets to the new project, discard or save changes as new presets.")); using ab = UnsavedChangesDialog::ActionButtons; - int act_buttons = ab::KEEP; + int act_buttons = ab::KEEP | ab::REMEMBER_CHOISE; if (!yes_or_no) act_buttons |= ab::SAVE; return wxGetApp().check_and_keep_current_preset_changes(_L("Creating a new project"), header, act_buttons, &transfer_preset_changes); @@ -8870,14 +8870,21 @@ int GUI::Plater::close_with_confirm(std::function second_check) return wxID_NO; } - auto result = MessageDialog(static_cast(this), _L("The current project has unsaved changes, save it before continue?"), - wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Save"), wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxCENTRE).ShowModal(); + MessageDialog dlg(static_cast(this), _L("The current project has unsaved changes, save it before continue?"), + wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Save"), wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxCENTRE); + dlg.show_dsa_button(_L("Remember my choice.")); + auto choise = wxGetApp().app_config->get("save_project_choise"); + auto result = choise.empty() ? dlg.ShowModal() : choise == "yes" ? wxID_YES : wxID_NO; if (result == wxID_CANCEL) return result; - else if (result == wxID_YES) { - result = save_project(); - if (result == wxID_CANCEL) - return result; + else { + if (dlg.get_checkbox_state()) + wxGetApp().app_config->set("save_project_choise", result == wxID_YES ? "yes" : "no"); + if (result == wxID_YES) { + result = save_project(); + if (result == wxID_CANCEL) + return result; + } } if (second_check && !second_check(result == wxID_YES)) return wxID_CANCEL; diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index fac62a3f54..f830ff73cf 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -666,6 +666,40 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa return m_sizer_checkbox; } +wxBoxSizer *PreferencesDialog::create_item_button(wxString title, wxString title2, wxWindow *parent, wxString tooltip, std::function onclick) +{ + wxBoxSizer *m_sizer_checkbox = new wxBoxSizer(wxHORIZONTAL); + + m_sizer_checkbox->Add(0, 0, 0, wxEXPAND | wxLEFT, 23); + auto m_staticTextPath = new wxStaticText(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END); + // m_staticTextPath->SetMaxSize(wxSize(FromDIP(440), -1)); + m_staticTextPath->SetForegroundColour(DESIGN_GRAY900_COLOR); + m_staticTextPath->SetFont(::Label::Body_13); + m_staticTextPath->Wrap(-1); + + auto m_button_download = new Button(parent, title2); + + StateColor abort_bg(std::pair(wxColour(255, 255, 255), StateColor::Disabled), std::pair(wxColour(206, 206, 206), StateColor::Pressed), + std::pair(wxColour(238, 238, 238), StateColor::Hovered), std::pair(wxColour(255, 255, 255), StateColor::Enabled), + std::pair(wxColour(255, 255, 255), StateColor::Normal)); + m_button_download->SetBackgroundColor(abort_bg); + StateColor abort_bd(std::pair(wxColour(144, 144, 144), StateColor::Disabled), std::pair(wxColour(38, 46, 48), StateColor::Enabled)); + m_button_download->SetBorderColor(abort_bd); + StateColor abort_text(std::pair(wxColour(144, 144, 144), StateColor::Disabled), std::pair(wxColour(38, 46, 48), StateColor::Enabled)); + m_button_download->SetTextColor(abort_text); + m_button_download->SetFont(Label::Body_10); + m_button_download->SetMinSize(wxSize(FromDIP(58), FromDIP(22))); + m_button_download->SetSize(wxSize(FromDIP(58), FromDIP(22))); + m_button_download->SetCornerRadius(FromDIP(12)); + + m_button_download->Bind(wxEVT_BUTTON, [this, onclick](auto &e) { onclick(); }); + + m_sizer_checkbox->Add(m_staticTextPath, 0, wxALIGN_CENTER_VERTICAL | wxALL, FromDIP(5)); + m_sizer_checkbox->Add(m_button_download, 0, wxALL, FromDIP(5)); + + return m_sizer_checkbox; +} + wxWindow* PreferencesDialog::create_item_downloads(wxWindow* parent, int padding_left, std::string param) { wxString download_path = wxString::FromUTF8(app_config->get("download_path")); @@ -881,8 +915,11 @@ wxWindow* PreferencesDialog::create_general_page() 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 title_sync_settings = create_item_title(_L("User sync"), page, _L("User sync")); + auto title_presets = create_item_title(_L("Presets"), page, _L("Presets")); auto item_user_sync = create_item_checkbox(_L("Auto sync user presets(Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset"); + auto item_save_presets = create_item_button(_L("Clear my choice on the unsaved presets."), _L("Clear"), page, _L("Clear my choice on the unsaved presets."), []() { + wxGetApp().app_config->set("save_preset_choise", ""); + }); #ifdef _WIN32 auto title_associate_file = create_item_title(_L("Associate files to BambuStudio"), page, _L("Associate files to BambuStudio")); @@ -907,6 +944,9 @@ wxWindow* PreferencesDialog::create_general_page() if (value.ToLong(&max)) wxGetApp().mainframe->set_max_recent_count(max); }); + auto item_save_choise = create_item_button(_L("Clear my choice on the unsaved projects."), _L("Clear"), page, _L("Clear my choice on the unsaved projects."), []() { + wxGetApp().app_config->set("save_project_choise", ""); + }); // auto item_backup = create_item_switch(_L("Backup switch"), page, _L("Backup switch"), "units"); auto item_backup = create_item_checkbox(_L("Auto-Backup"), page,_L("Backup your project periodically for restoring from the occasional crash."), 50, "backup_switch"); auto item_backup_interval = create_item_backup_input(_L("every"), page, _L("The peroid of backup in seconds."), "backup_interval"); @@ -927,8 +967,9 @@ 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(title_sync_settings, 0, wxTOP | wxEXPAND, FromDIP(20)); + sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20)); sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3)); + sizer_page->Add(item_save_presets, 0, wxTOP, FromDIP(3)); #ifdef _WIN32 sizer_page->Add(title_associate_file, 0, wxTOP| wxEXPAND, FromDIP(20)); sizer_page->Add(item_associate_3mf, 0, wxTOP, FromDIP(3)); @@ -940,6 +981,7 @@ wxWindow* PreferencesDialog::create_general_page() sizer_page->Add(title_project, 0, wxTOP| wxEXPAND, FromDIP(20)); sizer_page->Add(item_max_recent_count, 0, wxTOP, FromDIP(3)); + sizer_page->Add(item_save_choise, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_backup, 0, wxTOP,FromDIP(3)); item_backup->Add(item_backup_interval, 0, wxLEFT, 0); diff --git a/src/slic3r/GUI/Preferences.hpp b/src/slic3r/GUI/Preferences.hpp index bfe3c98cde..419242f7ce 100644 --- a/src/slic3r/GUI/Preferences.hpp +++ b/src/slic3r/GUI/Preferences.hpp @@ -110,6 +110,7 @@ public: wxBoxSizer *create_item_checkbox(wxString title, wxWindow *parent, wxString tooltip, int padding_left, std::string param); wxBoxSizer *create_item_darkmode_checkbox(wxString title, wxWindow *parent, wxString tooltip, int padding_left, std::string param); void set_dark_mode(); + wxBoxSizer *create_item_button(wxString title, wxString title2, wxWindow *parent, wxString tooltip, std::function onclick); wxWindow* create_item_downloads(wxWindow* parent, int padding_left, std::string param); wxBoxSizer *create_item_input(wxString title, wxString title2, wxWindow *parent, wxString tooltip, std::string param, std::function onchange = {}); wxBoxSizer *create_item_backup_input(wxString title, wxWindow *parent, wxString tooltip, std::string param); diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index 82c8009a7d..6bf8ccc115 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -27,6 +27,7 @@ #include "BitmapCache.hpp" #include "PresetComboBoxes.hpp" #include "Widgets/RoundedRectangle.hpp" +#include "Widgets/CheckBox.hpp" using boost::optional; @@ -818,6 +819,22 @@ UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type, PresetCollection * } +inline int UnsavedChangesDialog::ShowModal() +{ + auto choise_key = "save_preset_choise"; + auto choise = wxGetApp().app_config->get(choise_key); + long result = 0; + if ((m_buttons & REMEMBER_CHOISE) && !choise.empty() && wxString(choise).ToLong(&result) && (1 << result) & (m_buttons | DONT_SAVE)) { + m_exit_action = Action(result); + return 0; + } + int r = wxDialog::ShowModal(); + if (r != wxID_CANCEL && dynamic_cast<::CheckBox*>(FindWindowById(wxID_APPLY))->GetValue()) { + wxGetApp().app_config->set(choise_key, std::to_string(int(m_exit_action))); + } + return r; +} + void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_presets, const std::string &new_selected_preset, const wxString &header) { SetBackgroundColour(*wxWHITE); @@ -935,6 +952,17 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_ wxBoxSizer *m_sizer_button = new wxBoxSizer(wxHORIZONTAL); + auto checkbox_sizer = new wxBoxSizer(wxHORIZONTAL); + auto checkbox = new ::CheckBox(this, wxID_APPLY); + checkbox_sizer->Add(checkbox, 0, wxALL | wxALIGN_CENTER, FromDIP(2)); + + auto checkbox_text = new wxStaticText(this, wxID_ANY, _L("Remember my choice."), wxDefaultPosition, wxDefaultSize, 0); + checkbox_sizer->Add(checkbox_text, 0, wxALL | wxALIGN_CENTER, FromDIP(2)); + checkbox_text->SetFont(::Label::Body_13); + checkbox_text->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#323A3D"))); + m_sizer_button->Add(checkbox_sizer, 0, wxLEFT, FromDIP(22)); + checkbox_sizer->Show(bool(m_buttons & REMEMBER_CHOISE)); + m_sizer_button->Add(0, 0, 1, 0, 0); // Add Buttons diff --git a/src/slic3r/GUI/UnsavedChangesDialog.hpp b/src/slic3r/GUI/UnsavedChangesDialog.hpp index 04dc15d81b..b1bfbd0eb4 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.hpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.hpp @@ -277,9 +277,9 @@ protected: enum class Action { Undef, - Transfer, + Transfer, // Or KEEP + Save, Discard, - Save }; static constexpr char ActTransfer[] = "transfer"; @@ -320,6 +320,7 @@ public: KEEP = 2, SAVE = 4, DONT_SAVE = 8, + REMEMBER_CHOISE = 0x10000 }; // show unsaved changes when preset is switching @@ -328,7 +329,9 @@ public: UnsavedChangesDialog(const wxString& caption, const wxString& header, const std::string& app_config_key, int act_buttons); ~UnsavedChangesDialog(){}; - void build(Preset::Type type, PresetCollection* dependent_presets, const std::string& new_selected_preset, const wxString& header = ""); + int ShowModal(); + + void build(Preset::Type type, PresetCollection *dependent_presets, const std::string &new_selected_preset, const wxString &header = ""); void update(Preset::Type type, PresetCollection* dependent_presets, const std::string& new_selected_preset, const wxString& header); void update_list(); std::string subreplace(std::string resource_str, std::string sub_str, std::string new_str); diff --git a/src/slic3r/GUI/Widgets/CheckBox.cpp b/src/slic3r/GUI/Widgets/CheckBox.cpp index 4ca1ca5ba0..8a9b05b50b 100644 --- a/src/slic3r/GUI/Widgets/CheckBox.cpp +++ b/src/slic3r/GUI/Widgets/CheckBox.cpp @@ -2,8 +2,8 @@ #include "../wxExtensions.hpp" -CheckBox::CheckBox(wxWindow* parent) - : wxBitmapToggleButton(parent, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE) +CheckBox::CheckBox(wxWindow *parent, int id) + : wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE) , m_on(this, "check_on", 18) , m_half(this, "check_half", 18) , m_off(this, "check_off", 18) diff --git a/src/slic3r/GUI/Widgets/CheckBox.hpp b/src/slic3r/GUI/Widgets/CheckBox.hpp index 53c41b6470..01b801a215 100644 --- a/src/slic3r/GUI/Widgets/CheckBox.hpp +++ b/src/slic3r/GUI/Widgets/CheckBox.hpp @@ -8,7 +8,7 @@ class CheckBox : public wxBitmapToggleButton { public: - CheckBox(wxWindow * parent = NULL); + CheckBox(wxWindow * parent, int id = wxID_ANY); public: void SetValue(bool value) override;