Add a dialog to show which screens have potentially-problematic
[dcpomatic.git] / src / wx / invalid_certificate_period_dialog.cc
1 /*
2     Copyright (C) 2023 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 "invalid_certificate_period_dialog.h"
23 #include "wx_util.h"
24 #include "lib/kdm_util.h"
25 #include <wx/listctrl.h>
26 #include <wx/scrolwin.h>
27
28
29 InvalidCertificatePeriodDialog::InvalidCertificatePeriodDialog(wxWindow* parent, std::vector<KDMCertificatePeriod> const& periods)
30         : wxDialog(parent, wxID_ANY, _("Invalid certificates"))
31         , _list(new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT))
32 {
33         {
34                 wxListItem ip;
35                 ip.SetId(0);
36                 ip.SetText(_("Cinema"));
37                 ip.SetWidth(200);
38                 _list->InsertColumn(0, ip);
39         }
40
41         {
42                 wxListItem ip;
43                 ip.SetId(1);
44                 ip.SetText(_("Screen"));
45                 ip.SetWidth(50);
46                 _list->InsertColumn(1, ip);
47         }
48
49         {
50                 wxListItem ip;
51                 ip.SetId(2);
52                 ip.SetText(_("Certificate start"));
53                 ip.SetWidth(200);
54                 _list->InsertColumn(2, ip);
55         }
56
57         {
58                 wxListItem ip;
59                 ip.SetId(3);
60                 ip.SetText(_("Certificate end"));
61                 ip.SetWidth(200);
62                 _list->InsertColumn(3, ip);
63         }
64
65         int id = 0;
66         for (auto const& period: periods) {
67                 wxListItem item;
68                 item.SetId(id);
69                 _list->InsertItem(item);
70                 _list->SetItem(0, 0, std_to_wx(period.cinema_name));
71                 _list->SetItem(0, 1, std_to_wx(period.screen_name));
72                 _list->SetItem(0, 2, std_to_wx(period.from.as_string()));
73                 _list->SetItem(0, 3, std_to_wx(period.to.as_string()));
74         }
75
76         auto overall_sizer = new wxBoxSizer(wxVERTICAL);
77
78         auto constexpr width = 700;
79
80         auto question = new wxStaticText(this, wxID_ANY, _("Some KDMs would have validity periods which are outside the recipient certificate validity periods.  What do you want to do?"));
81         question->Wrap(width);
82         overall_sizer->Add(
83                 question,
84                 0,
85                 wxALL,
86                 DCPOMATIC_DIALOG_BORDER
87                 );
88
89         _list->SetSize({width, -1});
90         overall_sizer->Add(_list, 1, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER);
91
92         auto buttons = CreateStdDialogButtonSizer(0);
93         if (buttons) {
94                 overall_sizer->Add(CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder());
95                 buttons->SetAffirmativeButton(new wxButton(this, wxID_OK, _("Create KDMs anyway")));
96                 buttons->SetCancelButton(new wxButton(this, wxID_CANCEL, _("Cancel")));
97                 buttons->Realize();
98         }
99
100         overall_sizer->Layout();
101         SetSizerAndFit(overall_sizer);
102 }
103