Add empty playlist list and configuration option.
authorCarl Hetherington <cth@carlh.net>
Fri, 26 Oct 2018 00:17:56 +0000 (01:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 26 Oct 2018 00:17:56 +0000 (01:17 +0100)
src/lib/config.cc
src/lib/config.h
src/wx/controls.cc
src/wx/controls.h
src/wx/player_config_dialog.cc

index da3ef22..99115f2 100644 (file)
@@ -168,6 +168,7 @@ Config::set_defaults ()
        _respect_kdm_validity_periods = true;
        _player_log_file = boost::none;
        _player_content_directory = boost::none;
+       _player_playlist_directory = boost::none;
        _player_kdm_directory = boost::none;
 #ifdef DCPOMATIC_VARIANT_SWAROOP
        _player_background_image = boost::none;
@@ -516,6 +517,7 @@ try
        _respect_kdm_validity_periods = f.optional_bool_child("RespectKDMValidityPeriods").get_value_or(true);
        _player_log_file = f.optional_string_child("PlayerLogFile");
        _player_content_directory = f.optional_string_child("PlayerContentDirectory");
+       _player_playlist_directory = f.optional_string_child("PlayerPlaylistDirectory");
        _player_kdm_directory = f.optional_string_child("PlayerKDMDirectory");
 #ifdef DCPOMATIC_VARIANT_SWAROOP
        _player_background_image = f.optional_string_child("PlayerBackgroundImage");
@@ -922,6 +924,9 @@ Config::write_config () const
        if (_player_content_directory) {
                root->add_child("PlayerContentDirectory")->add_child_text(_player_content_directory->string());
        }
+       if (_player_playlist_directory) {
+               root->add_child("PlayerPlaylistDirectory")->add_child_text(_player_playlist_directory->string());
+       }
        if (_player_kdm_directory) {
                root->add_child("PlayerKDMDirectory")->add_child_text(_player_kdm_directory->string());
        }
index a25dab0..23286dd 100644 (file)
@@ -491,6 +491,10 @@ public:
                return _player_content_directory;
        }
 
+       boost::optional<boost::filesystem::path> player_playlist_directory () const {
+               return _player_playlist_directory;
+       }
+
        boost::optional<boost::filesystem::path> player_kdm_directory () const {
                return _player_kdm_directory;
        }
@@ -959,6 +963,18 @@ public:
                changed (PLAYER_CONTENT_DIRECTORY);
        }
 
+       void set_player_playlist_directory (boost::filesystem::path p) {
+               maybe_set (_player_playlist_directory, p);
+       }
+
+       void unset_player_playlist_directory () {
+               if (!_player_playlist_directory) {
+                       return;
+               }
+               _player_playlist_directory = boost::none;
+               changed ();
+       }
+
        void set_player_kdm_directory (boost::filesystem::path p) {
                maybe_set (_player_kdm_directory, p);
        }
@@ -1201,6 +1217,7 @@ private:
            for playback.
        */
        boost::optional<boost::filesystem::path> _player_content_directory;
+       boost::optional<boost::filesystem::path> _player_playlist_directory;
        boost::optional<boost::filesystem::path> _player_kdm_directory;
 #ifdef DCPOMATIC_VARIANT_SWAROOP
        boost::optional<boost::filesystem::path> _player_background_image;
index 9540b85..747d210 100644 (file)
@@ -87,7 +87,7 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
 
        _v_sizer->Add (view_options, 0, wxALL, DCPOMATIC_SIZER_GAP);
 
-       wxBoxSizer* e_sizer = new wxBoxSizer (wxHORIZONTAL);
+       wxBoxSizer* left_sizer = new wxBoxSizer (wxVERTICAL);
 
        _content_view = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER);
        /* time */
@@ -96,13 +96,20 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
        _content_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
        /* annotation text */
        _content_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 580);
-       e_sizer->Add (_content_view, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
+       left_sizer->Add (_content_view, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
 
        _spl_view = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER);
-       _spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
-       _spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
-       _spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 580);
-       e_sizer->Add (_spl_view, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
+       _spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 740);
+       left_sizer->Add (_spl_view, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
+
+       wxBoxSizer* e_sizer = new wxBoxSizer (wxHORIZONTAL);
+       e_sizer->Add (left_sizer, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
+
+       _current_spl_view = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER);
+       _current_spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
+       _current_spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
+       _current_spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 580);
+       e_sizer->Add (_current_spl_view, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
 
        wxBoxSizer* buttons_sizer = new wxBoxSizer (wxVERTICAL);
        _add_button = new wxButton(this, wxID_ANY, _("Add"));
@@ -120,6 +127,7 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
 
        _content_view->Show (false);
        _spl_view->Show (false);
+       _current_spl_view->Show (false);
        _add_button->Show (false);
        _save_button->Show (false);
        _load_button->Show (false);
@@ -215,7 +223,7 @@ Controls::add_clicked ()
                /* Put 1 frame of black at the start so when we seek to 0 we don't see anything */
                sel->set_position (DCPTime::from_frames(1, _film->video_frame_rate()));
        }
-       add_content_to_list (sel, _spl_view);
+       add_content_to_list (sel, _current_spl_view);
        setup_sensitivity ();
 }
 
@@ -243,10 +251,10 @@ Controls::load_clicked ()
 
        if (d->ShowModal() == wxID_OK) {
                _film->read_metadata (boost::filesystem::path(wx_to_std(d->GetPath())));
-               _spl_view->DeleteAllItems ();
+               _current_spl_view->DeleteAllItems ();
                BOOST_FOREACH (shared_ptr<Content> i, _film->content()) {
                        shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent>(i);
-                       add_content_to_list (dcp, _spl_view);
+                       add_content_to_list (dcp, _current_spl_view);
                }
        }
 
@@ -577,6 +585,7 @@ Controls::show_extended_player_controls (bool s)
                update_content_directory ();
        }
        _spl_view->Show (s);
+       _current_spl_view->Show (s);
        _log->Show (s);
        _add_button->Show (s);
        _save_button->Show (s);
index 6e9b684..2c0b84d 100644 (file)
@@ -106,6 +106,7 @@ private:
        wxCheckBox* _jump_to_selected;
        wxListCtrl* _content_view;
        wxListCtrl* _spl_view;
+       wxListCtrl* _current_spl_view;
        wxTextCtrl* _log;
        wxButton* _add_button;
        wxButton* _save_button;
index a7f61a3..62b216b 100644 (file)
@@ -234,6 +234,11 @@ private:
                table->Add (_content_directory, wxGBPosition (r, 1));
                ++r;
 
+               add_label_to_sizer (table, _panel, _("Playlist directory"), true, wxGBPosition (r, 0));
+               _playlist_directory = new wxDirPickerCtrl (_panel, wxID_ANY, wxEmptyString, wxDirSelectorPromptStr, wxDefaultPosition, wxSize (300, -1));
+               table->Add (_playlist_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));
@@ -247,6 +252,7 @@ private:
 #endif
 
                _content_directory->Bind (wxEVT_DIRPICKER_CHANGED, bind(&LocationsPage::content_directory_changed, this));
+               _playlist_directory->Bind (wxEVT_DIRPICKER_CHANGED, bind(&LocationsPage::playlist_directory_changed, this));
                _kdm_directory->Bind (wxEVT_DIRPICKER_CHANGED, bind(&LocationsPage::kdm_directory_changed, this));
 #ifdef DCPOMATIC_VARIANT_SWAROOP
                _background_image->Bind (wxEVT_FILEPICKER_CHANGED, bind(&LocationsPage::background_image_changed, this));
@@ -260,6 +266,9 @@ private:
                if (config->player_content_directory()) {
                        checked_set (_content_directory, *config->player_content_directory());
                }
+               if (config->player_playlist_directory()) {
+                       checked_set (_playlist_directory, *config->player_playlist_directory());
+               }
                if (config->player_kdm_directory()) {
                        checked_set (_kdm_directory, *config->player_kdm_directory());
                }
@@ -275,6 +284,11 @@ private:
                Config::instance()->set_player_content_directory(wx_to_std(_content_directory->GetPath()));
        }
 
+       void playlist_directory_changed ()
+       {
+               Config::instance()->set_player_playlist_directory(wx_to_std(_playlist_directory->GetPath()));
+       }
+
        void kdm_directory_changed ()
        {
                Config::instance()->set_player_kdm_directory(wx_to_std(_kdm_directory->GetPath()));
@@ -288,6 +302,7 @@ private:
 #endif
 
        wxDirPickerCtrl* _content_directory;
+       wxDirPickerCtrl* _playlist_directory;
        wxDirPickerCtrl* _kdm_directory;
 #ifdef DCPOMATIC_VARIANT_SWAROOP
        FilePickerCtrl* _background_image;