Tab: Update print host address and cafile properly, fix #1687

This commit is contained in:
Vojtech Kral 2019-01-29 15:57:22 +01:00
parent a99c823401
commit f7529dbef5
2 changed files with 7 additions and 4 deletions

View File

@ -128,6 +128,8 @@ public:
virtual wxString get_tooltip_text(const wxString& default_string); virtual wxString get_tooltip_text(const wxString& default_string);
void field_changed() { on_change_field(); }
// set icon to "UndoToSystemValue" button according to an inheritance of preset // set icon to "UndoToSystemValue" button according to an inheritance of preset
// void set_nonsys_btn_icon(const wxBitmap& icon); // void set_nonsys_btn_icon(const wxBitmap& icon);

View File

@ -1587,11 +1587,11 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(btn); sizer->Add(btn);
btn->Bind(wxEVT_BUTTON, [this, parent, optgroup](wxCommandEvent e) { btn->Bind(wxEVT_BUTTON, [this, parent, optgroup](wxCommandEvent &e) {
BonjourDialog dialog(parent); BonjourDialog dialog(parent);
if (dialog.show_and_lookup()) { if (dialog.show_and_lookup()) {
optgroup->set_value("print_host", std::move(dialog.get_selected()), true); optgroup->set_value("print_host", std::move(dialog.get_selected()), true);
// FIXME: emit killfocus on the edit widget optgroup->get_field("print_host")->field_changed();
} }
}); });
@ -1605,7 +1605,7 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(btn); sizer->Add(btn);
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent e) { btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config)); std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
if (! host) { if (! host) {
const auto text = wxString::Format("%s", const auto text = wxString::Format("%s",
@ -1646,6 +1646,7 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
wxFileDialog openFileDialog(this, _(L("Open CA certificate file")), "", "", filemasks, wxFD_OPEN | wxFD_FILE_MUST_EXIST); wxFileDialog openFileDialog(this, _(L("Open CA certificate file")), "", "", filemasks, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (openFileDialog.ShowModal() != wxID_CANCEL) { if (openFileDialog.ShowModal() != wxID_CANCEL) {
optgroup->set_value("printhost_cafile", std::move(openFileDialog.GetPath()), true); optgroup->set_value("printhost_cafile", std::move(openFileDialog.GetPath()), true);
optgroup->get_field("printhost_cafile")->field_changed();
} }
}); });