2 Copyright (C) 2014-2022 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
22 #include "barco_alchemy_certificate_panel.h"
23 #include "christie_certificate_panel.h"
24 #include "dcpomatic_button.h"
25 #include "dolby_doremi_certificate_panel.h"
26 #include "download_certificate_dialog.h"
27 #include "gdc_certificate_panel.h"
28 #include "qube_certificate_panel.h"
29 #include "static_text.h"
34 using boost::optional;
37 DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent)
38 : wxDialog (parent, wxID_ANY, _("Download certificate"))
40 auto sizer = new wxBoxSizer (wxVERTICAL);
42 _notebook = new wxNotebook (this, wxID_ANY);
43 sizer->Add (_notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
45 _download = new Button (this, _("Download"));
46 sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP);
48 _message = new StaticText (this, wxT (""));
49 sizer->Add (_message, 0, wxALL, DCPOMATIC_SIZER_GAP);
50 auto font = _message->GetFont();
51 font.SetStyle (wxFONTSTYLE_ITALIC);
52 font.SetPointSize (font.GetPointSize() - 1);
53 _message->SetFont (font);
55 _pages.push_back (new DolbyDoremiCertificatePanel (this));
56 _pages.push_back (new BarcoAlchemyCertificatePanel (this));
57 _pages.push_back (new ChristieCertificatePanel (this));
58 _pages.push_back (new GDCCertificatePanel (this));
59 _pages.push_back (new QubeCertificatePanel (this, N_("QXI")));
60 _pages.push_back (new QubeCertificatePanel (this, N_("QXPD")));
62 for (auto i: _pages) {
63 _notebook->AddPage (i, i->name(), true);
66 auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
68 sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
71 SetSizerAndFit (sizer);
73 _notebook->Bind (wxEVT_NOTEBOOK_PAGE_CHANGED, &DownloadCertificateDialog::page_changed, this);
74 _download->Bind (wxEVT_BUTTON, boost::bind (&DownloadCertificateDialog::download, this));
75 _download->Enable (false);
77 _notebook->SetSelection (0);
79 SetMinSize (wxSize(640, -1));
85 DownloadCertificateDialog::~DownloadCertificateDialog ()
87 _notebook->Unbind (wxEVT_NOTEBOOK_PAGE_CHANGED, &DownloadCertificateDialog::page_changed, this);
92 DownloadCertificateDialog::download ()
94 _pages[_notebook->GetSelection()]->download ();
99 DownloadCertificateDialog::certificate () const
101 auto c = _pages[_notebook->GetSelection()]->certificate ();
102 DCPOMATIC_ASSERT (c);
108 DownloadCertificateDialog::url () const
110 auto u = _pages[_notebook->GetSelection()]->url();
111 DCPOMATIC_ASSERT (u);
117 DownloadCertificateDialog::setup_sensitivity ()
119 auto p = _pages[_notebook->GetSelection()];
120 _download->Enable (p->ready_to_download ());
121 auto ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
123 ok->Enable (static_cast<bool>(p->certificate ()));
129 DownloadCertificateDialog::page_changed (wxNotebookEvent& ev)
131 setup_sensitivity ();