Add config option for default KDM type.
authorCarl Hetherington <cth@carlh.net>
Sat, 19 Mar 2022 21:34:00 +0000 (22:34 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 19 Mar 2022 21:34:23 +0000 (22:34 +0100)
cscript
src/lib/config.cc
src/lib/config.h
src/wx/full_config_dialog.cc
src/wx/kdm_choice.cc
src/wx/kdm_choice.h
src/wx/kdm_output_panel.cc

diff --git a/cscript b/cscript
index 06bf0eb51c69fe187169939aae63c224b14d9f37..25208d1a2825c88d878b14a6a6c6af543e685faa 100644 (file)
--- a/cscript
+++ b/cscript
@@ -402,8 +402,8 @@ def dependencies(target, options):
         # Use distro-provided FFmpeg on Arch
         deps = []
 
-    deps.append(('libdcp', 'v1.8.10'))
-    deps.append(('libsub', 'v1.6.10'))
+    deps.append(('libdcp', 'v1.8.11'))
+    deps.append(('libsub', 'v1.6.11'))
     deps.append(('leqm-nrt', '93ae9e6'))
     deps.append(('rtaudio', 'f619b76'))
     # We get our OpenSSL libraries from the environment, but we
index b6615403849e709f2b083755bf1a9421460bc59b..6e654d5bed95a66b044b668174ebc91b5718cb53 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2022 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -182,6 +182,7 @@ Config::set_defaults ()
        _use_isdcf_name_by_default = true;
        _write_kdms_to_disk = true;
        _email_kdms = false;
+       _default_kdm_type = dcp::Formulation::MODIFIED_TRANSITIONAL_1;
 
        _allowed_dcp_frame_rates.clear ();
        _allowed_dcp_frame_rates.push_back (24);
@@ -571,6 +572,7 @@ try
        _use_isdcf_name_by_default = f.optional_bool_child("UseISDCFNameByDefault").get_value_or(true);
        _write_kdms_to_disk = f.optional_bool_child("WriteKDMsToDisk").get_value_or(true);
        _email_kdms = f.optional_bool_child("EmailKDMs").get_value_or(false);
+       _default_kdm_type = dcp::string_to_formulation(f.optional_string_child("DefaultKDMType").get_value_or("modified-transitional-1"));
 
        if (boost::filesystem::exists (_cinemas_file)) {
                cxml::Document f ("Cinemas");
@@ -1003,6 +1005,7 @@ Config::write_config () const
        root->add_child("UseISDCFNameByDefault")->add_child_text(_use_isdcf_name_by_default ? "1" : "0");
        root->add_child("WriteKDMsToDisk")->add_child_text(_write_kdms_to_disk ? "1" : "0");
        root->add_child("EmailKDMs")->add_child_text(_email_kdms ? "1" : "0");
+       root->add_child("DefaultKDMType")->add_child_text(dcp::formulation_to_string(_default_kdm_type));
 
        auto target = config_write_file();
 
index ec152b969dbee98530628f1a274c0b48725764b5..2ad201c35e76d0849a39f8a38b5e102bdb767a81 100644 (file)
@@ -563,6 +563,11 @@ public:
                return _email_kdms;
        }
 
+       dcp::Formulation default_kdm_type () const {
+               return _default_kdm_type;
+       }
+
+
        /* SET (mostly) */
 
        void set_master_encoding_threads (int n) {
@@ -1079,6 +1084,10 @@ public:
                maybe_set (_email_kdms, email);
        }
 
+       void set_default_kdm_type (dcp::Formulation type) {
+               maybe_set (_default_kdm_type, type);
+       }
+
        void changed (Property p = OTHER);
        boost::signals2::signal<void (Property)> Changed;
        /** Emitted if read() failed on an existing Config file.  There is nothing
@@ -1297,6 +1306,7 @@ private:
        bool _use_isdcf_name_by_default;
        bool _write_kdms_to_disk;
        bool _email_kdms;
+       dcp::Formulation _default_kdm_type;
 
        static int const _current_version;
 
index 3fef8ef8bbf183db008d271e470a5aad6119767c..127ca412973ba10800248d7cf9ad4b60d96afc26 100644 (file)
@@ -34,6 +34,7 @@
 #include "file_picker_ctrl.h"
 #include "filter_dialog.h"
 #include "full_config_dialog.h"
+#include "kdm_choice.h"
 #include "make_chain_dialog.h"
 #include "nag_dialog.h"
 #include "name_format_editor.h"
@@ -331,9 +332,12 @@ private:
 #else
                _kdm_directory = new wxDirPickerCtrl (_panel, wxDD_DIR_MUST_EXIST);
 #endif
-
                table->Add (_kdm_directory, 1, wxEXPAND);
 
+               add_label_to_sizer (table, _panel, _("Default KDM type"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
+               _kdm_type = new KDMChoice (_panel);
+               table->Add (_kdm_type, 1, wxEXPAND);
+
                table->Add (_use_isdcf_name_by_default = new CheckBox(_panel, _("Use ISDCF name by default")), 0, wxALIGN_CENTRE_VERTICAL);
 
                _still_length->SetRange (1, 3600);
@@ -341,6 +345,7 @@ private:
 
                _directory->Bind (wxEVT_DIRPICKER_CHANGED, boost::bind (&DefaultsPage::directory_changed, this));
                _kdm_directory->Bind (wxEVT_DIRPICKER_CHANGED, boost::bind (&DefaultsPage::kdm_directory_changed, this));
+               _kdm_type->Bind (wxEVT_CHOICE, boost::bind(&DefaultsPage::kdm_type_changed, this));
 
                _use_isdcf_name_by_default->Bind (wxEVT_CHECKBOX, boost::bind(&DefaultsPage::use_isdcf_name_by_default_changed, this));
 
@@ -399,6 +404,7 @@ private:
                checked_set (_still_length, config->default_still_length ());
                _directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()));
                _kdm_directory->SetPath (std_to_wx (config->default_kdm_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()));
+               _kdm_type->set (config->default_kdm_type());
                checked_set (_use_isdcf_name_by_default, config->use_isdcf_name_by_default());
                checked_set (_j2k_bandwidth, config->default_j2k_bandwidth() / 1000000);
                _j2k_bandwidth->SetRange (50, config->maximum_j2k_bandwidth() / 1000000);
@@ -458,6 +464,11 @@ private:
                Config::instance()->set_default_kdm_directory (wx_to_std (_kdm_directory->GetPath ()));
        }
 
+       void kdm_type_changed ()
+       {
+               Config::instance()->set_default_kdm_type(_kdm_type->get());
+       }
+
        void use_isdcf_name_by_default_changed ()
        {
                Config::instance()->set_use_isdcf_name_by_default (_use_isdcf_name_by_default->GetValue());
@@ -514,6 +525,7 @@ private:
        wxDirPickerCtrl* _directory;
        wxDirPickerCtrl* _kdm_directory;
 #endif
+       KDMChoice* _kdm_type;
        wxCheckBox* _use_isdcf_name_by_default;
        wxChoice* _container;
        wxChoice* _dcp_content_type;
index 64a43f76562d6e558c3f00612504c008dba3bffd..c8685e22c741d54844dd668d73322658b8673f23 100644 (file)
@@ -32,9 +32,31 @@ KDMChoice::KDMChoice (wxWindow* parent)
 }
 
 
+dcp::Formulation
+KDMChoice::get_formulation (unsigned int n) const
+{
+       return static_cast<dcp::Formulation>(reinterpret_cast<intptr_t>(GetClientData(n)));
+}
+
+
 dcp::Formulation
 KDMChoice::get () const
 {
-       return static_cast<dcp::Formulation>(reinterpret_cast<intptr_t>(GetClientData(GetSelection())));
+       return get_formulation(GetSelection());
+}
+
+
+void
+KDMChoice::set (dcp::Formulation type)
+{
+       for (unsigned int i = 0; i < GetCount(); ++i) {
+               if (get_formulation(i) == type) {
+                       SetSelection(i);
+                       return;
+               }
+       }
 }
 
+
+
+
index 3f2bcdfe019f0302f08f6d3eabd5b00b31d829bc..109c552f087d3fc0468508cb9e663681aac06425 100644 (file)
@@ -29,5 +29,9 @@ public:
        KDMChoice (wxWindow* parent);
 
        dcp::Formulation get () const;
+       void set (dcp::Formulation type);
+
+private:
+       dcp::Formulation get_formulation (unsigned int n) const;
 };
 
index ec2182c36a1e2f2fd79ae3d44e3adae75dcbbba6..bc66e37b95e098467061aa48a6d551712f2965ce 100644 (file)
@@ -72,7 +72,7 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
        auto type = new wxBoxSizer (wxHORIZONTAL);
        _type = new KDMChoice (this);
        type->Add (_type, 1, wxTOP, DCPOMATIC_CHOICE_TOP_PAD);
-       _type->SetSelection (0);
+       _type->set(Config::instance()->default_kdm_type());
        auto advanced = new Button (this, _("Advanced..."));
        type->Add (advanced, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
        table->Add (type, 1, wxTOP, DCPOMATIC_CHOICE_TOP_PAD);