diff options
author | supermerill <merill@free.fr> | 2022-09-06 19:23:14 +0300 |
---|---|---|
committer | supermerill <merill@free.fr> | 2022-09-16 17:13:56 +0300 |
commit | d6cbc5541880d176b17091e46f4d38efc4e96ef1 (patch) | |
tree | 73a605d853f61f2b46e826007200859ce6d6287c | |
parent | bb7fef4ab9602cffea938cbc72faccce69702831 (diff) |
Fix default reset of scripted widgets
supermerill/SuperSlicer#3144
-rw-r--r-- | src/slic3r/GUI/OptionsGroup.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index fa0d9a5e8..f218c1c1e 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -690,33 +690,43 @@ void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config, // Fucntion doesn't exists, reset the fields from the 'depends' // reset in all tabs // first set_key_value + PrinterTechnology printer_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology(); + std::vector<Tab*> tab_list = wxGetApp().tabs_list; + std::set<size_t> modified_tabs_idx; for (const std::string& dep_key : it_opt->second.opt.depends_on) { - for (Tab* tab : wxGetApp().tabs_list) { - if (tab != nullptr && tab->completed()) { + for (const PresetCollection* preset_collection : wxGetApp().get_active_preset_collections()) + for (size_t tab_idx = 0; tab_idx < tab_list.size(); tab_idx++) { + Tab* tab = tab_list[tab_idx]; + if (tab != nullptr && tab->completed() && tab->supports_printer_technology(printer_technology)) { const DynamicPrintConfig& initial_conf = tab->m_presets->get_selected_preset().config; DynamicPrintConfig& edited_conf = tab->m_presets->get_edited_preset().config; if (initial_conf.has(dep_key) && edited_conf.has(dep_key)) { ConfigOption* conf_opt = initial_conf.option(dep_key)->clone(); //set the conf edited_conf.set_key_value(dep_key, conf_opt); + modified_tabs_idx.insert(tab_idx); } } } } // now that all keys are set, call the on_value_change to propagate the changes in one go. for (const std::string& dep_key : it_opt->second.opt.depends_on) { - for (Tab* tab : wxGetApp().tabs_list) { - if (tab != nullptr && tab->completed()) { - const DynamicPrintConfig& initial_conf = tab->m_presets->get_selected_preset().config; - DynamicPrintConfig& edited_conf = tab->m_presets->get_edited_preset().config; - if (initial_conf.has(dep_key) && edited_conf.has(dep_key)) { - ConfigOption* conf_opt = initial_conf.option(dep_key)->clone(); - // update the field - tab->on_value_change(dep_key, conf_opt->getAny()); - } + for (size_t tab_idx : modified_tabs_idx) { + Tab* tab = tab_list[tab_idx]; + const DynamicPrintConfig& initial_conf = tab->m_presets->get_selected_preset().config; + DynamicPrintConfig& edited_conf = tab->m_presets->get_edited_preset().config; + if (initial_conf.has(dep_key) && edited_conf.has(dep_key)) { + ConfigOption* conf_opt = initial_conf.option(dep_key)->clone(); + // update the field + tab->set_value(dep_key, get_config_value(initial_conf, dep_key)); + tab->on_value_change(dep_key, conf_opt->getAny()); } } } + for (size_t tab_idx : modified_tabs_idx) { + // update the decorations + tab_list[tab_idx]->update_changed_ui(); + } } return; } else if (it_opt_map == m_opt_map.end() || |