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, 2 Apr 2022 20:25:53 +0000 (22:25 +0200)
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

index 2859d548f24bc7a803b3ef5ebd34221b1f0ead32..eb581fe42ad84477067a88dbf73badd2af40680d 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.
 
@@ -188,6 +188,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);
@@ -579,6 +580,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");
@@ -1014,6 +1016,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 cb4ed1365a6d2c2fdaf4a28b09d81b3684939d6e..8aaddc1b14cb30b8e4531183a92120fe56b9a69c 100644 (file)
@@ -572,6 +572,11 @@ public:
                return _email_kdms;
        }
 
+       dcp::Formulation default_kdm_type () const {
+               return _default_kdm_type;
+       }
+
+
        /* SET (mostly) */
 
        void set_master_encoding_threads (int n) {
@@ -1096,6 +1101,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
@@ -1316,6 +1325,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 bd09d249a93a37564db83e7629661ff961240f82..bac0d47f62cad68ed563ddf9fe8ae0a3496a4ab5 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 e7d7260a32b3dd3e542c400e4ee00d9bcf25522a..12a7abe9cd4d01673101c02273aaabaa2b599854 100644 (file)
@@ -73,7 +73,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);