ConfigWizard: Improved detection of the preferred printer technology when new printers are added

This commit is contained in:
YuSanka 2021-11-25 09:46:52 +01:00
parent e6c7814546
commit 046f9d2380

View File

@ -2522,23 +2522,33 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
{
wxString header, caption = _L("Configuration is edited in ConfigWizard");
const auto enabled_vendors = appconfig_new.vendors();
const auto enabled_vendors_old = app_config->vendors();
bool suppress_sla_printer = model_has_multi_part_objects(wxGetApp().model());
PrinterTechnology preferred_pt = ptAny;
auto get_preferred_printer_technology = [enabled_vendors, suppress_sla_printer](const std::string& bundle_name, const Bundle& bundle) {
auto get_preferred_printer_technology = [enabled_vendors, enabled_vendors_old, suppress_sla_printer](const std::string& bundle_name, const Bundle& bundle) {
const auto config = enabled_vendors.find(bundle_name);
PrinterTechnology pt = ptAny;
if (config != enabled_vendors.end()) {
for (const auto& model : bundle.vendor_profile->models) {
if (const auto model_it = config->second.find(model.id);
model_it != config->second.end() && model_it->second.size() > 0) {
if (pt == ptAny)
pt = model.technology;
// if preferred printer model has SLA printer technology it's important to check the model for multypart state
if (pt == ptSLA && suppress_sla_printer)
continue;
else
pt = model.technology;
const auto config_old = enabled_vendors_old.find(bundle_name);
if (config_old == enabled_vendors_old.end() || config_old->second.find(model.id) == config_old->second.end()) {
// if preferred printer model has SLA printer technology it's important to check the model for multi-part state
if (pt == ptSLA && suppress_sla_printer)
continue;
return pt;
}
if (const auto model_it_old = config_old->second.find(model.id);
model_it_old == config_old->second.end() || model_it_old->second != model_it->second) {
// if preferred printer model has SLA printer technology it's important to check the model for multi-part state
if (pt == ptSLA && suppress_sla_printer)
continue;
return pt;
}
}
}
}
@ -2645,7 +2655,6 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
std::string preferred_model;
std::string preferred_variant;
const auto enabled_vendors_old = app_config->vendors();
auto get_preferred_printer_model = [enabled_vendors, enabled_vendors_old, preferred_pt](const std::string& bundle_name, const Bundle& bundle, std::string& variant) {
const auto config = enabled_vendors.find(bundle_name);
if (config == enabled_vendors.end())