No-op: remove all trailing whitespace.
[dcpomatic.git] / src / wx / report_problem_dialog.cc
1 /*
2     Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 #include "report_problem_dialog.h"
21 #include "wx_util.h"
22 #include "lib/config.h"
23 #include "lib/job_manager.h"
24 #include "lib/send_problem_report_job.h"
25 #include <wx/sizer.h>
26
27 using std::string;
28 using boost::shared_ptr;
29
30 ReportProblemDialog::ReportProblemDialog (wxWindow* parent, shared_ptr<Film> film)
31         : wxDialog (parent, wxID_ANY, _("Report A Problem"))
32         , _film (film)
33 {
34         _overall_sizer = new wxBoxSizer (wxVERTICAL);
35         SetSizer (_overall_sizer);
36
37         _table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
38         _table->AddGrowableCol (1, 1);
39
40         _overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
41
42         wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
43         if (buttons) {
44                 _overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
45         }
46
47         wxString t = _("My problem is");
48         int flags = wxALIGN_TOP | wxLEFT | wxRIGHT;
49 #ifdef __WXOSX__
50         flags |= wxALIGN_RIGHT;
51         t += wxT (":");
52 #endif
53         wxStaticText* m = new wxStaticText (this, wxID_ANY, t);
54         _table->Add (m, 1, flags, 6);
55
56         _summary = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (320, 240), wxTE_MULTILINE);
57         _table->Add (_summary, 1, wxEXPAND | wxALIGN_TOP);
58
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);
63
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);
68
69         _overall_sizer->Layout ();
70         _overall_sizer->SetSizeHints (this);
71 }
72
73 void
74 ReportProblemDialog::report ()
75 {
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."));
78                 return;
79         }
80
81         JobManager::instance()->add (shared_ptr<Job> (new SendProblemReportJob (_film, wx_to_std (_email->GetValue ()), wx_to_std (_summary->GetValue ()))));
82 }