Add KDM directory configuration in player.
authorCarl Hetherington <cth@carlh.net>
Mon, 24 Sep 2018 23:47:49 +0000 (00:47 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 24 Sep 2018 23:47:49 +0000 (00:47 +0100)
src/lib/config.cc
src/lib/config.h
src/wx/player_config_dialog.cc

index 54716d8497afcc75ec4ee57cb30a3f423ee07c39..5e953382dadb26ed99726fe2f9a844d67a07d9ee 100644 (file)
@@ -168,6 +168,7 @@ Config::set_defaults ()
        _respect_kdm_validity_periods = true;
        _player_log_file = boost::none;
        _player_dcp_directory = boost::none;
+       _player_kdm_directory = boost::none;
 
        _allowed_dcp_frame_rates.clear ();
        _allowed_dcp_frame_rates.push_back (24);
@@ -499,6 +500,7 @@ try
        _respect_kdm_validity_periods = f.optional_bool_child("RespectKDMValidityPeriods").get_value_or(true);
        _player_log_file = f.optional_string_child("PlayerLogFile");
        _player_dcp_directory = f.optional_string_child("PlayerDCPDirectory");
+       _player_kdm_directory = f.optional_string_child("PlayerKDMDirectory");
 
        /* Replace any cinemas from config.xml with those from the configured file */
        if (boost::filesystem::exists (_cinemas_file)) {
@@ -893,6 +895,9 @@ Config::write_config () const
        if (_player_dcp_directory) {
                root->add_child("PlayerDCPDirectory")->add_child_text(_player_dcp_directory->string());
        }
+       if (_player_kdm_directory) {
+               root->add_child("PlayerKDMDirectory")->add_child_text(_player_kdm_directory->string());
+       }
 
        try {
                doc.write_to_file_formatted(config_file().string());
index 814f078f049b0c71ee725a81a079dd7a6ee2f567..60e85c5f362dc1bfa2c0d8983458c758290342ef 100644 (file)
@@ -486,6 +486,10 @@ public:
                return _player_dcp_directory;
        }
 
+       boost::optional<boost::filesystem::path> player_kdm_directory () const {
+               return _player_kdm_directory;
+       }
+
        /* SET (mostly) */
 
        void set_master_encoding_threads (int n) {
@@ -920,6 +924,18 @@ public:
                changed (PLAYER_DCP_DIRECTORY);
        }
 
+       void set_player_kdm_directory (boost::filesystem::path p) {
+               maybe_set (_player_kdm_directory, p);
+       }
+
+       void unset_player_kdm_directory () {
+               if (!_player_kdm_directory) {
+                       return;
+               }
+               _player_kdm_directory = boost::none;
+               changed ();
+       }
+
        void changed (Property p = OTHER);
        boost::signals2::signal<void (Property)> Changed;
        /** Emitted if read() failed on an existing Config file.  There is nothing
@@ -1111,6 +1127,7 @@ private:
            for playback.
        */
        boost::optional<boost::filesystem::path> _player_dcp_directory;
+       boost::optional<boost::filesystem::path> _player_kdm_directory;
 
        static int const _current_version;
 
index dda2b62e5d63c4e6e7f67b15a780f96aed4ffc57..a34f0bd3b4a897a78c544051a5a75391c33653dd 100644 (file)
@@ -115,11 +115,17 @@ private:
                table->Add (_dcp_directory, wxGBPosition (r, 1));
                ++r;
 
+               add_label_to_sizer (table, _panel, _("KDM directory"), true, wxGBPosition (r, 0));
+               _kdm_directory = new wxDirPickerCtrl (_panel, wxID_ANY, wxEmptyString, wxDirSelectorPromptStr, wxDefaultPosition, wxSize (300, -1));
+               table->Add (_kdm_directory, wxGBPosition (r, 1));
+               ++r;
+
                _player_mode->Bind (wxEVT_CHOICE, bind(&PlayerGeneralPage::player_mode_changed, this));
                _image_display->Bind (wxEVT_CHOICE, bind(&PlayerGeneralPage::image_display_changed, this));
                _respect_kdm->Bind (wxEVT_CHECKBOX, bind(&PlayerGeneralPage::respect_kdm_changed, this));
                _log_file->Bind (wxEVT_FILEPICKER_CHANGED, bind(&PlayerGeneralPage::log_file_changed, this));
                _dcp_directory->Bind (wxEVT_DIRPICKER_CHANGED, bind(&PlayerGeneralPage::dcp_directory_changed, this));
+               _kdm_directory->Bind (wxEVT_DIRPICKER_CHANGED, bind(&PlayerGeneralPage::kdm_directory_changed, this));
        }
 
        void config_changed ()
@@ -148,6 +154,9 @@ private:
                if (config->player_dcp_directory()) {
                        checked_set (_dcp_directory, *config->player_dcp_directory());
                }
+               if (config->player_kdm_directory()) {
+                       checked_set (_kdm_directory, *config->player_kdm_directory());
+               }
        }
 
 private:
@@ -186,11 +195,17 @@ private:
                Config::instance()->set_player_dcp_directory(wx_to_std(_dcp_directory->GetPath()));
        }
 
+       void kdm_directory_changed ()
+       {
+               Config::instance()->set_player_kdm_directory(wx_to_std(_kdm_directory->GetPath()));
+       }
+
        wxChoice* _player_mode;
        wxChoice* _image_display;
        wxCheckBox* _respect_kdm;
        FilePickerCtrl* _log_file;
        wxDirPickerCtrl* _dcp_directory;
+       wxDirPickerCtrl* _kdm_directory;
 };
 
 wxPreferencesEditor*