fixes for dependencies tab (#9594)
Some checks are pending
Build all / Build All (push) Waiting to run
Build all / Flatpak (push) Waiting to run

* init

* fix indent
This commit is contained in:
yw4z 2025-05-10 17:13:28 +03:00 committed by GitHub
parent 41ff632d28
commit 75dd55fcf6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 13 deletions

View file

@ -5922,16 +5922,14 @@ void Tab::create_line_with_widget(ConfigOptionsGroup* optgroup, const std::strin
// Return a callback to create a Tab widget to mark the preferences as compatible / incompatible to the current printer. // Return a callback to create a Tab widget to mark the preferences as compatible / incompatible to the current printer.
wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &deps) wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &deps)
{ {
auto cb_text = _L("All");
deps.checkbox = new ::CheckBox(parent, wxID_ANY); deps.checkbox = new ::CheckBox(parent, wxID_ANY);
deps.checkbox->SetLabel(cb_text);
deps.checkbox->SetFont(Label::Body_14);
auto cb_size = wxSize(deps.checkbox->GetTextExtent(cb_text).x + deps.checkbox->GetBitmap().GetWidth() + FromDIP(6), -1);
deps.checkbox->SetSize( cb_size);
deps.checkbox->SetMinSize(cb_size);
deps.checkbox->SetForegroundColour(wxColour("#363636"));
wxGetApp().UpdateDarkUI(deps.checkbox, false, true); wxGetApp().UpdateDarkUI(deps.checkbox, false, true);
deps.checkbox_title = new wxStaticText(parent, wxID_ANY, _L("All"));
deps.checkbox_title->SetFont(Label::Body_14);
deps.checkbox_title->SetForegroundColour(wxColour("#363636"));
wxGetApp().UpdateDarkUI(deps.checkbox_title, false, true);
// ORCA modernize button style // ORCA modernize button style
Button* btn = new Button(parent, _(L("Set")) + " " + dots); Button* btn = new Button(parent, _(L("Set")) + " " + dots);
btn->SetFont(Label::Body_14); btn->SetFont(Label::Body_14);
@ -5955,18 +5953,33 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add((deps.checkbox), 0, wxALIGN_CENTER_VERTICAL); sizer->Add((deps.checkbox), 0, wxALIGN_CENTER_VERTICAL);
sizer->Add((deps.checkbox_title), 0, wxALIGN_CENTER_VERTICAL);
sizer->Add(new wxStaticText(parent, wxID_ANY, " ")); // weirdly didnt apply AddSpacer or wxRIGHT border sizer->Add(new wxStaticText(parent, wxID_ANY, " ")); // weirdly didnt apply AddSpacer or wxRIGHT border
sizer->Add((deps.btn), 0, wxALIGN_CENTER_VERTICAL); sizer->Add((deps.btn), 0, wxALIGN_CENTER_VERTICAL);
deps.checkbox->Bind(wxEVT_TOGGLEBUTTON, ([this, &deps](wxCommandEvent e) auto on_toggle = [this, &deps](const bool &state){
{ deps.checkbox->SetValue(state);
deps.checkbox->SetValue(e.IsChecked()); deps.btn->Enable(!state);
deps.btn->Enable(!e.IsChecked());
// All printers have been made compatible with this preset. // All printers have been made compatible with this preset.
if (e.IsChecked()) if (state)
this->load_key_value(deps.key_list, std::vector<std::string> {}); this->load_key_value(deps.key_list, std::vector<std::string> {});
this->get_field(deps.key_condition)->toggle(e.IsChecked()); this->get_field(deps.key_condition)->toggle(state);
this->update_changed_ui(); this->update_changed_ui();
};
deps.checkbox_title->Bind(wxEVT_LEFT_DOWN,([this, &deps, on_toggle](wxMouseEvent e) {
if (e.GetEventType() == wxEVT_LEFT_DCLICK) return;
on_toggle(!deps.checkbox->GetValue());
e.Skip();
}));
deps.checkbox_title->Bind(wxEVT_LEFT_DCLICK,([this, &deps, on_toggle](wxMouseEvent e) {
on_toggle(!deps.checkbox->GetValue());
e.Skip();
}));
deps.checkbox->Bind(wxEVT_TOGGLEBUTTON, ([this, on_toggle](wxCommandEvent e) {
on_toggle(e.IsChecked());
e.Skip(); e.Skip();
}), deps.checkbox->GetId()); }), deps.checkbox->GetId());

View file

@ -165,6 +165,7 @@ protected:
struct PresetDependencies { struct PresetDependencies {
Preset::Type type = Preset::TYPE_INVALID; Preset::Type type = Preset::TYPE_INVALID;
::CheckBox* checkbox = nullptr; ::CheckBox* checkbox = nullptr;
wxStaticText* checkbox_title = nullptr;
Button *btn = nullptr; Button *btn = nullptr;
std::string key_list; // "compatible_printers" std::string key_list; // "compatible_printers"
std::string key_condition; std::string key_condition;