mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Project dirty state manager -> presets dirty state
This commit is contained in:
parent
5d4b7c03b6
commit
edbb1d0f69
11 changed files with 206 additions and 18 deletions
|
@ -907,7 +907,7 @@ bool GUI_App::on_init_inner()
|
|||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
if (plater_ != nullptr) {
|
||||
// plater_->reset_project_initial_presets();
|
||||
plater_->reset_project_dirty_initial_presets();
|
||||
plater_->update_project_dirty_from_presets();
|
||||
}
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
|
@ -1673,7 +1673,11 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||
break;
|
||||
case ConfigMenuTakeSnapshot:
|
||||
// Take a configuration snapshot.
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
if (check_and_save_current_preset_changes()) {
|
||||
#else
|
||||
if (check_unsaved_changes()) {
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
wxTextEntryDialog dlg(nullptr, _L("Taking configuration snapshot"), _L("Snapshot name"));
|
||||
|
||||
// set current normal font for dialog children,
|
||||
|
@ -1688,7 +1692,11 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||
}
|
||||
break;
|
||||
case ConfigMenuSnapshots:
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
if (check_and_save_current_preset_changes()) {
|
||||
#else
|
||||
if (check_unsaved_changes()) {
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
std::string on_snapshot;
|
||||
if (Config::SnapshotDB::singleton().is_on_snapshot(*app_config))
|
||||
on_snapshot = app_config->get("on_snapshot");
|
||||
|
@ -1789,8 +1797,57 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||
menu->Append(local_menu, _L("&Configuration"));
|
||||
}
|
||||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
bool GUI_App::has_unsaved_preset_changes() const
|
||||
{
|
||||
PrinterTechnology printer_technology = preset_bundle->printers.get_edited_preset().printer_technology();
|
||||
for (const Tab* const tab : tabs_list) {
|
||||
if (tab->supports_printer_technology(printer_technology) && tab->saved_preset_is_dirty())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GUI_App::has_current_preset_changes() const
|
||||
{
|
||||
PrinterTechnology printer_technology = preset_bundle->printers.get_edited_preset().printer_technology();
|
||||
for (const Tab* const tab : tabs_list) {
|
||||
if (tab->supports_printer_technology(printer_technology) && tab->current_preset_is_dirty())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GUI_App::update_saved_preset_from_current_preset()
|
||||
{
|
||||
PrinterTechnology printer_technology = preset_bundle->printers.get_edited_preset().printer_technology();
|
||||
for (Tab* tab : tabs_list) {
|
||||
if (tab->supports_printer_technology(printer_technology))
|
||||
tab->update_saved_preset_from_current_preset();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::pair<unsigned int, std::string>> GUI_App::get_selected_presets() const
|
||||
{
|
||||
std::vector<std::pair<unsigned int, std::string>> ret;
|
||||
PrinterTechnology printer_technology = preset_bundle->printers.get_edited_preset().printer_technology();
|
||||
for (Tab* tab : tabs_list) {
|
||||
if (tab->supports_printer_technology(printer_technology)) {
|
||||
const PresetCollection* presets = tab->get_presets();
|
||||
ret.push_back({ static_cast<unsigned int>(presets->type()), presets->get_selected_preset_name() });
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
|
||||
// This is called when closing the application, when loading a config file or when starting the config wizard
|
||||
// to notify the user whether he is aware that some preset changes will be lost.
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
bool GUI_App::check_and_save_current_preset_changes(const wxString& header)
|
||||
{
|
||||
if (this->plater()->model().objects.empty() && has_current_preset_changes()) {
|
||||
#else
|
||||
bool GUI_App::check_unsaved_changes(const wxString &header)
|
||||
{
|
||||
PrinterTechnology printer_technology = preset_bundle->printers.get_edited_preset().printer_technology();
|
||||
|
@ -1802,8 +1859,8 @@ bool GUI_App::check_unsaved_changes(const wxString &header)
|
|||
break;
|
||||
}
|
||||
|
||||
if (has_unsaved_changes)
|
||||
{
|
||||
if (has_unsaved_changes) {
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
UnsavedChangesDialog dlg(header);
|
||||
if (wxGetApp().app_config->get("default_action_on_close_application") == "none" && dlg.ShowModal() == wxID_CANCEL)
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue