diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-07 10:34:25 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-07 10:34:25 +0100 |
| commit | be00f12bdb5d74677ae55c7919fae9339e882090 (patch) | |
| tree | 87e9336ab474f3305623a4b1936607bf5cb2cdcf /src | |
| parent | b82eb916dd469ee7c86ebea7a0bf4892d4a1258e (diff) | |
Re-add option to save DKDMs to a file.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/dcpomatic.cc | 32 | ||||
| -rw-r--r-- | src/wx/self_dkdm_dialog.cc | 48 | ||||
| -rw-r--r-- | src/wx/self_dkdm_dialog.h | 12 |
3 files changed, 80 insertions, 12 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 799124ee8..6b1d4d260 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -92,6 +92,7 @@ using std::list; using std::exception; using boost::shared_ptr; using boost::dynamic_pointer_cast; +using boost::optional; class FilmChangedDialog : public boost::noncopyable { @@ -563,20 +564,16 @@ private: return; } + optional<dcp::EncryptedKDM> kdm; try { - vector<dcp::EncryptedKDM> dkdms = Config::instance()->dkdms (); - dkdms.push_back ( - _film->make_kdm ( - Config::instance()->decryption_chain()->leaf(), - vector<dcp::Certificate> (), - d->cpl (), - dcp::LocalTime ("2012-01-01T01:00:00+00:00"), - dcp::LocalTime ("2112-01-01T01:00:00+00:00"), - dcp::MODIFIED_TRANSITIONAL_1 - ) + kdm = _film->make_kdm ( + Config::instance()->decryption_chain()->leaf(), + vector<dcp::Certificate> (), + d->cpl (), + dcp::LocalTime ("2012-01-01T01:00:00+00:00"), + dcp::LocalTime ("2112-01-01T01:00:00+00:00"), + dcp::MODIFIED_TRANSITIONAL_1 ); - - Config::instance()->set_dkdms (dkdms); } catch (dcp::NotEncryptedError& e) { error_dialog (this, _("CPL's content is not encrypted.")); } catch (exception& e) { @@ -585,6 +582,17 @@ private: error_dialog (this, _("An unknown exception occurred.")); } + if (kdm) { + if (d->internal ()) { + vector<dcp::EncryptedKDM> dkdms = Config::instance()->dkdms (); + dkdms.push_back (kdm.get()); + Config::instance()->set_dkdms (dkdms); + } else { + boost::filesystem::path path = d->directory() / (_film->dcp_name(false) + "_DKDM.xml"); + kdm->as_xml (path); + } + } + d->Destroy (); } diff --git a/src/wx/self_dkdm_dialog.cc b/src/wx/self_dkdm_dialog.cc index a94b56e18..99f414267 100644 --- a/src/wx/self_dkdm_dialog.cc +++ b/src/wx/self_dkdm_dialog.cc @@ -25,6 +25,11 @@ #include "lib/film.h" #include "lib/screen.h" #include <libcxml/cxml.h> +#ifdef DCPOMATIC_USE_OWN_PICKER +#include "dir_picker_ctrl.h" +#else +#include <wx/filepicker.h> +#endif #include <wx/treectrl.h> #include <wx/listctrl.h> #include <wx/stdpaths.h> @@ -38,6 +43,7 @@ using std::cout; using std::vector; using std::make_pair; using boost::shared_ptr; +using boost::bind; SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film) : wxDialog (parent, wxID_ANY, _("Make DKDM for DCP-o-matic")) @@ -56,6 +62,31 @@ SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, boost::shared_ptr<const Film> _cpl = new KDMCPLPanel (this, film->cpls ()); vertical->Add (_cpl); + /* Sub-heading: output */ + h = new wxStaticText (this, wxID_ANY, _("Output")); + h->SetFont (subheading_font); + vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2); + + _internal = new wxRadioButton (this, wxID_ANY, _("Save to KDM creator tool's list")); + vertical->Add (_internal, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP); + + wxBoxSizer* w = new wxBoxSizer (wxHORIZONTAL); + + _write_to = new wxRadioButton (this, wxID_ANY, _("Write to")); + w->Add (_write_to, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP); + +#ifdef DCPOMATIC_USE_OWN_PICKER + _folder = new DirPickerCtrl (this); +#else + _folder = new wxDirPickerCtrl (this, wxID_ANY, wxEmptyString, wxDirSelectorPromptStr, wxDefaultPosition, wxSize (300, -1)); +#endif + + _folder->SetPath (wxStandardPaths::Get().GetDocumentsDir()); + + w->Add (_folder, 1, wxEXPAND); + + vertical->Add (w, 0, wxBOTTOM, DCPOMATIC_SIZER_Y_GAP); + /* Make an overall sizer to get a nice border, and put some buttons in */ wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); @@ -71,11 +102,16 @@ SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, boost::shared_ptr<const Film> SetSizer (overall_sizer); overall_sizer->Layout (); overall_sizer->SetSizeHints (this); + + _internal->Bind (wxEVT_COMMAND_RADIOBUTTON_SELECTED, bind (&SelfDKDMDialog::setup_sensitivity, this)); + _write_to->Bind (wxEVT_COMMAND_RADIOBUTTON_SELECTED, bind (&SelfDKDMDialog::setup_sensitivity, this)); } void SelfDKDMDialog::setup_sensitivity () { + _folder->Enable (_write_to->GetValue ()); + wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this)); if (ok) { ok->Enable (_cpl->has_selected ()); @@ -87,3 +123,15 @@ SelfDKDMDialog::cpl () const { return _cpl->cpl (); } + +bool +SelfDKDMDialog::internal () const +{ + return _internal->GetValue (); +} + +boost::filesystem::path +SelfDKDMDialog::directory () const +{ + return wx_to_std (_folder->GetPath ()); +} diff --git a/src/wx/self_dkdm_dialog.h b/src/wx/self_dkdm_dialog.h index 5f26c8dce..ca25a775d 100644 --- a/src/wx/self_dkdm_dialog.h +++ b/src/wx/self_dkdm_dialog.h @@ -27,6 +27,8 @@ class Film; class KDMCPLPanel; +class wxDirPickerCtrl; +class DirPickerCtrl; class SelfDKDMDialog : public wxDialog { @@ -35,8 +37,18 @@ public: boost::filesystem::path cpl () const; + bool internal () const; + boost::filesystem::path directory () const; + private: void setup_sensitivity (); KDMCPLPanel* _cpl; + wxRadioButton* _internal; + wxRadioButton* _write_to; +#ifdef DCPOMATIC_USE_OWN_PICKER + DirPickerCtrl* _folder; +#else + wxDirPickerCtrl* _folder; +#endif }; |
