Follow up previous cdf07c3cce - code improvements

This commit is contained in:
YuSanka 2022-10-27 17:16:44 +02:00
parent cdf07c3cce
commit ece63f5d81
2 changed files with 15 additions and 11 deletions

View File

@ -4180,13 +4180,6 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
combo->update(); combo->update();
} }
else if (select_preset) { else if (select_preset) {
if (preset_type == Preset::TYPE_PRINTER) {
PhysicalPrinterCollection& physical_printers = wxGetApp().preset_bundle->physical_printers;
if(combo->is_selected_physical_printer())
preset_name = physical_printers.get_selected_printer_preset_name();
else
physical_printers.unselect_printer();
}
wxWindowUpdateLocker noUpdates(sidebar->presets_panel()); wxWindowUpdateLocker noUpdates(sidebar->presets_panel());
wxGetApp().get_tab(preset_type)->select_preset(preset_name); wxGetApp().get_tab(preset_type)->select_preset(preset_name);
} }

View File

@ -515,12 +515,24 @@ bool PresetComboBox::is_selected_physical_printer()
bool PresetComboBox::selection_is_changed_according_to_physical_printers() bool PresetComboBox::selection_is_changed_according_to_physical_printers()
{ {
if (m_type != Preset::TYPE_PRINTER || !is_selected_physical_printer()) if (m_type != Preset::TYPE_PRINTER)
return false; return false;
PhysicalPrinterCollection& physical_printers = m_preset_bundle->physical_printers; const std::string selected_string = into_u8(this->GetString(this->GetSelection()));
PhysicalPrinterCollection& physical_printers = m_preset_bundle->physical_printers;
Tab* tab = wxGetApp().get_tab(Preset::TYPE_PRINTER);
std::string selected_string = this->GetString(this->GetSelection()).ToUTF8().data(); if (!is_selected_physical_printer()) {
if (!physical_printers.has_selection())
return false;
const bool is_changed = selected_string == physical_printers.get_selected_printer_preset_name();
if (is_changed)
tab->select_preset(selected_string);
physical_printers.unselect_printer();
return is_changed;
}
std::string old_printer_full_name, old_printer_preset; std::string old_printer_full_name, old_printer_preset;
if (physical_printers.has_selection()) { if (physical_printers.has_selection()) {
@ -548,7 +560,6 @@ bool PresetComboBox::selection_is_changed_according_to_physical_printers()
return true; return true;
} }
Tab* tab = wxGetApp().get_tab(Preset::TYPE_PRINTER);
if (tab) if (tab)
tab->select_preset(preset_name, false, old_printer_full_name); tab->select_preset(preset_name, false, old_printer_full_name);
return true; return true;