Fix of Physical Printer Dialog #9695

This commit is contained in:
David Kocik 2023-02-15 15:52:56 +01:00
parent e2045a60ee
commit 2125996837

View File

@ -462,7 +462,7 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
choice->set_selection();
}
update();
update(true);
}
void PhysicalPrinterDialog::update_printhost_buttons()
@ -632,11 +632,12 @@ void PhysicalPrinterDialog::update_host_type(bool printer_change)
Choice* choice = dynamic_cast<Choice*>(ht);
choice->set_values(types);
int index_in_choice = (printer_change ? 0 : last_in_conf);
int dif = (int)ht->m_opt.enum_def->values().size() - (int)types.size();
int index_in_choice = (printer_change ? std::clamp(last_in_conf - ((int)ht->m_opt.enum_def->values().size() - (int)types.size()), 0, (int)ht->m_opt.enum_def->values().size() - 1) : last_in_conf);
choice->set_value(index_in_choice);
if (link.supported && link.label == _(ht->m_opt.enum_def->label(index_in_choice)))
m_config->set_key_value("host_type", new ConfigOptionEnum<PrintHostType>(htPrusaLink));
else if (link.supported && link.label == _(ht->m_opt.enum_def->label(index_in_choice)))
else if (connect.supported && connect.label == _(ht->m_opt.enum_def->label(index_in_choice)))
m_config->set_key_value("host_type", new ConfigOptionEnum<PrintHostType>(htPrusaConnect));
else {
int host_type = std::clamp(index_in_choice + ((int)ht->m_opt.enum_def->values().size() - (int)types.size()), 0, (int)ht->m_opt.enum_def->values().size() - 1);