ConfigWizard: Clarify select-all buttons

This commit is contained in:
Vojtech Kral 2019-02-11 16:15:34 +01:00
parent 339c1b64f8
commit b6d155b442
2 changed files with 17 additions and 15 deletions

View File

@ -174,10 +174,13 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
if (titles.size() > 1) { if (titles.size() > 1) {
// It only makes sense to add the All / None buttons if there's multiple printers // It only makes sense to add the All / None buttons if there's multiple printers
auto *sel_all_std = new wxButton(this, wxID_ANY, _(L("All standard")));
auto *sel_all = new wxButton(this, wxID_ANY, _(L("All"))); auto *sel_all = new wxButton(this, wxID_ANY, _(L("All")));
auto *sel_none = new wxButton(this, wxID_ANY, _(L("None"))); auto *sel_none = new wxButton(this, wxID_ANY, _(L("None")));
sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(true); }); sel_all_std->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(true, false); });
sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(true, true); });
sel_none->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(false); }); sel_none->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(false); });
title_sizer->Add(sel_all_std, 0, wxRIGHT, BTN_SPACING);
title_sizer->Add(sel_all, 0, wxRIGHT, BTN_SPACING); title_sizer->Add(sel_all, 0, wxRIGHT, BTN_SPACING);
title_sizer->Add(sel_none); title_sizer->Add(sel_none);
} }
@ -192,7 +195,7 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
: PrinterPicker(parent, vendor, std::move(title), max_cols, appconfig_vendors, [](const VendorProfile::PrinterModel&) { return true; }) : PrinterPicker(parent, vendor, std::move(title), max_cols, appconfig_vendors, [](const VendorProfile::PrinterModel&) { return true; })
{} {}
void PrinterPicker::select_all(bool select) void PrinterPicker::select_all(bool select, bool alternates)
{ {
for (const auto &cb : cboxes) { for (const auto &cb : cboxes) {
if (cb->GetValue() != select) { if (cb->GetValue() != select) {
@ -201,13 +204,12 @@ void PrinterPicker::select_all(bool select)
} }
} }
// Alt nozzles are de-selected if this is an all-deselect, left intact otherwise if (! select) { alternates = false; }
if (! select) {
for (const auto &cb : cboxes_alt) { for (const auto &cb : cboxes_alt) {
if (cb->GetValue()) { if (cb->GetValue() != alternates) {
cb->SetValue(false); cb->SetValue(alternates);
on_checkbox(cb, false); on_checkbox(cb, alternates);
}
} }
} }
} }
@ -334,10 +336,10 @@ PagePrinters::PagePrinters(ConfigWizard *parent, wxString title, wxString shortn
} }
} }
void PagePrinters::select_all(bool select) void PagePrinters::select_all(bool select, bool alternates)
{ {
for (auto picker : printer_pickers) { for (auto picker : printer_pickers) {
picker->select_all(select); picker->select_all(select, alternates);
} }
} }
@ -989,7 +991,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
topsizer->AddSpacer(INDEX_MARGIN); topsizer->AddSpacer(INDEX_MARGIN);
topsizer->Add(p->hscroll, 1, wxEXPAND); topsizer->Add(p->hscroll, 1, wxEXPAND);
auto *btn_sel_all = new wxButton(this, wxID_ANY, _(L("Select all printers"))); auto *btn_sel_all = new wxButton(this, wxID_ANY, _(L("Select all standard printers")));
p->btnsizer->Add(btn_sel_all); p->btnsizer->Add(btn_sel_all);
p->btn_prev = new wxButton(this, wxID_ANY, _(L("< &Back"))); p->btn_prev = new wxButton(this, wxID_ANY, _(L("< &Back")));
@ -1060,7 +1062,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
p->btn_finish->Hide(); p->btn_finish->Hide();
btn_sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &) { btn_sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &) {
p->page_fff->select_all(true); p->page_fff->select_all(true, false);
p->index->go_to(p->page_update); p->index->go_to(p->page_update);
}); });

View File

@ -65,7 +65,7 @@ struct PrinterPicker: wxPanel
PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxString title, size_t max_cols, const AppConfig &appconfig_vendors, const ModelFilter &filter); PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxString title, size_t max_cols, const AppConfig &appconfig_vendors, const ModelFilter &filter);
PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxString title, size_t max_cols, const AppConfig &appconfig_vendors); PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxString title, size_t max_cols, const AppConfig &appconfig_vendors);
void select_all(bool select); void select_all(bool select, bool alternates = false);
void select_one(size_t i, bool select); void select_one(size_t i, bool select);
void on_checkbox(const Checkbox *cbox, bool checked); void on_checkbox(const Checkbox *cbox, bool checked);
@ -113,7 +113,7 @@ struct PagePrinters: ConfigWizardPage
PagePrinters(ConfigWizard *parent, wxString title, wxString shortname, const VendorProfile &vendor, unsigned indent); PagePrinters(ConfigWizard *parent, wxString title, wxString shortname, const VendorProfile &vendor, unsigned indent);
void select_all(bool select); void select_all(bool select, bool alternates = false);
int get_width() const; int get_width() const;
}; };