Allow configuration of KDM filename format.
[dcpomatic.git] / src / wx / kdm_dialog.cc
index 7bd256d038a6527b25b4740b76186e6bce988308..ee164518aed47070613f53f267cb8c5dd35b0dd5 100644 (file)
@@ -1,19 +1,20 @@
 /*
     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
-    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 <http://www.gnu.org/licenses/>.
 
 */
 
@@ -54,9 +55,14 @@ KDMDialog::KDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
        h->SetFont (subheading_font);
        vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL);
        _screens = new ScreensPanel (this);
+       /* Hack to stop KDM dialogs that are taller than my laptop screen; this
+          really isn't the right way to fix it...
+       */
+       _screens->SetMaxSize (wxSize (-1, 280));
        vertical->Add (_screens, 1, wxEXPAND);
 
        /* 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->SetFont (subheading_font);
        vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
@@ -66,9 +72,9 @@ KDMDialog::KDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
        /* Sub-heading: CPL */
        h = new wxStaticText (this, wxID_ANY, _("CPL"));
        h->SetFont (subheading_font);
-       vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
+       vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP * 2);
        _cpl = new KDMCPLPanel (this, film->cpls ());
-       vertical->Add (_cpl);
+       vertical->Add (_cpl, 0, wxEXPAND);
 
        /* Sub-heading: Output */
        h = new wxStaticText (this, wxID_ANY, _("Output"));
@@ -77,19 +83,21 @@ KDMDialog::KDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
        _output = new KDMOutputPanel (this, film->interop ());
        vertical->Add (_output, 0, wxEXPAND | wxTOP, DCPOMATIC_SIZER_GAP);
 
-       /* Make an overall sizer to get a nice border, and put some buttons in */
-
-       wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
-       overall_sizer->Add (vertical, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
 
        wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
        if (buttons) {
-               overall_sizer->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
+               vertical->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
        }
 
+       /* Make an overall sizer to get a nice border, and put some buttons in */
+
+       wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+       overall_sizer->Add (vertical, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
+
        /* Bind */
 
        _screens->ScreensChanged.connect (boost::bind (&KDMDialog::setup_sensitivity, this));
+       _timing->TimingChanged.connect (boost::bind (&KDMDialog::setup_sensitivity, this));
 
        setup_sensitivity ();
 
@@ -108,7 +116,7 @@ KDMDialog::setup_sensitivity ()
 
        wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
        if (ok) {
-               ok->Enable (!_screens->screens().empty() && sd);
+               ok->Enable (!_screens->screens().empty() && _timing->valid() && sd);
        }
 }
 
@@ -153,3 +161,17 @@ KDMDialog::formulation () const
 {
        return _output->formulation ();
 }
+
+KDMNameFormat
+KDMDialog::name_format () const
+{
+       return _output->name_format ();
+}
+
+int
+KDMDialog::ShowModal ()
+{
+       int const r = wxDialog::ShowModal ();
+       _output->save_kdm_name_format ();
+       return r;
+}