PhysicalPrinterDialog improvements : Printer device default name is changed to force the user to change it

SavePresetDialog : Fixed OSX bug, when wxEVT_TEXT wasn't invoked after change selection in ComboBox
This commit is contained in:
YuSanka 2020-08-06 10:40:04 +02:00
parent 5eb3b21be7
commit 1079d4644c
2 changed files with 14 additions and 3 deletions

View File

@ -161,13 +161,15 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxString printer_name)
SetFont(wxGetApp().normal_font()); SetFont(wxGetApp().normal_font());
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
m_default_name = _L("My Printer Device"); m_default_name = _L("Type here the name of your printer device");
bool new_printer = true;
if (printer_name.IsEmpty()) if (printer_name.IsEmpty())
printer_name = m_default_name; printer_name = m_default_name;
else { else {
std::string full_name = into_u8(printer_name); std::string full_name = into_u8(printer_name);
printer_name = from_u8(PhysicalPrinter::get_short_name(full_name)); printer_name = from_u8(PhysicalPrinter::get_short_name(full_name));
new_printer = false;
} }
wxStaticText* label_top = new wxStaticText(this, wxID_ANY, _L("Descriptive name for the printer device") + ":"); wxStaticText* label_top = new wxStaticText(this, wxID_ANY, _L("Descriptive name for the printer device") + ":");
@ -206,7 +208,6 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxString printer_name)
m_optgroup = new ConfigOptionsGroup(this, _L("Print Host upload"), m_config); m_optgroup = new ConfigOptionsGroup(this, _L("Print Host upload"), m_config);
build_printhost_settings(m_optgroup); build_printhost_settings(m_optgroup);
//m_optgroup->reload_config();
wxStdDialogButtonSizer* btns = this->CreateStdDialogButtonSizer(wxOK | wxCANCEL); wxStdDialogButtonSizer* btns = this->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
wxButton* btnOK = static_cast<wxButton*>(this->FindWindowById(wxID_OK, this)); wxButton* btnOK = static_cast<wxButton*>(this->FindWindowById(wxID_OK, this));
@ -230,6 +231,11 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxString printer_name)
SetSizer(topSizer); SetSizer(topSizer);
topSizer->SetSizeHints(this); topSizer->SetSizeHints(this);
if (new_printer) {
m_printer_name->SetFocus();
m_printer_name->SelectAll();
}
} }
PhysicalPrinterDialog::~PhysicalPrinterDialog() PhysicalPrinterDialog::~PhysicalPrinterDialog()
@ -494,7 +500,7 @@ void PhysicalPrinterDialog::OnOK(wxEvent& event)
std::string renamed_from; std::string renamed_from;
// temporary save previous printer name if it was edited // temporary save previous printer name if it was edited
if (m_printer.name != _u8L("My Printer Device") && if (m_printer.name != into_u8(m_default_name) &&
m_printer.name != into_u8(printer_name)) m_printer.name != into_u8(printer_name))
renamed_from = m_printer.name; renamed_from = m_printer.name;

View File

@ -1054,6 +1054,11 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string& suffix, wxBox
m_combo->Append(from_u8(value)); m_combo->Append(from_u8(value));
m_combo->Bind(wxEVT_TEXT, [this](wxCommandEvent&) { update(); }); m_combo->Bind(wxEVT_TEXT, [this](wxCommandEvent&) { update(); });
#ifdef __WXOSX__
// Under OSX wxEVT_TEXT wasn't invoked after change selection in combobox,
// So process wxEVT_COMBOBOX too
m_combo->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent&) { update(); });
#endif //__WXOSX__
m_valid_label = new wxStaticText(m_parent, wxID_ANY, ""); m_valid_label = new wxStaticText(m_parent, wxID_ANY, "");
m_valid_label->SetFont(wxGetApp().bold_font()); m_valid_label->SetFont(wxGetApp().bold_font());