Fix KDM target buttons for DKDMs too (#1137).
authorCarl Hetherington <cth@carlh.net>
Mon, 5 Feb 2018 00:21:42 +0000 (00:21 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 5 Feb 2018 00:21:42 +0000 (00:21 +0000)
src/lib/config.cc
src/lib/config.h
src/wx/self_dkdm_dialog.cc
src/wx/self_dkdm_dialog.h

index 6ae850bfff209f6f1d5a04a47ddb79bda357a0b7..a54858cdb53662113c4e2fb510c2872077b8da0a 100644 (file)
@@ -132,6 +132,7 @@ Config::set_defaults ()
        _sound = true;
        _sound_output = optional<string> ();
        _last_kdm_write_type = KDM_WRITE_FLAT;
+       _last_dkdm_write_type = DKDM_WRITE_INTERNAL;
 
        /* 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
@@ -383,6 +384,13 @@ try
                        _last_kdm_write_type = KDM_WRITE_ZIP;
                }
        }
+       if (f.optional_string_child("LastDKDMWriteType")) {
+               if (f.optional_string_child("LastDKDMWriteType").get() == "internal") {
+                       _last_dkdm_write_type = DKDM_WRITE_INTERNAL;
+               } else if (f.optional_string_child("LastDKDMWriteType").get() == "file") {
+                       _last_dkdm_write_type = DKDM_WRITE_FILE;
+               }
+       }
        _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 */
@@ -691,6 +699,16 @@ Config::write_config () const
                        break;
                }
        }
+       if (_last_dkdm_write_type) {
+               switch (_last_dkdm_write_type.get()) {
+               case DKDM_WRITE_INTERNAL:
+                       root->add_child("LastDKDMWriteType")->add_child_text("internal");
+                       break;
+               case DKDM_WRITE_FILE:
+                       root->add_child("LastDKDMWriteType")->add_child_text("file");
+                       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 f32b171064134e0749e25e044c7b2bddcc5ac5a5..db32c58a0fdfb94da163b1a29667a96083fcf789 100644 (file)
@@ -363,6 +363,15 @@ public:
                return _last_kdm_write_type;
        }
 
+       enum DKDMWriteType {
+               DKDM_WRITE_INTERNAL,
+               DKDM_WRITE_FILE
+       };
+
+       boost::optional<DKDMWriteType> last_dkdm_write_type () const {
+               return _last_dkdm_write_type;
+       }
+
        int frames_in_memory_multiplier () const {
                return _frames_in_memory_multiplier;
        }
@@ -609,6 +618,10 @@ public:
                maybe_set (_last_kdm_write_type, t);
        }
 
+       void set_last_dkdm_write_type (DKDMWriteType t) {
+               maybe_set (_last_dkdm_write_type, t);
+       }
+
        void unset_sound_output () {
                if (!_sound_output) {
                        return;
@@ -817,6 +830,7 @@ private:
        std::string _cover_sheet;
        boost::optional<boost::filesystem::path> _last_player_load_directory;
        boost::optional<KDMWriteType> _last_kdm_write_type;
+       boost::optional<DKDMWriteType> _last_dkdm_write_type;
        int _frames_in_memory_multiplier;
 
        /** Singleton instance, or 0 */
index cd55a8dea96aed7120fda9e7f3e0ca21aa745258..f53338517447192b9c53a9456c782f4855f44daf 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -24,6 +24,7 @@
 #include "kdm_cpl_panel.h"
 #include "lib/film.h"
 #include "lib/screen.h"
+#include "lib/config.h"
 #include <libcxml/cxml.h>
 #ifdef DCPOMATIC_USE_OWN_PICKER
 #include "dir_picker_ctrl.h"
@@ -97,14 +98,34 @@ SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, boost::shared_ptr<const Film>
                overall_sizer->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
        }
 
-       setup_sensitivity ();
-
        SetSizer (overall_sizer);
        overall_sizer->Layout ();
        overall_sizer->SetSizeHints (this);
 
-       _internal->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::setup_sensitivity, this));
-       _write_to->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::setup_sensitivity, this));
+       switch (Config::instance()->last_dkdm_write_type().get_value_or(Config::DKDM_WRITE_INTERNAL)) {
+       case Config::DKDM_WRITE_INTERNAL:
+               _internal->SetValue (true);
+               break;
+       case Config::DKDM_WRITE_FILE:
+               _write_to->SetValue (true);
+               break;
+       }
+       setup_sensitivity ();
+
+       _internal->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::dkdm_write_type_changed, this));
+       _write_to->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::dkdm_write_type_changed, this));
+}
+
+void
+SelfDKDMDialog::dkdm_write_type_changed ()
+{
+       setup_sensitivity ();
+
+       if (_internal->GetValue ()) {
+               Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_INTERNAL);
+       } else if (_write_to->GetValue ()) {
+               Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_FILE);
+       }
 }
 
 void
index ca25a775de7e89f515ccdec46319c8e811bfdcab..509280b5cc482e1d6e3efa62cdbcd09f3c03f30e 100644 (file)
@@ -42,6 +42,7 @@ public:
 
 private:
        void setup_sensitivity ();
+       void dkdm_write_type_changed ();
 
        KDMCPLPanel* _cpl;
        wxRadioButton* _internal;