Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2022-01-06 12:39:12 +0300
committerYuSanka <yusanka@gmail.com>2022-01-06 12:39:12 +0300
commit19f919eca1e5b36b42f3f81090d225fc35daa724 (patch)
tree16112844ebdb08c6f27d4fa62204ea8065e7abd2 /src/slic3r/GUI
parent934611206d8ab360ccabe9f27c7d6d72f3fb807e (diff)
Implementation of the Preferences option "Ask for unsaved changes in project"
Diffstat (limited to 'src/slic3r/GUI')
-rw-r--r--src/slic3r/GUI/Plater.cpp29
-rw-r--r--src/slic3r/GUI/Preferences.cpp24
2 files changed, 49 insertions, 4 deletions
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index 60efb3fae..734cb7f0c 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -1720,8 +1720,33 @@ struct Plater::priv
fs::path output_file = get_export_file_path(FT_3MF);
suggested_project_name = output_file.empty() ? _L("Untitled") : from_u8(output_file.stem().string());
}
- res = MessageDialog(mainframe, reason + "\n" + format_wxstr(_L("Do you want to save the changes to \"%1%\"?"), suggested_project_name),
- wxString(SLIC3R_APP_NAME), wxYES_NO | wxCANCEL).ShowModal();
+
+ std::string act_key = "default_action_on_dirty_project";
+ std::string act = wxGetApp().app_config->get(act_key);
+ if (act.empty()) {
+ RichMessageDialog dialog(mainframe, reason + "\n" + format_wxstr(_L("Do you want to save the changes to \"%1%\"?"), suggested_project_name), wxString(SLIC3R_APP_NAME), wxYES_NO | wxCANCEL);
+ dialog.ShowCheckBox(_L("Remember my choice"));
+ res = dialog.ShowModal();
+ if (res != wxID_CANCEL)
+ if (dialog.IsCheckBoxChecked()) {
+ wxString preferences_item = _L("Ask for unsaved changes in project");
+ wxString msg =
+ _L("PrusaSlicer will remember your choice.") + "\n\n" +
+ _L("You will not be asked about it again, when: \n"
+ "- Closing PrusaSlicer,\n"
+ "- Loading or creating a new project") + "\n\n" +
+ format_wxstr(_L("Visit \"Preferences\" and check \"%1%\"\nto changes your choice."), preferences_item);
+
+ MessageDialog msg_dlg(mainframe, msg, _L("PrusaSlicer: Don't ask me again"), wxOK | wxCANCEL | wxICON_INFORMATION);
+ if (msg_dlg.ShowModal() == wxID_CANCEL)
+ return wxID_CANCEL;
+
+ get_app_config()->set(act_key, res == wxID_YES ? "1" : "0");
+ }
+ }
+ else
+ res = (act == "1") ? wxID_YES : wxID_NO;
+
if (res == wxID_YES)
if (!mainframe->save_project_as(project_name))
res = wxID_CANCEL;
diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp
index 7ef62b84c..1d98dfd5d 100644
--- a/src/slic3r/GUI/Preferences.cpp
+++ b/src/slic3r/GUI/Preferences.cpp
@@ -107,6 +107,8 @@ void PreferencesDialog::build(size_t selected_tab)
m_optgroup_general->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
if (opt_key == "default_action_on_close_application" || opt_key == "default_action_on_select_preset" || opt_key == "default_action_on_new_project")
m_values[opt_key] = boost::any_cast<bool>(value) ? "none" : "discard";
+ else if (opt_key == "default_action_on_dirty_project")
+ m_values[opt_key] = boost::any_cast<bool>(value) ? "" : "0";
else
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
};
@@ -217,6 +219,17 @@ void PreferencesDialog::build(size_t selected_tab)
m_optgroup_general->append_separator();
+ def.label = L("Ask for unsaved changes in project");
+ def.type = coBool;
+ def.tooltip = L("Always ask for unsaved changes in project, when: \n"
+ "- Closing PrusaSlicer,\n"
+ "- Loading or creating a new project");
+ def.set_default_value(new ConfigOptionBool{ app_config->get("default_action_on_dirty_project").empty() });
+ option = Option(def, "default_action_on_dirty_project");
+ m_optgroup_general->append_single_option_line(option);
+
+ m_optgroup_general->append_separator();
+
def.label = L("Ask to save unsaved changes in presets when closing the application or when loading a new project");
def.type = coBool;
def.tooltip = L("Always ask for unsaved changes in presets, when: \n"
@@ -590,10 +603,17 @@ void PreferencesDialog::accept(wxEvent&)
}
}
- for (const std::string& key : {"default_action_on_close_application", "default_action_on_select_preset"}) {
+ for (const std::string& key : { "default_action_on_close_application",
+ "default_action_on_select_preset",
+ "default_action_on_new_project" }) {
auto it = m_values.find(key);
if (it != m_values.end() && it->second != "none" && app_config->get(key) != "none")
- m_values.erase(it); // we shouldn't change value, if some of those parameters was selected, and then deselected
+ m_values.erase(it); // we shouldn't change value, if some of those parameters were selected, and then deselected
+ }
+ {
+ auto it = m_values.find("default_action_on_dirty_project");
+ if (it != m_values.end() && !it->second.empty() && !app_config->get("default_action_on_dirty_project").empty())
+ m_values.erase(it); // we shouldn't change value, if this parameter was selected, and then deselected
}
#if 0 //#ifdef _WIN32 // #ysDarkMSW - Allow it when we deside to support the sustem colors for application