Fix of #5503 - Physical printer disappears from Slicer upon close of application
This commit is contained in:
parent
48481c10b4
commit
55c62887cc
@ -1393,9 +1393,8 @@ const std::vector<std::string>& PhysicalPrinter::printer_options()
|
|||||||
static std::vector<std::string> s_opts;
|
static std::vector<std::string> s_opts;
|
||||||
if (s_opts.empty()) {
|
if (s_opts.empty()) {
|
||||||
s_opts = {
|
s_opts = {
|
||||||
"preset_name",
|
"preset_names",
|
||||||
"printer_technology",
|
"printer_technology",
|
||||||
// "printer_model",
|
|
||||||
"host_type",
|
"host_type",
|
||||||
"print_host",
|
"print_host",
|
||||||
"printhost_apikey",
|
"printhost_apikey",
|
||||||
@ -1453,11 +1452,10 @@ bool PhysicalPrinter::has_empty_config() const
|
|||||||
void PhysicalPrinter::update_preset_names_in_config()
|
void PhysicalPrinter::update_preset_names_in_config()
|
||||||
{
|
{
|
||||||
if (!preset_names.empty()) {
|
if (!preset_names.empty()) {
|
||||||
std::string name;
|
std::vector<std::string>& values = config.option<ConfigOptionStrings>("preset_names")->values;
|
||||||
for (auto el : preset_names)
|
values.clear();
|
||||||
name += el + ";";
|
for (auto preset : preset_names)
|
||||||
name.pop_back();
|
values.push_back(preset);
|
||||||
config.set_key_value("preset_name", new ConfigOptionString(name));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1482,14 +1480,13 @@ void PhysicalPrinter::update_from_config(const DynamicPrintConfig& new_config)
|
|||||||
{
|
{
|
||||||
config.apply_only(new_config, printer_options(), false);
|
config.apply_only(new_config, printer_options(), false);
|
||||||
|
|
||||||
std::string str = config.opt_string("preset_name");
|
const std::vector<std::string>& values = config.option<ConfigOptionStrings>("preset_names")->values;
|
||||||
std::set<std::string> values{};
|
|
||||||
if (!str.empty()) {
|
if (values.empty())
|
||||||
boost::split(values, str, boost::is_any_of(";"));
|
preset_names.clear();
|
||||||
|
else
|
||||||
for (const std::string& val : values)
|
for (const std::string& val : values)
|
||||||
preset_names.emplace(val);
|
preset_names.emplace(val);
|
||||||
}
|
|
||||||
preset_names = values;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicalPrinter::reset_presets()
|
void PhysicalPrinter::reset_presets()
|
||||||
@ -1817,7 +1814,7 @@ bool PhysicalPrinterCollection::delete_preset_from_printers( const std::string&
|
|||||||
return true;
|
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<std::string> PhysicalPrinterCollection::get_printers_with_preset(const std::string& preset_name)
|
std::vector<std::string> PhysicalPrinterCollection::get_printers_with_preset(const std::string& preset_name)
|
||||||
{
|
{
|
||||||
std::vector<std::string> printers;
|
std::vector<std::string> printers;
|
||||||
@ -1832,7 +1829,7 @@ std::vector<std::string> PhysicalPrinterCollection::get_printers_with_preset(con
|
|||||||
return printers;
|
return printers;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get list of printers which has only "preset_name" preset
|
// Get list of printers which has only "preset_names" preset
|
||||||
std::vector<std::string> PhysicalPrinterCollection::get_printers_with_only_preset(const std::string& preset_name)
|
std::vector<std::string> PhysicalPrinterCollection::get_printers_with_only_preset(const std::string& preset_name)
|
||||||
{
|
{
|
||||||
std::vector<std::string> printers;
|
std::vector<std::string> printers;
|
||||||
|
@ -685,9 +685,9 @@ public:
|
|||||||
// returns true if all presets were deleted successfully.
|
// returns true if all presets were deleted successfully.
|
||||||
bool delete_preset_from_printers(const std::string& preset_name);
|
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<std::string> get_printers_with_preset( const std::string &preset_name);
|
std::vector<std::string> 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<std::string> get_printers_with_only_preset( const std::string &preset_name);
|
std::vector<std::string> get_printers_with_only_preset( const std::string &preset_name);
|
||||||
|
|
||||||
// Return the selected preset, without the user modifications applied.
|
// Return the selected preset, without the user modifications applied.
|
||||||
|
@ -151,11 +151,11 @@ void PrintConfigDef::init_common_params()
|
|||||||
def->mode = comAdvanced;
|
def->mode = comAdvanced;
|
||||||
def->set_default_value(new ConfigOptionString(""));
|
def->set_default_value(new ConfigOptionString(""));
|
||||||
|
|
||||||
def = this->add("preset_name", coString);
|
def = this->add("preset_names", coStrings);
|
||||||
def->label = L("Printer preset name");
|
def->label = L("Printer preset names");
|
||||||
def->tooltip = L("Related printer preset name");
|
def->tooltip = L("Names of presets related to the physical printer");
|
||||||
def->mode = comAdvanced;
|
def->mode = comAdvanced;
|
||||||
def->set_default_value(new ConfigOptionString(""));
|
def->set_default_value(new ConfigOptionStrings());
|
||||||
|
|
||||||
def = this->add("printhost_authorization_type", coEnum);
|
def = this->add("printhost_authorization_type", coEnum);
|
||||||
def->label = L("Authorization Type");
|
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";
|
opt_key = "printhost_cafile";
|
||||||
} else if (opt_key == "octoprint_apikey") {
|
} else if (opt_key == "octoprint_apikey") {
|
||||||
opt_key = "printhost_apikey";
|
opt_key = "printhost_apikey";
|
||||||
|
} else if (opt_key == "preset_name") {
|
||||||
|
opt_key = "preset_names";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore the following obsolete configuration keys:
|
// Ignore the following obsolete configuration keys:
|
||||||
|
Loading…
Reference in New Issue
Block a user