diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 6c500b84a..98ccf280f 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -1393,9 +1393,8 @@ const std::vector& PhysicalPrinter::printer_options() static std::vector s_opts; if (s_opts.empty()) { s_opts = { - "preset_name", + "preset_names", "printer_technology", -// "printer_model", "host_type", "print_host", "printhost_apikey", @@ -1453,11 +1452,10 @@ bool PhysicalPrinter::has_empty_config() const void PhysicalPrinter::update_preset_names_in_config() { if (!preset_names.empty()) { - std::string name; - for (auto el : preset_names) - name += el + ";"; - name.pop_back(); - config.set_key_value("preset_name", new ConfigOptionString(name)); + std::vector& values = config.option("preset_names")->values; + values.clear(); + for (auto preset : preset_names) + values.push_back(preset); } } @@ -1482,14 +1480,13 @@ void PhysicalPrinter::update_from_config(const DynamicPrintConfig& new_config) { config.apply_only(new_config, printer_options(), false); - std::string str = config.opt_string("preset_name"); - std::set values{}; - if (!str.empty()) { - boost::split(values, str, boost::is_any_of(";")); + const std::vector& values = config.option("preset_names")->values; + + if (values.empty()) + preset_names.clear(); + else for (const std::string& val : values) preset_names.emplace(val); - } - preset_names = values; } void PhysicalPrinter::reset_presets() @@ -1817,7 +1814,7 @@ bool PhysicalPrinterCollection::delete_preset_from_printers( const std::string& return true; } -// Get list of printers which have more than one preset and "preset_name" preset is one of them +// Get list of printers which have more than one preset and "preset_names" preset is one of them std::vector PhysicalPrinterCollection::get_printers_with_preset(const std::string& preset_name) { std::vector printers; @@ -1832,7 +1829,7 @@ std::vector PhysicalPrinterCollection::get_printers_with_preset(con return printers; } -// Get list of printers which has only "preset_name" preset +// Get list of printers which has only "preset_names" preset std::vector PhysicalPrinterCollection::get_printers_with_only_preset(const std::string& preset_name) { std::vector printers; diff --git a/src/libslic3r/Preset.hpp b/src/libslic3r/Preset.hpp index d81717f0e..6e56ad911 100644 --- a/src/libslic3r/Preset.hpp +++ b/src/libslic3r/Preset.hpp @@ -685,9 +685,9 @@ public: // returns true if all presets were deleted successfully. bool delete_preset_from_printers(const std::string& preset_name); - // Get list of printers which have more than one preset and "preset_name" preset is one of them + // Get list of printers which have more than one preset and "preset_names" preset is one of them std::vector get_printers_with_preset( const std::string &preset_name); - // Get list of printers which has only "preset_name" preset + // Get list of printers which has only "preset_names" preset std::vector get_printers_with_only_preset( const std::string &preset_name); // Return the selected preset, without the user modifications applied. diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 480ce4590..810b651c4 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -151,11 +151,11 @@ void PrintConfigDef::init_common_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionString("")); - def = this->add("preset_name", coString); - def->label = L("Printer preset name"); - def->tooltip = L("Related printer preset name"); + def = this->add("preset_names", coStrings); + def->label = L("Printer preset names"); + def->tooltip = L("Names of presets related to the physical printer"); def->mode = comAdvanced; - def->set_default_value(new ConfigOptionString("")); + def->set_default_value(new ConfigOptionStrings()); def = this->add("printhost_authorization_type", coEnum); def->label = L("Authorization Type"); @@ -3366,6 +3366,8 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va opt_key = "printhost_cafile"; } else if (opt_key == "octoprint_apikey") { opt_key = "printhost_apikey"; + } else if (opt_key == "preset_name") { + opt_key = "preset_names"; } // Ignore the following obsolete configuration keys: