From: Carl Hetherington Date: Thu, 4 Jan 2018 21:26:18 +0000 (+0000) Subject: Set up a default KDM write mode and preselect the last used one when re-opening the... X-Git-Tag: v2.11.36~5 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=9ccaee9ed18688b3862b8b7fb7e73b69e71568e3 Set up a default KDM write mode and preselect the last used one when re-opening the KDM window (#1137). --- diff --git a/ChangeLog b/ChangeLog index deaecc7dc..0dedf2aa8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-01-04 Carl Hetherington + + * Set up a default KDM write mode and preselect the last used + one when re-opening the KDM window (#1137). + 2018-01-03 Carl Hetherington * Version 2.11.35 released. diff --git a/src/lib/config.cc b/src/lib/config.cc index 48568975e..2a8a3cc89 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -128,6 +128,7 @@ Config::set_defaults () } _sound = false; _sound_output = optional (); + _last_kdm_write_type = KDM_WRITE_FLAT; /* I think the scaling factor here should be the ratio of the longest frame encode time to the shortest; if the thread count is T, longest time is L @@ -366,6 +367,15 @@ try _cover_sheet = f.optional_string_child("CoverSheet").get(); } _last_player_load_directory = f.optional_string_child("LastPlayerLoadDirectory"); + if (f.optional_string_child("LastKDMWriteType")) { + if (f.optional_string_child("LastKDMWriteType").get() == "flat") { + _last_kdm_write_type = KDM_WRITE_FLAT; + } else if (f.optional_string_child("LastKDMWriteType").get() == "folder") { + _last_kdm_write_type = KDM_WRITE_FOLDER; + } else if (f.optional_string_child("LastKDMWriteType").get() == "zip") { + _last_kdm_write_type = KDM_WRITE_ZIP; + } + } _frames_in_memory_multiplier = f.optional_number_child("FramesInMemoryMultiplier").get_value_or(3); /* Replace any cinemas from config.xml with those from the configured file */ @@ -647,6 +657,19 @@ Config::write_config () const if (_last_player_load_directory) { root->add_child("LastPlayerLoadDirectory")->add_child_text(_last_player_load_directory->string()); } + if (_last_kdm_write_type) { + switch (_last_kdm_write_type.get()) { + case KDM_WRITE_FLAT: + root->add_child("LastKDMWriteType")->add_child_text("flat"); + break; + case KDM_WRITE_FOLDER: + root->add_child("LastKDMWriteType")->add_child_text("folder"); + break; + case KDM_WRITE_ZIP: + root->add_child("LastKDMWriteType")->add_child_text("zip"); + break; + } + } /* [XML] FramesInMemoryMultiplier value to multiply the encoding threads count by to get the maximum number of frames to be held in memory at once. */ diff --git a/src/lib/config.h b/src/lib/config.h index afa362a4c..a57fbd587 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -345,6 +345,16 @@ public: return _last_player_load_directory; } + enum KDMWriteType { + KDM_WRITE_FLAT, + KDM_WRITE_FOLDER, + KDM_WRITE_ZIP + }; + + boost::optional last_kdm_write_type () const { + return _last_kdm_write_type; + } + int frames_in_memory_multiplier () const { return _frames_in_memory_multiplier; } @@ -583,6 +593,10 @@ public: maybe_set (_last_player_load_directory, d); } + void set_last_kdm_write_type (KDMWriteType t) { + maybe_set (_last_kdm_write_type, t); + } + void unset_sound_output () { if (!_sound_output) { return; @@ -779,6 +793,7 @@ private: boost::optional _sound_output; std::string _cover_sheet; boost::optional _last_player_load_directory; + boost::optional _last_kdm_write_type; int _frames_in_memory_multiplier; /** Singleton instance, or 0 */ diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index 29b697b89..0b99ee465 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -132,10 +132,25 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent, bool interop) table->Add (_email, 1, wxEXPAND); table->AddSpacer (0); + switch (Config::instance()->last_kdm_write_type().get_value_or(Config::KDM_WRITE_FLAT)) { + case Config::KDM_WRITE_FLAT: + _write_flat->SetValue (true); + break; + case Config::KDM_WRITE_FOLDER: + _write_folder->SetValue (true); + break; + case Config::KDM_WRITE_ZIP: + _write_zip->SetValue (true); + break; + } + _write_to->SetValue (true); - _write_to->Bind (wxEVT_CHECKBOX, boost::bind (&KDMOutputPanel::setup_sensitivity, this)); - _email->Bind (wxEVT_CHECKBOX, boost::bind (&KDMOutputPanel::setup_sensitivity, this)); + _write_to->Bind (wxEVT_CHECKBOX, boost::bind (&KDMOutputPanel::setup_sensitivity, this)); + _email->Bind (wxEVT_CHECKBOX, boost::bind (&KDMOutputPanel::setup_sensitivity, this)); + _write_flat->Bind (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this)); + _write_folder->Bind (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this)); + _write_zip->Bind (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this)); SetSizer (table); } @@ -150,6 +165,18 @@ KDMOutputPanel::setup_sensitivity () _write_zip->Enable (write); } +void +KDMOutputPanel::kdm_write_type_changed () +{ + if (_write_flat->GetValue()) { + Config::instance()->set_last_kdm_write_type (Config::KDM_WRITE_FLAT); + } else if (_write_folder->GetValue()) { + Config::instance()->set_last_kdm_write_type (Config::KDM_WRITE_FOLDER); + } else if (_write_zip->GetValue()) { + Config::instance()->set_last_kdm_write_type (Config::KDM_WRITE_ZIP); + } +} + pair, int> KDMOutputPanel::make ( list screen_kdms, string name, KDMTimingPanel* timing, function confirm_overwrite, shared_ptr log diff --git a/src/wx/kdm_output_panel.h b/src/wx/kdm_output_panel.h index cb6f9a1ca..b2f428252 100644 --- a/src/wx/kdm_output_panel.h +++ b/src/wx/kdm_output_panel.h @@ -51,6 +51,8 @@ public: ); private: + void kdm_write_type_changed (); + wxChoice* _type; NameFormatEditor* _container_name_format; NameFormatEditor* _filename_format;