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:17:52 +0000 (00:17 +0100)
src/lib/config.cc
src/lib/config.h
src/wx/kdm_output_panel.cc
src/wx/kdm_output_panel.h

index bc03377b618b10903d293ca0af1b9d423b61c796..2859d548f24bc7a803b3ef5ebd34221b1f0ead32 100644 (file)
@@ -186,6 +186,8 @@ Config::set_defaults ()
        _add_files_path = boost::none;
        _auto_crop_threshold = 0.1;
        _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);
@@ -575,6 +577,8 @@ try
        _add_files_path = f.optional_string_child("AddFilesPath");
        _auto_crop_threshold = f.optional_number_child<double>("AutoCropThreshold").get_value_or(0.1);
        _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");
@@ -1008,6 +1012,8 @@ Config::write_config () const
        }
        root->add_child("AutoCropThreshold")->add_child_text(raw_convert<string>(_auto_crop_threshold));
        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 0f565fe500e7ae1ddf2abf61d82b1b7f6ea6b2dc..cb4ed1365a6d2c2fdaf4a28b09d81b3684939d6e 100644 (file)
@@ -564,6 +564,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) {
@@ -1080,6 +1088,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
@@ -1298,6 +1314,8 @@ private:
        boost::optional<boost::filesystem::path> _add_files_path;
        double _auto_crop_threshold;
        bool _use_isdcf_name_by_default;
+       bool _write_kdms_to_disk;
+       bool _email_kdms;
 
        static int const _current_version;
 
index 33b9cb4f07c0dcd3a0c9a812d7905c8de1c45b24..7b739720f326c67461174f711353d1276b4d55b0 100644 (file)
@@ -154,10 +154,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));
@@ -167,6 +168,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;