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.
This commit is contained in:
parent
c8d14fb617
commit
7142126609
2 changed files with 8 additions and 5 deletions
|
@ -495,6 +495,7 @@ sub _compatible_printers_widget {
|
||||||
$btn->$method;
|
$btn->$method;
|
||||||
# All printers have been made compatible with this preset.
|
# All printers have been made compatible with this preset.
|
||||||
$self->_load_key_value('compatible_printers', []) if $checkbox->GetValue;
|
$self->_load_key_value('compatible_printers', []) if $checkbox->GetValue;
|
||||||
|
$self->get_field('compatible_printers_condition')->toggle($checkbox->GetValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
EVT_BUTTON($self, $btn, sub {
|
EVT_BUTTON($self, $btn, sub {
|
||||||
|
@ -516,6 +517,7 @@ sub _compatible_printers_widget {
|
||||||
my $value = [ @presets[$dlg->GetSelections] ];
|
my $value = [ @presets[$dlg->GetSelections] ];
|
||||||
if (!@$value) {
|
if (!@$value) {
|
||||||
$checkbox->SetValue(1);
|
$checkbox->SetValue(1);
|
||||||
|
$self->get_field('compatible_printers_condition')->toggle(1);
|
||||||
$btn->Disable;
|
$btn->Disable;
|
||||||
}
|
}
|
||||||
# All printers have been made compatible with this preset.
|
# All printers have been made compatible with this preset.
|
||||||
|
@ -533,6 +535,7 @@ sub _reload_compatible_printers_widget {
|
||||||
my $method = $has_any ? 'Enable' : 'Disable';
|
my $method = $has_any ? 'Enable' : 'Disable';
|
||||||
$self->{compatible_printers_checkbox}->SetValue(! $has_any);
|
$self->{compatible_printers_checkbox}->SetValue(! $has_any);
|
||||||
$self->{compatible_printers_btn}->$method;
|
$self->{compatible_printers_btn}->$method;
|
||||||
|
$self->get_field('compatible_printers_condition')->toggle(! $has_any);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub update_ui_from_settings {
|
sub update_ui_from_settings {
|
||||||
|
|
|
@ -145,7 +145,9 @@ std::string Preset::label() const
|
||||||
bool Preset::is_compatible_with_printer(const Preset &active_printer, const DynamicPrintConfig *extra_config) 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"));
|
auto *condition = dynamic_cast<const ConfigOptionString*>(this->config.option("compatible_printers_condition"));
|
||||||
if (condition != nullptr && ! condition->value.empty()) {
|
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 {
|
try {
|
||||||
return PlaceholderParser::evaluate_boolean_expression(condition->value, active_printer.config, extra_config);
|
return PlaceholderParser::evaluate_boolean_expression(condition->value, active_printer.config, extra_config);
|
||||||
} catch (const std::runtime_error &err) {
|
} catch (const std::runtime_error &err) {
|
||||||
|
@ -154,9 +156,7 @@ bool Preset::is_compatible_with_printer(const Preset &active_printer, const Dyna
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto *compatible_printers = dynamic_cast<const ConfigOptionStrings*>(this->config.option("compatible_printers"));
|
return this->is_default || active_printer.name.empty() || ! has_compatible_printers ||
|
||||||
return this->is_default || active_printer.name.empty() ||
|
|
||||||
compatible_printers == nullptr || compatible_printers->values.empty() ||
|
|
||||||
std::find(compatible_printers->values.begin(), compatible_printers->values.end(), active_printer.name) !=
|
std::find(compatible_printers->values.begin(), compatible_printers->values.end(), active_printer.name) !=
|
||||||
compatible_printers->values.end();
|
compatible_printers->values.end();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue