diff --git a/resources/icons/exit.svg b/resources/icons/exit.svg
new file mode 100644
index 000000000..eca78da62
--- /dev/null
+++ b/resources/icons/exit.svg
@@ -0,0 +1,20 @@
+
+
+
+
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index 7b3309398..cfbe4104b 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -1526,41 +1526,8 @@ bool GUI_App::check_unsaved_changes(const wxString &header)
if (dlg.save_preset()) // save selected changes
{
- struct NameType
- {
- std::string name;
- Preset::Type type {Preset::TYPE_INVALID};
- };
-
- std::vector names_and_types;
-
- // for system/default/external presets we should take an edited name
- std::vector types;
- for (Tab* tab : tabs_list)
- if (tab->supports_printer_technology(printer_technology) && tab->current_preset_is_dirty())
- {
- const Preset& preset = tab->get_presets()->get_edited_preset();
- if (preset.is_system || preset.is_default || preset.is_external)
- types.emplace_back(preset.type);
-
- names_and_types.emplace_back(NameType{ preset.name, preset.type });
- }
-
-
- if (!types.empty()) {
- SavePresetDialog save_dlg(types);
- if (save_dlg.ShowModal() != wxID_OK)
- return false;
-
- for (NameType& nt : names_and_types) {
- const std::string name = save_dlg.get_name(nt.type);
- if (!name.empty())
- nt.name = name;
- }
- }
-
- for (const NameType& nt : names_and_types)
- preset_bundle->save_changes_for_preset(nt.name, nt.type, dlg.get_unselected_options(nt.type));
+ for (const std::pair& nt : dlg.get_names_and_types())
+ preset_bundle->save_changes_for_preset(nt.first, nt.second, dlg.get_unselected_options(nt.second));
// if we saved changes to the new presets, we should to
// synchronize config.ini with the current selections.
diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp
index f5570c514..3ef5012ee 100644
--- a/src/slic3r/GUI/MainFrame.cpp
+++ b/src/slic3r/GUI/MainFrame.cpp
@@ -361,7 +361,7 @@ void MainFrame::update_layout()
fromDlg,
toDlg
};
- State update_scaling_state = m_layout == ESettingsLayout::Unknown ? State::noUpdate : // don't scale settings dialog from the application start
+ State update_scaling_state = //m_layout == ESettingsLayout::Unknown ? State::noUpdate : // don't scale settings dialog from the application start
m_layout == ESettingsLayout::Dlg ? State::fromDlg :
layout == ESettingsLayout::Dlg ? State::toDlg : State::noUpdate;
#endif //__WXMSW__
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp
index d46413320..c5ac0b9d8 100644
--- a/src/slic3r/GUI/Tab.cpp
+++ b/src/slic3r/GUI/Tab.cpp
@@ -3336,17 +3336,8 @@ bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr
if (dlg.save_preset()) // save selected changes
{
- std::vector unselected_options = dlg.get_unselected_options(presets->type());
- const Preset& preset = presets->get_edited_preset();
- std::string name = preset.name;
-
- // for system/default/external presets we should take an edited name
- if (preset.is_system || preset.is_default || preset.is_external) {
- SavePresetDialog save_dlg(preset.type);
- if (save_dlg.ShowModal() != wxID_OK)
- return false;
- name = save_dlg.get_name();
- }
+ const std::vector& unselected_options = dlg.get_unselected_options(presets->type());
+ const std::string& name = dlg.get_preset_name();
if (m_type == presets->type()) // save changes for the current preset from this tab
{
@@ -3358,9 +3349,9 @@ bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr
{
m_preset_bundle->save_changes_for_preset(name, presets->type(), unselected_options);
- /* If filament preset is saved for multi-material printer preset,
- * there are cases when filament comboboxs are updated for old (non-modified) colors,
- * but in full_config a filament_colors option aren't.*/
+ // If filament preset is saved for multi-material printer preset,
+ // there are cases when filament comboboxs are updated for old (non-modified) colors,
+ // but in full_config a filament_colors option aren't.
if (presets->type() == Preset::TYPE_FILAMENT && wxGetApp().extruders_edited_cnt() > 1)
wxGetApp().plater()->force_filament_colors_update();
}
@@ -3878,8 +3869,8 @@ void TabPrinter::update_machine_limits_description(const MachineLimitsUsage usag
text = _L("Machine limits will be emitted to G-code and used to estimate print time.");
break;
case MachineLimitsUsage::TimeEstimateOnly:
- text = _L("Machine limits will NOT be emitted to G-code, however they will be used to estimate print time, \
- which may herefore not be accurate as the printer may apply a different set of machine limits.");
+ text = _L("Machine limits will NOT be emitted to G-code, however they will be used to estimate print time, "
+ "which may herefore not be accurate as the printer may apply a different set of machine limits.");
break;
case MachineLimitsUsage::Ignore:
text = _L("Machine limits are not set, therefore the print time estimate may not be accurate.");
@@ -3887,6 +3878,8 @@ void TabPrinter::update_machine_limits_description(const MachineLimitsUsage usag
default: assert(false);
}
m_machine_limits_description_line->SetText(text);
+
+ Layout();
}
void Tab::compatible_widget_reload(PresetDependencies &deps)
diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp
index e43f738c4..68ecd49d1 100644
--- a/src/slic3r/GUI/UnsavedChangesDialog.cpp
+++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp
@@ -13,6 +13,7 @@
#include "Tab.hpp"
#include "ExtraRenderers.hpp"
#include "wxExtensions.hpp"
+#include "PresetComboBoxes.hpp"
//#define FTS_FUZZY_MATCH_IMPLEMENTATION
//#include "fts_fuzzy_match.h"
@@ -515,13 +516,13 @@ void UnsavedChangesModel::Rescale()
//------------------------------------------
UnsavedChangesDialog::UnsavedChangesDialog(const wxString& header)
- : DPIDialog(nullptr, wxID_ANY, _L("Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+ : DPIDialog(nullptr, wxID_ANY, _L("Close Aplication: Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
build(Preset::TYPE_INVALID, nullptr, "", header);
}
UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type, PresetCollection* dependent_presets, const std::string& new_selected_preset)
- : DPIDialog(nullptr, wxID_ANY, _L("Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+ : DPIDialog(nullptr, wxID_ANY, _L("Select New Preset: Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
build(type, dependent_presets, new_selected_preset);
}
@@ -577,12 +578,12 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
// Add Buttons
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxCANCEL);
- auto add_btn = [this, buttons](ScalableButton** btn, int& btn_id, const std::string& icon_name, Action close_act, int idx, bool process_enable = true)
+ auto add_btn = [this, buttons, dependent_presets](ScalableButton** btn, int& btn_id, const std::string& icon_name, Action close_act, int idx, bool process_enable = true)
{
*btn = new ScalableButton(this, btn_id = NewControlId(), icon_name, "", wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, true);
buttons->Insert(idx, *btn, 0, wxLEFT, 5);
- (*btn)->Bind(wxEVT_BUTTON, [this, close_act](wxEvent&) { close(close_act); });
+ (*btn)->Bind(wxEVT_BUTTON, [this, close_act, dependent_presets](wxEvent&) { close_act == Action::Save ? save_and_close(dependent_presets) : close(close_act); });
if (process_enable)
(*btn)->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(!m_empty_selection); });
(*btn)->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& e) { show_info_line(Action::Undef); e.Skip(); });
@@ -596,7 +597,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
dependent_presets->get_edited_preset().printer_technology() == dependent_presets->find_preset(new_selected_preset)->printer_technology() :
printers.get_edited_preset().printer_technology() == printers.find_preset(new_selected_preset)->printer_technology() ) )
add_btn(&m_move_btn, m_move_btn_id, "paste_menu", Action::Move, btn_idx++);
- add_btn(&m_continue_btn, m_continue_btn_id, "cross", Action::Continue, btn_idx, false);
+ add_btn(&m_continue_btn, m_continue_btn_id, dependent_presets ? "cross" : "exit", Action::Continue, btn_idx, false);
m_info_line = new wxStaticText(this, wxID_ANY, "");
m_info_line->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold());
@@ -667,7 +668,7 @@ void UnsavedChangesDialog::show_info_line(Action action, std::string preset_name
if (action == Action::Undef)
text = _L("Some fields are too long to fit. Right click on it to show full text.");
else if (action == Action::Continue)
- text = _L("All changed options will be reverted.");
+ text = _L("All modified options will be reverted.");
else {
std::string act_string = action == Action::Save ? _u8L("save") : _u8L("move");
if (preset_name.empty())
@@ -692,6 +693,58 @@ void UnsavedChangesDialog::close(Action action)
this->EndModal(wxID_CLOSE);
}
+void UnsavedChangesDialog::save_and_close(PresetCollection* dependent_presets)
+{
+ names_and_types.clear();
+
+ // save one preset
+ if (dependent_presets) {
+ const Preset& preset = dependent_presets->get_edited_preset();
+ std::string name = preset.name;
+
+ // for system/default/external presets we should take an edited name
+ if (preset.is_system || preset.is_default || preset.is_external) {
+ SavePresetDialog save_dlg(preset.type);
+ if (save_dlg.ShowModal() != wxID_OK)
+ return;
+ name = save_dlg.get_name();
+ }
+
+ names_and_types.emplace_back(make_pair(name, preset.type));
+ }
+ // save all presets
+ else
+ {
+ std::vector types_for_save;
+
+ PrinterTechnology printer_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
+
+ for (Tab* tab : wxGetApp().tabs_list)
+ if (tab->supports_printer_technology(printer_technology) && tab->current_preset_is_dirty()) {
+ const Preset& preset = tab->get_presets()->get_edited_preset();
+ if (preset.is_system || preset.is_default || preset.is_external)
+ types_for_save.emplace_back(preset.type);
+
+ names_and_types.emplace_back(make_pair(preset.name, preset.type));
+ }
+
+
+ if (!types_for_save.empty()) {
+ SavePresetDialog save_dlg(types_for_save);
+ if (save_dlg.ShowModal() != wxID_OK)
+ return;
+
+ for (std::pair& nt : names_and_types) {
+ const std::string& name = save_dlg.get_name(nt.second);
+ if (!name.empty())
+ nt.first = name;
+ }
+ }
+ }
+
+ close(Action::Save);
+}
+
template
wxString get_string_from_enum(const std::string& opt_key, const DynamicPrintConfig& config, bool is_infill = false)
{
@@ -866,11 +919,11 @@ void UnsavedChangesDialog::update(Preset::Type type, PresetCollection* dependent
}
m_continue_btn ->Bind(wxEVT_ENTER_WINDOW, [this] (wxMouseEvent& e) { show_info_line(Action::Continue); e.Skip(); });
- m_continue_btn->SetLabel(_L("Continue without changes"));
if (type == Preset::TYPE_INVALID) {
m_action_line ->SetLabel(header + "\n" + _L("Next presets have the following unsaved changes:"));
m_save_btn ->SetLabel(_L("Save selected"));
+ m_continue_btn ->SetLabel(_L("Close aplication without changes"));
}
else {
wxString action_msg;
@@ -891,6 +944,7 @@ void UnsavedChangesDialog::update(Preset::Type type, PresetCollection* dependent
}
m_action_line->SetLabel(from_u8((boost::format(_utf8(L("Preset \"%1%\" %2%"))) % _utf8(presets->get_edited_preset().name) % action_msg).str()));
m_save_btn->SetLabel(from_u8((boost::format(_u8L("Save selected to preset: %1%")) % ("\"" + presets->get_selected_preset().name + "\"")).str()));
+ m_continue_btn->SetLabel(_L("Select new preset without changes"));
}
update_tree(type, presets);
diff --git a/src/slic3r/GUI/UnsavedChangesDialog.hpp b/src/slic3r/GUI/UnsavedChangesDialog.hpp
index f78a1fec0..a50a5f480 100644
--- a/src/slic3r/GUI/UnsavedChangesDialog.hpp
+++ b/src/slic3r/GUI/UnsavedChangesDialog.hpp
@@ -227,6 +227,9 @@ class UnsavedChangesDialog : public DPIDialog
// tree items related to the options
std::map m_items_map;
+ // preset names which are modified in SavePresetDialog and related types
+ std::vector> names_and_types;
+
public:
UnsavedChangesDialog(const wxString& header);
UnsavedChangesDialog(Preset::Type type, PresetCollection* dependent_presets, const std::string& new_selected_preset);
@@ -241,11 +244,17 @@ public:
void context_menu(wxDataViewEvent &event);
void show_info_line(Action action, std::string preset_name = "");
void close(Action action);
+ void save_and_close(PresetCollection* dependent_presets);
bool save_preset() const { return m_exit_action == Action::Save; }
bool move_preset() const { return m_exit_action == Action::Move; }
bool just_continue() const { return m_exit_action == Action::Continue; }
+ // get full bundle of preset names and types for saving
+ const std::vector>& get_names_and_types() { return names_and_types; }
+ // short version of the previous function, for the case, when just one preset is modified
+ std::string get_preset_name() { return names_and_types[0].first; }
+
std::vector get_unselected_options(Preset::Type type);
std::vector get_selected_options();