2 Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "report_problem_dialog.h"
22 #include "lib/config.h"
23 #include "lib/job_manager.h"
24 #include "lib/send_problem_report_job.h"
28 using boost::shared_ptr;
30 ReportProblemDialog::ReportProblemDialog (wxWindow* parent, shared_ptr<Film> film)
31 : wxDialog (parent, wxID_ANY, _("Report A Problem"))
34 _overall_sizer = new wxBoxSizer (wxVERTICAL);
35 SetSizer (_overall_sizer);
37 _table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
38 _table->AddGrowableCol (1, 1);
40 _overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
42 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
44 _overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
47 wxString t = _("My problem is");
48 int flags = wxALIGN_TOP | wxLEFT | wxRIGHT;
50 flags |= wxALIGN_RIGHT;
53 wxStaticText* m = new wxStaticText (this, wxID_ANY, t);
54 _table->Add (m, 1, flags, 6);
56 _summary = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (320, 240), wxTE_MULTILINE);
57 _table->Add (_summary, 1, wxEXPAND | wxALIGN_TOP);
59 _send_logs = new wxCheckBox (this, wxID_ANY, _("Send logs"));
60 _send_logs->SetValue (true);
61 _table->Add (_send_logs, 1, wxEXPAND);
62 _table->AddSpacer (0);
64 add_label_to_sizer (_table, this, _("Contact email"), true);
65 _email = new wxTextCtrl (this, wxID_ANY, wxT (""));
66 _email->SetValue (std_to_wx (Config::instance()->kdm_from ()));
67 _table->Add (_email, 1, wxEXPAND);
69 _overall_sizer->Layout ();
70 _overall_sizer->SetSizeHints (this);
74 ReportProblemDialog::report ()
76 if (_email->GetValue().IsEmpty ()) {
77 error_dialog (this, _("Please enter an email address so that we can contact you with any queries about the problem."));
81 JobManager::instance()->add (shared_ptr<Job> (new SendProblemReportJob (_film, wx_to_std (_email->GetValue ()), wx_to_std (_summary->GetValue ()))));