From eb970af6fa9ddc854f13c88d6d8fd3b4a1057b9c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 13 Jun 2025 01:24:50 +0200 Subject: Only enable report-problem "OK" button when an email address has been entered. Previously we would let users get it wrong, then show an error and dump them back without any report message they might have written. --- src/wx/report_problem_dialog.cc | 18 +++++++++++++----- src/wx/report_problem_dialog.h | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/wx/report_problem_dialog.cc b/src/wx/report_problem_dialog.cc index 9079b344d..2a0fb6bbd 100644 --- a/src/wx/report_problem_dialog.cc +++ b/src/wx/report_problem_dialog.cc @@ -105,17 +105,16 @@ ReportProblemDialog::ReportProblemDialog(wxWindow* parent, shared_ptr film _overall_sizer->SetSizeHints(this); _summary->SetFocus(); + + _email->Bind(wxEVT_TEXT, boost::bind(&ReportProblemDialog::setup_sensitivity, this)); + + setup_sensitivity(); } void ReportProblemDialog::report() { - if (_email->GetValue().IsEmpty()) { - error_dialog(this, _("Please enter an email address so that we can contact you with any queries about the problem.")); - return; - } - if (_email->GetValue() == char_to_wx("carl@dcpomatic.com") || _email->GetValue() == char_to_wx("cth@carlh.net")) { error_dialog(this, wxString::Format(_("Enter your email address for the contact, not %s"), _email->GetValue().data())); return; @@ -124,3 +123,12 @@ ReportProblemDialog::report() JobManager::instance()->add(make_shared(_film, wx_to_std(_email->GetValue()), wx_to_std(_summary->GetValue()))); } + +void +ReportProblemDialog::setup_sensitivity() +{ + if (auto ok = dynamic_cast(FindWindowById(wxID_OK, this))) { + ok->Enable(!_email->GetValue().IsEmpty()); + } +} + diff --git a/src/wx/report_problem_dialog.h b/src/wx/report_problem_dialog.h index c43defd41..ad76795a3 100644 --- a/src/wx/report_problem_dialog.h +++ b/src/wx/report_problem_dialog.h @@ -39,6 +39,8 @@ public: void report(); private: + void setup_sensitivity(); + std::shared_ptr _film; wxSizer* _overall_sizer; -- cgit v1.2.3