Re-add option to save DKDMs to a file.
authorCarl Hetherington <cth@carlh.net>
Tue, 7 Jun 2016 09:34:25 +0000 (10:34 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 7 Jun 2016 09:34:25 +0000 (10:34 +0100)
ChangeLog
src/tools/dcpomatic.cc
src/wx/self_dkdm_dialog.cc
src/wx/self_dkdm_dialog.h

index f85a28317ad63469943edd0c6403238366a00a15..570f26606205addc03f1e6a4630a4a8fde647e0e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-06-07  c.hetherington  <cth@carlh.net>
+
+       * Re-add option to save DKDMs to a file.
+
 2016-06-06  Carl Hetherington  <cth@carlh.net>
 
        * Updated nl_NL translation from Rob van Nieuwkerk.
index 799124ee8f816042f420714787bf874e4e49aed3..6b1d4d260dc3b044252ed5423502d3ca98541f2c 100644 (file)
@@ -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 ();
        }
 
index a94b56e185ce1a0a80f77f6b64b8b69ec12521ba..99f4142678888875626167b929e85e31908f4218 100644 (file)
 #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 ());
+}
index 5f26c8dce21fe419b947e26829882e89f079650d..ca25a775de7e89f515ccdec46319c8e811bfdcab 100644 (file)
@@ -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
 };