Set up a default KDM write mode and preselect the last used one when re-opening the...
authorCarl Hetherington <cth@carlh.net>
Thu, 4 Jan 2018 21:26:18 +0000 (21:26 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 4 Jan 2018 21:26:18 +0000 (21:26 +0000)
ChangeLog
src/lib/config.cc
src/lib/config.h
src/wx/kdm_output_panel.cc
src/wx/kdm_output_panel.h

index deaecc7..0dedf2a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-04  Carl Hetherington  <cth@carlh.net>
+
+       * 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  <cth@carlh.net>
 
        * Version 2.11.35 released.
index 4856897..2a8a3cc 100644 (file)
@@ -128,6 +128,7 @@ Config::set_defaults ()
        }
        _sound = false;
        _sound_output = optional<string> ();
+       _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<int>("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.
        */
index afa362a..a57fbd5 100644 (file)
@@ -345,6 +345,16 @@ public:
                return _last_player_load_directory;
        }
 
+       enum KDMWriteType {
+               KDM_WRITE_FLAT,
+               KDM_WRITE_FOLDER,
+               KDM_WRITE_ZIP
+       };
+
+       boost::optional<KDMWriteType> 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<std::string> _sound_output;
        std::string _cover_sheet;
        boost::optional<boost::filesystem::path> _last_player_load_directory;
+       boost::optional<KDMWriteType> _last_kdm_write_type;
        int _frames_in_memory_multiplier;
 
        /** Singleton instance, or 0 */
index 29b697b..0b99ee4 100644 (file)
@@ -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<shared_ptr<Job>, int>
 KDMOutputPanel::make (
        list<ScreenKDM> screen_kdms, string name, KDMTimingPanel* timing, function<bool (boost::filesystem::path)> confirm_overwrite, shared_ptr<Log> log
index cb6f9a1..b2f4282 100644 (file)
@@ -51,6 +51,8 @@ public:
                );
 
 private:
+       void kdm_write_type_changed ();
+
        wxChoice* _type;
        NameFormatEditor* _container_name_format;
        NameFormatEditor* _filename_format;