Remember the state of the write to/email checkboxes in the KDM creator across runs...
authorCarl Hetherington <cth@carlh.net>
Sun, 13 Mar 2022 23:09:09 +0000 (00:09 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 13 Mar 2022 23:09:09 +0000 (00:09 +0100)
src/lib/config.cc
src/lib/config.h
src/wx/kdm_output_panel.cc
src/wx/kdm_output_panel.h

index 0de19f70f866d8214529033ebd2e5534e10bf6ac..b6615403849e709f2b083755bf1a9421460bc59b 100644 (file)
@@ -180,6 +180,8 @@ Config::set_defaults ()
        _custom_languages.clear ();
        _add_files_path = boost::none;
        _use_isdcf_name_by_default = true;
+       _write_kdms_to_disk = true;
+       _email_kdms = false;
 
        _allowed_dcp_frame_rates.clear ();
        _allowed_dcp_frame_rates.push_back (24);
@@ -567,6 +569,8 @@ try
 
        _add_files_path = f.optional_string_child("AddFilesPath");
        _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);
 
        if (boost::filesystem::exists (_cinemas_file)) {
                cxml::Document f ("Cinemas");
@@ -997,6 +1001,8 @@ Config::write_config () const
                root->add_child("AddFilesPath")->add_child_text(_add_files_path->string());
        }
        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");
 
        auto target = config_write_file();
 
index 3277dc153965ac14f4aec6263c720d929a6bfe79..ec152b969dbee98530628f1a274c0b48725764b5 100644 (file)
@@ -555,6 +555,14 @@ public:
                return _use_isdcf_name_by_default;
        }
 
+       bool write_kdms_to_disk () const {
+               return _write_kdms_to_disk;
+       }
+
+       bool email_kdms () const {
+               return _email_kdms;
+       }
+
        /* SET (mostly) */
 
        void set_master_encoding_threads (int n) {
@@ -1063,6 +1071,14 @@ public:
                maybe_set (_use_isdcf_name_by_default, use);
        }
 
+       void set_write_kdms_to_disk (bool write) {
+               maybe_set (_write_kdms_to_disk, write);
+       }
+
+       void set_email_kdms (bool email) {
+               maybe_set (_email_kdms, email);
+       }
+
        void changed (Property p = OTHER);
        boost::signals2::signal<void (Property)> Changed;
        /** Emitted if read() failed on an existing Config file.  There is nothing
@@ -1279,6 +1295,8 @@ private:
        std::vector<dcp::LanguageTag> _custom_languages;
        boost::optional<boost::filesystem::path> _add_files_path;
        bool _use_isdcf_name_by_default;
+       bool _write_kdms_to_disk;
+       bool _email_kdms;
 
        static int const _current_version;
 
index 8a2757557e940952eb38a01ec294c6bf9f878f78..11f921aad5c236b70b2e363ad6d6b5d7867bd866 100644 (file)
@@ -153,10 +153,11 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
                break;
        }
 
-       _write_to->SetValue (true);
+       _write_to->SetValue (Config::instance()->write_kdms_to_disk());
+       _email->SetValue (Config::instance()->email_kdms());
 
-       _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::write_to_changed, this));
+       _email->Bind        (wxEVT_CHECKBOX, boost::bind (&KDMOutputPanel::email_changed, 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));
@@ -166,6 +167,22 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
 }
 
 
+void
+KDMOutputPanel::write_to_changed ()
+{
+       Config::instance()->set_write_kdms_to_disk(_write_to->GetValue());
+       setup_sensitivity ();
+}
+
+
+void
+KDMOutputPanel::email_changed ()
+{
+       Config::instance()->set_email_kdms(_email->GetValue());
+       setup_sensitivity ();
+}
+
+
 void
 KDMOutputPanel::setup_sensitivity ()
 {
index e8515d2c6c3e6ef90e831de73ff2746e357db05b..1f7373165c4e459da7dc06c21d4f5d069a3442dd 100644 (file)
@@ -60,6 +60,8 @@ public:
 private:
        void kdm_write_type_changed ();
        void advanced_clicked ();
+       void write_to_changed ();
+       void email_changed ();
 
        wxChoice* _type;
        NameFormatEditor* _container_name_format;