Implementation of the Preferences option "Ask for unsaved changes in project"
This commit is contained in:
parent
934611206d
commit
19f919eca1
2 changed files with 49 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue