diff options
author | bubnikv <bubnikv@gmail.com> | 2017-12-20 15:32:02 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2017-12-20 15:32:02 +0300 |
commit | 7142126609fbd01102a5d9ccb45e475cb721fb66 (patch) | |
tree | f3be605e1024366c6a5a5b60133d246c8dae7b0e /xs | |
parent | c8d14fb6178f4feea906f1509e9988fceceb0e26 (diff) |
Grey out the compatible_printers_condition edit field in case
the compatible_printers list is non empty.
Changed the precendence of compatible_printers_condition over
compatible_printers. Now compatible_printers has precedence.
Diffstat (limited to 'xs')
-rw-r--r-- | xs/src/slic3r/GUI/Preset.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 6af5982a3..2720654bf 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -144,8 +144,10 @@ std::string Preset::label() const bool Preset::is_compatible_with_printer(const Preset &active_printer, const DynamicPrintConfig *extra_config) const { - auto *condition = dynamic_cast<const ConfigOptionString*>(this->config.option("compatible_printers_condition")); - if (condition != nullptr && ! condition->value.empty()) { + auto *condition = dynamic_cast<const ConfigOptionString*>(this->config.option("compatible_printers_condition")); + auto *compatible_printers = dynamic_cast<const ConfigOptionStrings*>(this->config.option("compatible_printers")); + bool has_compatible_printers = compatible_printers != nullptr && ! compatible_printers->values.empty(); + if (! has_compatible_printers && condition != nullptr && ! condition->value.empty()) { try { return PlaceholderParser::evaluate_boolean_expression(condition->value, active_printer.config, extra_config); } catch (const std::runtime_error &err) { @@ -154,9 +156,7 @@ bool Preset::is_compatible_with_printer(const Preset &active_printer, const Dyna return true; } } - auto *compatible_printers = dynamic_cast<const ConfigOptionStrings*>(this->config.option("compatible_printers")); - return this->is_default || active_printer.name.empty() || - compatible_printers == nullptr || compatible_printers->values.empty() || + return this->is_default || active_printer.name.empty() || ! has_compatible_printers || std::find(compatible_printers->values.begin(), compatible_printers->values.end(), active_printer.name) != compatible_printers->values.end(); } |