From 7bc591abc86ed4742f21f45ca1d6151cb14bc100 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 19 Mar 2022 22:34:00 +0100 Subject: [PATCH] Add config option for default KDM type. --- cscript | 4 ++-- src/lib/config.cc | 5 ++++- src/lib/config.h | 10 ++++++++++ src/wx/full_config_dialog.cc | 14 +++++++++++++- src/wx/kdm_choice.cc | 24 +++++++++++++++++++++++- src/wx/kdm_choice.h | 4 ++++ src/wx/kdm_output_panel.cc | 2 +- 7 files changed, 57 insertions(+), 6 deletions(-) diff --git a/cscript b/cscript index 06bf0eb51..25208d1a2 100644 --- 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 diff --git a/src/lib/config.cc b/src/lib/config.cc index b66154038..6e654d5be 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2021 Carl Hetherington + Copyright (C) 2012-2022 Carl Hetherington 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(); diff --git a/src/lib/config.h b/src/lib/config.h index ec152b969..2ad201c35 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -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 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; diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 3fef8ef8b..127ca4129 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -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; diff --git a/src/wx/kdm_choice.cc b/src/wx/kdm_choice.cc index 64a43f765..c8685e22c 100644 --- a/src/wx/kdm_choice.cc +++ b/src/wx/kdm_choice.cc @@ -32,9 +32,31 @@ KDMChoice::KDMChoice (wxWindow* parent) } +dcp::Formulation +KDMChoice::get_formulation (unsigned int n) const +{ + return static_cast(reinterpret_cast(GetClientData(n))); +} + + dcp::Formulation KDMChoice::get () const { - return static_cast(reinterpret_cast(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; + } + } } + + + diff --git a/src/wx/kdm_choice.h b/src/wx/kdm_choice.h index 3f2bcdfe0..109c552f0 100644 --- a/src/wx/kdm_choice.h +++ b/src/wx/kdm_choice.h @@ -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; }; diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index ec2182c36..bc66e37b9 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -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); -- 2.30.2