Support buttons.
[dcpomatic.git] / src / wx / kdm_dialog.cc
index 5679cf0cb14c2822338d4a78d62e03574b8e9984..55364f5974e04bbf8231d3426edb8b6ee843e688 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -25,6 +25,8 @@
 #include "kdm_output_panel.h"
 #include "kdm_cpl_panel.h"
 #include "confirm_kdm_email_dialog.h"
+#include "static_text.h"
+#include "dcpomatic_button.h"
 #include "lib/film.h"
 #include "lib/screen.h"
 #include "lib/screen_kdm.h"
@@ -47,6 +49,7 @@ using std::pair;
 using std::cout;
 using std::vector;
 using std::make_pair;
+using std::runtime_error;
 using boost::shared_ptr;
 using boost::bind;
 
@@ -67,7 +70,7 @@ KDMDialog::KDMDialog (wxWindow* parent, shared_ptr<const Film> film)
        subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
 
        /* Sub-heading: Screens */
-       wxStaticText* h = new wxStaticText (this, wxID_ANY, _("Screens"));
+       wxStaticText* h = new StaticText (this, _("Screens"));
        h->SetFont (subheading_font);
        left->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, DCPOMATIC_SIZER_Y_GAP);
        _screens = new ScreensPanel (this);
@@ -75,27 +78,27 @@ KDMDialog::KDMDialog (wxWindow* parent, shared_ptr<const Film> film)
 
        /* Sub-heading: Timing */
        /// TRANSLATORS: translate the word "Timing" here; do not include the "KDM|" prefix
-       h = new wxStaticText (this, wxID_ANY, S_("KDM|Timing"));
+       h = new StaticText (this, S_("KDM|Timing"));
        h->SetFont (subheading_font);
        right->Add (h, 0, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP * 2);
        _timing = new KDMTimingPanel (this);
        right->Add (_timing);
 
        /* Sub-heading: CPL */
-       h = new wxStaticText (this, wxID_ANY, _("CPL"));
+       h = new StaticText (this, _("CPL"));
        h->SetFont (subheading_font);
        right->Add (h, 0, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP * 2);
        _cpl = new KDMCPLPanel (this, film->cpls ());
        right->Add (_cpl, 0, wxEXPAND);
 
        /* Sub-heading: Output */
-       h = new wxStaticText (this, wxID_ANY, _("Output"));
+       h = new StaticText (this, _("Output"));
        h->SetFont (subheading_font);
        right->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
        _output = new KDMOutputPanel (this, film->interop ());
        right->Add (_output, 0, wxEXPAND | wxTOP, DCPOMATIC_SIZER_GAP);
 
-       _make = new wxButton (this, wxID_ANY, _("Make KDMs"));
+       _make = new Button (this, _("Make KDMs"));
        right->Add (_make, 0, wxTOP | wxBOTTOM, DCPOMATIC_SIZER_GAP);
 
        /* Make an overall sizer to get a nice border */
@@ -139,11 +142,20 @@ KDMDialog::make_clicked ()
        shared_ptr<const Film> film = _film.lock ();
        DCPOMATIC_ASSERT (film);
 
-       list<ScreenKDM> screen_kdms = film->make_kdms (
-               _screens->screens(), _cpl->cpl(), _timing->from(), _timing->until(), _output->formulation()
-               );
+       list<ScreenKDM> screen_kdms;
+       try {
+
+               screen_kdms = film->make_kdms (
+                       _screens->screens(), _cpl->cpl(), _timing->from(), _timing->until(), _output->formulation(),
+                       !_output->forensic_mark_video(), _output->forensic_mark_audio() ? boost::optional<int>() : 0
+                       );
+
+       } catch (runtime_error& e) {
+               error_dialog (this, std_to_wx(e.what()));
+               return;
+       }
 
-       pair<shared_ptr<Job>, int> result = _output->make (screen_kdms, film->name(), _timing, bind (&KDMDialog::confirm_overwrite, this, _1), film->log());
+       pair<shared_ptr<Job>, int> result = _output->make (screen_kdms, film->name(), _timing, bind (&KDMDialog::confirm_overwrite, this, _1));
        if (result.first) {
                JobManager::instance()->add (result.first);
        }