Move UTC offset for KDMs from the cinema to the point of KDM creation (#2300).
[dcpomatic.git] / src / wx / cinema_dialog.cc
1 /*
2     Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "cinema_dialog.h"
23 #include "wx_util.h"
24 #include "lib/dcpomatic_assert.h"
25 #include "lib/util.h"
26
27
28 using std::back_inserter;
29 using std::copy;
30 using std::cout;
31 using std::string;
32 using std::vector;
33 using boost::bind;
34 #if BOOST_VERSION >= 106100
35 using namespace boost::placeholders;
36 #endif
37
38
39 CinemaDialog::CinemaDialog(wxWindow* parent, wxString title, string name, vector<string> emails, string notes)
40         : wxDialog (parent, wxID_ANY, title)
41 {
42         auto overall_sizer = new wxBoxSizer (wxVERTICAL);
43         SetSizer (overall_sizer);
44
45         auto sizer = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
46         int r = 0;
47
48         add_label_to_sizer (sizer, this, _("Name"), true, wxGBPosition(r, 0));
49         _name = new wxTextCtrl (this, wxID_ANY, std_to_wx(name), wxDefaultPosition, wxSize(500, -1));
50         sizer->Add (_name, wxGBPosition(r, 1));
51         ++r;
52
53         add_label_to_sizer (sizer, this, _("Notes"), true, wxGBPosition(r, 0));
54         _notes = new wxTextCtrl (this, wxID_ANY, std_to_wx(notes), wxDefaultPosition, wxSize(500, -1));
55         sizer->Add (_notes, wxGBPosition(r, 1));
56         ++r;
57
58         add_label_to_sizer (sizer, this, _("Email addresses for KDM delivery"), false, wxGBPosition(r, 0), wxGBSpan(1, 2));
59         ++r;
60
61         copy (emails.begin(), emails.end(), back_inserter (_emails));
62
63         vector<EditableListColumn> columns;
64         columns.push_back (EditableListColumn(_("Address"), 500, true));
65         _email_list = new EditableList<string, EmailDialog> (
66                 this, columns, bind(&CinemaDialog::emails, this), bind (&CinemaDialog::set_emails, this, _1), [](string s, int) {
67                         return s;
68                 }, EditableListTitle::INVISIBLE, EditableListButton::NEW | EditableListButton::EDIT | EditableListButton::REMOVE
69                 );
70
71         sizer->Add (_email_list, wxGBPosition(r, 0), wxGBSpan(1, 2), wxEXPAND);
72         ++r;
73
74         overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
75
76         auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
77         if (buttons) {
78                 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
79         }
80
81         overall_sizer->Layout ();
82         overall_sizer->SetSizeHints (this);
83
84         _name->SetFocus ();
85 }
86
87
88 string
89 CinemaDialog::name () const
90 {
91         return wx_to_std (_name->GetValue());
92 }
93
94
95 void
96 CinemaDialog::set_emails (vector<string> e)
97 {
98         _emails = e;
99 }
100
101
102 vector<string>
103 CinemaDialog::emails() const
104 {
105         return _emails;
106 }
107
108
109 string
110 CinemaDialog::notes () const
111 {
112         return wx_to_std (_notes->GetValue());
113 }