X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fdownload_certificate_dialog.cc;h=8f4720252f09975d0854b3cd614c682699335335;hb=865316f0129c85cdd0248b87502fe97dec94b3f0;hp=275c943db7687895430f02897026e8aa15aef4ce;hpb=76196d4356ca5d92047e46ce8d617c688ad88c91;p=dcpomatic.git diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index 275c943db..8f4720252 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -1,63 +1,133 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2022 Carl Hetherington - This program is free software; you can redistribute it and/or modify + 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. - This program is distributed in the hope that it will be useful, + 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ -#include "wx_util.h" + +#include "barco_alchemy_certificate_panel.h" +#include "christie_certificate_panel.h" +#include "dcpomatic_button.h" +#include "dolby_doremi_certificate_panel.h" #include "download_certificate_dialog.h" -#include +#include "gdc_certificate_panel.h" +#include "qube_certificate_panel.h" +#include "static_text.h" +#include "wx_util.h" -using boost::function; -DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent, function load) - : TableDialog (parent, _("Download certificate"), 2, 1, true) - , _load (load) - , _message (0) - , _download (0) -{ +using std::string; +using boost::optional; -} -void -DownloadCertificateDialog::add_common_widgets () +DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) + : wxDialog (parent, wxID_ANY, _("Download certificate")) { - add_spacer (); - _download = add (new wxButton (this, wxID_ANY, _("Download"))); + auto sizer = new wxBoxSizer (wxVERTICAL); - add_spacer (); - _message = add (new wxStaticText (this, wxID_ANY, wxT (""))); + _notebook = new wxNotebook (this, wxID_ANY); + sizer->Add (_notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - wxFont font = _message->GetFont(); + _download = new Button (this, _("Download")); + sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP); + + _message = new StaticText (this, wxT ("")); + sizer->Add (_message, 0, wxALL, DCPOMATIC_SIZER_GAP); + auto font = _message->GetFont(); font.SetStyle (wxFONTSTYLE_ITALIC); font.SetPointSize (font.GetPointSize() - 1); _message->SetFont (font); - _download->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DownloadCertificateDialog::download, this)); + _pages.push_back (new DolbyDoremiCertificatePanel (this)); + _pages.push_back (new BarcoAlchemyCertificatePanel (this)); + _pages.push_back (new ChristieCertificatePanel (this)); + _pages.push_back (new GDCCertificatePanel (this)); + _pages.push_back (new QubeCertificatePanel (this, N_("QXI"))); + _pages.push_back (new QubeCertificatePanel (this, N_("QXPD"))); + + for (auto i: _pages) { + _notebook->AddPage (i, i->name(), true); + } + + auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); + if (buttons) { + sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); + } + + SetSizerAndFit (sizer); + + _notebook->Bind (wxEVT_NOTEBOOK_PAGE_CHANGED, &DownloadCertificateDialog::page_changed, this); + _download->Bind (wxEVT_BUTTON, boost::bind (&DownloadCertificateDialog::download, this)); _download->Enable (false); - layout (); + _notebook->SetSelection (0); + + SetMinSize (wxSize(640, -1)); + + setup_sensitivity (); +} + + +DownloadCertificateDialog::~DownloadCertificateDialog () +{ + _notebook->Unbind (wxEVT_NOTEBOOK_PAGE_CHANGED, &DownloadCertificateDialog::page_changed, this); +} + + +void +DownloadCertificateDialog::download () +{ + _pages[_notebook->GetSelection()]->download (); +} + + +dcp::Certificate +DownloadCertificateDialog::certificate () const +{ + auto c = _pages[_notebook->GetSelection()]->certificate (); + DCPOMATIC_ASSERT (c); + return *c; +} + - wxButton* ok = dynamic_cast (FindWindowById (wxID_OK, this)); - ok->Enable (false); +string +DownloadCertificateDialog::url () const +{ + auto u = _pages[_notebook->GetSelection()]->url(); + DCPOMATIC_ASSERT (u); + return *u; } + +void +DownloadCertificateDialog::setup_sensitivity () +{ + auto p = _pages[_notebook->GetSelection()]; + _download->Enable (p->ready_to_download ()); + auto ok = dynamic_cast (FindWindowById (wxID_OK, this)); + if (ok) { + ok->Enable (static_cast(p->certificate ())); + } +} + + void -DownloadCertificateDialog::downloaded (bool done) +DownloadCertificateDialog::page_changed (wxNotebookEvent& ev) { - wxButton* ok = dynamic_cast (FindWindowById (wxID_OK, this)); - ok->Enable (done); + setup_sensitivity (); + ev.Skip (); }