ENH: [STUDIO-2549] remember my choice on unsaved project/presets

Change-Id: Ib9fc9074075bfce19f9a02be3aff7b3d04e3802a
This commit is contained in:
chunmao.guo 2023-03-23 14:14:36 +08:00 committed by Lane.Wei
parent 778761908a
commit 8c39fbaf22
10 changed files with 103 additions and 18 deletions

View file

@ -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<bool(bool)> second_check)
return wxID_NO;
}
auto result = MessageDialog(static_cast<wxWindow*>(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<wxWindow*>(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;