summaryrefslogtreecommitdiff
path: root/src/wx/invalid_certificate_period_dialog.cc
blob: c0f277f1cf592f64d931f5b8350bcae704822cb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
    Copyright (C) 2023 Carl Hetherington <cth@carlh.net>

    This file is part of DCP-o-matic.

    DCP-o-matic is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    DCP-o-matic is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.

*/


#include "invalid_certificate_period_dialog.h"
#include "wx_util.h"
#include "lib/kdm_util.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/listctrl.h>
#include <wx/scrolwin.h>
LIBDCP_ENABLE_WARNINGS


InvalidCertificatePeriodDialog::InvalidCertificatePeriodDialog(wxWindow* parent, std::vector<KDMCertificatePeriod> const& periods)
	: wxDialog(parent, wxID_ANY, _("Invalid certificates"))
	, _list(new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT))
{
	{
		wxListItem ip;
		ip.SetId(0);
		ip.SetText(_("Cinema"));
		ip.SetWidth(200);
		_list->InsertColumn(0, ip);
	}

	{
		wxListItem ip;
		ip.SetId(1);
		ip.SetText(_("Screen"));
		ip.SetWidth(50);
		_list->InsertColumn(1, ip);
	}

	{
		wxListItem ip;
		ip.SetId(2);
		ip.SetText(_("Certificate start"));
		ip.SetWidth(200);
		_list->InsertColumn(2, ip);
	}

	{
		wxListItem ip;
		ip.SetId(3);
		ip.SetText(_("Certificate end"));
		ip.SetWidth(200);
		_list->InsertColumn(3, ip);
	}

	int id = 0;
	for (auto const& period: periods) {
		wxListItem item;
		item.SetId(id);
		_list->InsertItem(item);
		_list->SetItem(0, 0, std_to_wx(period.cinema_name));
		_list->SetItem(0, 1, std_to_wx(period.screen_name));
		_list->SetItem(0, 2, std_to_wx(period.from.as_string()));
		_list->SetItem(0, 3, std_to_wx(period.to.as_string()));
	}

	auto overall_sizer = new wxBoxSizer(wxVERTICAL);

	auto constexpr width = 700;

	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?"));
	question->Wrap(width);
	overall_sizer->Add(
		question,
		0,
		wxALL,
		DCPOMATIC_DIALOG_BORDER
		);

	_list->SetSize({width, -1});
	overall_sizer->Add(_list, 1, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER);

	auto buttons = CreateStdDialogButtonSizer(0);
	if (buttons) {
		overall_sizer->Add(CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder());
		buttons->SetAffirmativeButton(new wxButton(this, wxID_OK, _("Create KDMs anyway")));
		buttons->SetCancelButton(new wxButton(this, wxID_CANCEL, _("Cancel")));
		buttons->Realize();
	}

	overall_sizer->Layout();
	SetSizerAndFit(overall_sizer);
}