FIX: select printer preset with same printer_variant as old
Change-Id: Iccf72ed34da620f8ca728dfc56585f2ab2a496b9 Jira: STUDIO-11210
This commit is contained in:
parent
f5c447ddf0
commit
4a270ee6d3
|
@ -2280,23 +2280,30 @@ Preset *PresetBundle::get_similar_printer_preset(std::string printer_model, std:
|
||||||
if (printer_model.empty())
|
if (printer_model.empty())
|
||||||
printer_model = printers.get_selected_preset().config.opt_string("printer_model");
|
printer_model = printers.get_selected_preset().config.opt_string("printer_model");
|
||||||
auto printer_variant_old = printers.get_selected_preset().config.opt_string("printer_variant");
|
auto printer_variant_old = printers.get_selected_preset().config.opt_string("printer_variant");
|
||||||
std::set<std::string> printer_names;
|
std::map<std::string, Preset*> printer_presets;
|
||||||
for (auto &preset : printers.m_presets) {
|
for (auto &preset : printers.m_presets) {
|
||||||
if (printer_variant.empty() && !preset.is_system)
|
if (printer_variant.empty() && !preset.is_system)
|
||||||
continue;
|
continue;
|
||||||
if (preset.config.opt_string("printer_model") == printer_model)
|
if (preset.config.opt_string("printer_model") == printer_model)
|
||||||
printer_names.insert(preset.name);
|
printer_presets.insert({preset.name, &preset});
|
||||||
}
|
}
|
||||||
if (printer_names.empty())
|
if (printer_presets.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto prefer_printer = printers.get_selected_preset().name;
|
auto prefer_printer = printers.get_selected_preset().name;
|
||||||
if (!printer_variant.empty())
|
if (!printer_variant.empty())
|
||||||
boost::replace_all(prefer_printer, printer_variant_old, printer_variant);
|
boost::replace_all(prefer_printer, printer_variant_old, printer_variant);
|
||||||
else if (auto n = prefer_printer.find(printer_variant_old); n != std::string::npos)
|
else if (auto n = prefer_printer.find(printer_variant_old); n != std::string::npos)
|
||||||
prefer_printer = printer_model + " " + printer_variant_old + prefer_printer.substr(n + printer_variant_old.length());
|
prefer_printer = printer_model + " " + printer_variant_old + prefer_printer.substr(n + printer_variant_old.length());
|
||||||
if (printer_names.count(prefer_printer) == 0)
|
if (auto iter = printer_presets.find(prefer_printer); iter != printer_presets.end()) {
|
||||||
prefer_printer = *printer_names.begin();
|
return iter->second;
|
||||||
return printers.find_preset(prefer_printer, false, true);
|
}
|
||||||
|
if (printer_variant.empty())
|
||||||
|
printer_variant = printer_variant_old;
|
||||||
|
for (auto& preset : printer_presets) {
|
||||||
|
if (preset.second->config.opt_string("printer_variant") == printer_variant)
|
||||||
|
return preset.second;
|
||||||
|
}
|
||||||
|
return printer_presets.begin()->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
//BBS: check whether this is the only edited filament
|
//BBS: check whether this is the only edited filament
|
||||||
|
|
Loading…
Reference in New Issue