From 3812f13cb575b6a3c7f208551017324469c42c4a Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 18 Nov 2018 12:02:16 -0600 Subject: [PATCH] Refactor preset setting update to its own method and call during load() --- src/GUI/Plater/PresetChooser.cpp | 10 +++++++--- src/GUI/Plater/PresetChooser.hpp | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/GUI/Plater/PresetChooser.cpp b/src/GUI/Plater/PresetChooser.cpp index c4ecb696d..9d5b3c802 100644 --- a/src/GUI/Plater/PresetChooser.cpp +++ b/src/GUI/Plater/PresetChooser.cpp @@ -109,6 +109,7 @@ void PresetChooser::load(std::array presets) { ++i; } + this->_update_preset_settings(group); } } @@ -132,12 +133,16 @@ bool PresetChooser::select_preset_by_name(wxString name, wxBitmapComboBox* choos return false; } -void PresetChooser::_on_select_preset(preset_t preset) { - // update settings store +void PresetChooser::_update_preset_settings(preset_t preset) { auto& settings_presets {_settings.default_presets.at(get_preset(preset))}; settings_presets.clear(); // make sure previous contents are deconstructed settings_presets = this->_get_selected_presets(preset); +} + +void PresetChooser::_on_select_preset(preset_t preset) { + // update settings store + this->_update_preset_settings(preset); // save settings _settings.save_settings(); if (preset == preset_t::Printer) { @@ -165,7 +170,6 @@ wxString PresetChooser::_get_selected_preset(preset_t group, size_t index) const if (index > selected.size()) { return wxString(""); } return selected.at(index); } - void PresetChooser::_on_change_combobox(preset_t preset, wxBitmapComboBox* choice) { // Prompt for unsaved changes and undo selections if cancelled and return early diff --git a/src/GUI/Plater/PresetChooser.hpp b/src/GUI/Plater/PresetChooser.hpp index 97c7e50ce..1a6d494d8 100644 --- a/src/GUI/Plater/PresetChooser.hpp +++ b/src/GUI/Plater/PresetChooser.hpp @@ -65,6 +65,7 @@ public: bool prompt_unsaved_changes(); private: wxFlexGridSizer* _local_sizer {}; + wxWindow* _parent {}; void _on_change_combobox(preset_t preset, wxBitmapComboBox* choice); chooser_name_map __chooser_names; @@ -85,6 +86,8 @@ private: /// Fetch the preset name corresponding to the chooser index wxString _get_selected_preset(preset_t group, size_t index) const; + /// Update Settings presets with the state of this system + void _update_preset_settings(preset_t preset); }; }} // Slic3r::GUI