From ab8ef6d729e6a858c8719e463011813f82c9a6ea Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 24 Sep 2018 21:46:50 +0100 Subject: [PATCH] Fix up DCP list in player. --- src/lib/config.h | 5 +- src/tools/dcpomatic_player.cc | 2 + src/wx/controls.cc | 83 +++++++++++++++++++++++++++++++++- src/wx/controls.h | 42 ++++++++++++++++- src/wx/player_config_dialog.cc | 19 +++++++- 5 files changed, 145 insertions(+), 6 deletions(-) diff --git a/src/lib/config.h b/src/lib/config.h index fc5d820f9..814f078f0 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -76,6 +76,7 @@ public: SOUND, SOUND_OUTPUT, INTERFACE_COMPLEXITY, + PLAYER_DCP_DIRECTORY, OTHER }; @@ -908,7 +909,7 @@ public: } void set_player_dcp_directory (boost::filesystem::path p) { - maybe_set (_player_dcp_directory, p); + maybe_set (_player_dcp_directory, p, PLAYER_DCP_DIRECTORY); } void unset_player_dcp_directory () { @@ -916,7 +917,7 @@ public: return; } _player_dcp_directory = boost::none; - changed (); + changed (PLAYER_DCP_DIRECTORY); } void changed (Property p = OTHER); diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 3be947cc6..06b83a97f 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -191,6 +191,7 @@ public: Bind (wxEVT_MENU, boost::bind (&DOMFrame::forward_frame, this), ID_forward_frame); UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this)); + _controls->DCPDirectorySelected.connect (boost::bind(&DOMFrame::load_dcp, this, _1)); setup_screen (); } @@ -576,6 +577,7 @@ private: void setup_screen () { _controls->Show (_mode != Config::PLAYER_MODE_FULL); + _controls->show_dcp_directory (_mode == Config::PLAYER_MODE_DUAL); _info->Show (_mode != Config::PLAYER_MODE_FULL); _overall_panel->SetBackgroundColour (_mode == Config::PLAYER_MODE_FULL ? wxColour(0, 0, 0) : wxNullColour); ShowFullScreen (_mode == Config::PLAYER_MODE_FULL); diff --git a/src/wx/controls.cc b/src/wx/controls.cc index c48628ed1..915c056b3 100644 --- a/src/wx/controls.cc +++ b/src/wx/controls.cc @@ -1,3 +1,23 @@ +/* + Copyright (C) 2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + #include "controls.h" #include "film_viewer.h" #include "wx_util.h" @@ -6,6 +26,7 @@ #include "lib/job_manager.h" #include #include +#include using std::string; using boost::optional; @@ -15,7 +36,7 @@ using boost::weak_ptr; /** @param outline_content true if viewer should present an "outline content" checkbox. * @param jump_to_selected true if viewer should present a "jump to selected" checkbox. */ -Controls::Controls (wxWindow* parent, shared_ptr viewer, bool outline_content, bool jump_to_selected, bool eye) +Controls::Controls (wxWindow* parent, shared_ptr viewer, bool outline_content, bool jump_to_selected, bool eye, bool dcp_directory) : wxPanel (parent) , _viewer (viewer) , _slider_being_moved (false) @@ -55,6 +76,11 @@ Controls::Controls (wxWindow* parent, shared_ptr viewer, bool outlin _v_sizer->Add (view_options, 0, wxALL, DCPOMATIC_SIZER_GAP); + _dcp_directory = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize(600, -1), wxLC_REPORT | wxLC_NO_HEADER); + _dcp_directory->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 580); + _v_sizer->Add (_dcp_directory, 0, wxALL, DCPOMATIC_SIZER_GAP); + _dcp_directory->Show (dcp_directory); + wxBoxSizer* h_sizer = new wxBoxSizer (wxHORIZONTAL); wxBoxSizer* time_sizer = new wxBoxSizer (wxVERTICAL); @@ -92,6 +118,7 @@ Controls::Controls (wxWindow* parent, shared_ptr viewer, bool outlin _forward_button->Bind (wxEVT_LEFT_DOWN, boost::bind (&Controls::forward_clicked, this, _1)); _frame_number->Bind (wxEVT_LEFT_DOWN, boost::bind (&Controls::frame_number_clicked, this)); _timecode->Bind (wxEVT_LEFT_DOWN, boost::bind (&Controls::timecode_clicked, this)); + _dcp_directory->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind (&Controls::dcp_directory_selected, this)); if (_jump_to_selected) { _jump_to_selected->Bind (wxEVT_CHECKBOX, boost::bind (&Controls::jump_to_selected_clicked, this)); _jump_to_selected->SetValue (Config::instance()->jump_to_selected ()); @@ -105,10 +132,21 @@ Controls::Controls (wxWindow* parent, shared_ptr viewer, bool outlin film_changed (); setup_sensitivity (); + update_dcp_directory (); JobManager::instance()->ActiveJobsChanged.connect ( bind (&Controls::active_jobs_changed, this, _2) ); + + _config_changed_connection = Config::instance()->Changed.connect (bind(&Controls::config_changed, this, _1)); +} + +void +Controls::config_changed (int property) +{ + if (property == Config::PLAYER_DCP_DIRECTORY) { + update_dcp_directory (); + } } void @@ -375,3 +413,46 @@ Controls::film () const { return _film; } + +void +Controls::show_dcp_directory (bool s) +{ + _dcp_directory->Show (s); +} + +void +Controls::update_dcp_directory () +{ + using namespace boost::filesystem; + + _dcp_directory->DeleteAllItems (); + _dcp_directories.clear (); + optional dir = Config::instance()->player_dcp_directory(); + if (!dir) { + return; + } + + for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) { + try { + if (is_directory(*i) && (is_regular_file(*i / "ASSETMAP") || is_regular_file(*i / "ASSETMAP.xml"))) { + string const x = i->path().string().substr(dir->string().length() + 1); + _dcp_directory->InsertItem(_dcp_directory->GetItemCount(), std_to_wx(x)); + _dcp_directories.push_back(x); + } + } catch (boost::filesystem::filesystem_error& e) { + /* Never mind */ + } + } +} + +void +Controls::dcp_directory_selected () +{ + long int s = _dcp_directory->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + if (s == -1) { + return; + } + + DCPOMATIC_ASSERT (s < int(_dcp_directories.size())); + DCPDirectorySelected (*Config::instance()->player_dcp_directory() / _dcp_directories[s]); +} diff --git a/src/wx/controls.h b/src/wx/controls.h index 1c8474e54..8ee5310c7 100644 --- a/src/wx/controls.h +++ b/src/wx/controls.h @@ -1,3 +1,23 @@ +/* + Copyright (C) 2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + #include "lib/dcpomatic_time.h" #include "lib/types.h" #include "lib/film.h" @@ -11,16 +31,28 @@ class ClosedCaptionsDialog; class Content; class PlayerVideo; class wxToggleButton; +class wxListCtrl; class Controls : public wxPanel { public: - Controls (wxWindow* parent, boost::shared_ptr, bool outline_content = true, bool jump_to_selected = true, bool eyes = true); + Controls ( + wxWindow* parent, + boost::shared_ptr, + bool outline_content = true, + bool jump_to_selected = true, + bool eyes = true, + bool dcp_directory = false + ); boost::shared_ptr film () const; void back_frame (); void forward_frame (); + void show_dcp_directory (bool s); + + boost::signals2::signal DCPDirectorySelected; + private: void update_position_label (); void update_position_slider (); @@ -45,6 +77,10 @@ private: void started (); void stopped (); void film_changed (); + void update_dcp_directory (); + void dcp_directory_changed (); + void dcp_directory_selected (); + void config_changed (int property); boost::shared_ptr _film; boost::shared_ptr _viewer; @@ -56,6 +92,8 @@ private: wxCheckBox* _outline_content; wxChoice* _eye; wxCheckBox* _jump_to_selected; + wxListCtrl* _dcp_directory; + std::vector _dcp_directories; wxSlider* _slider; wxButton* _rewind_button; wxButton* _back_button; @@ -65,4 +103,6 @@ private: wxToggleButton* _play_button; ClosedCaptionsDialog* _closed_captions_dialog; + + boost::signals2::scoped_connection _config_changed_connection; }; diff --git a/src/wx/player_config_dialog.cc b/src/wx/player_config_dialog.cc index 84657f99b..dda2b62e5 100644 --- a/src/wx/player_config_dialog.cc +++ b/src/wx/player_config_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2017 Carl Hetherington + Copyright (C) 2012-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -26,8 +26,8 @@ #include "wx_util.h" #include "editable_list.h" #include "filter_dialog.h" -#include "dir_picker_ctrl.h" #include "file_picker_ctrl.h" +#include "dir_picker_ctrl.h" #include "isdcf_metadata_dialog.h" #include "server_dialog.h" #include "make_chain_dialog.h" @@ -110,10 +110,16 @@ private: table->Add (_log_file, wxGBPosition (r, 1)); ++r; + add_label_to_sizer (table, _panel, _("DCP directory"), true, wxGBPosition (r, 0)); + _dcp_directory = new wxDirPickerCtrl (_panel, wxID_ANY, wxEmptyString, wxDirSelectorPromptStr, wxDefaultPosition, wxSize (300, -1)); + table->Add (_dcp_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)); } void config_changed () @@ -139,6 +145,9 @@ private: if (config->player_log_file()) { checked_set (_log_file, *config->player_log_file()); } + if (config->player_dcp_directory()) { + checked_set (_dcp_directory, *config->player_dcp_directory()); + } } private: @@ -172,10 +181,16 @@ private: Config::instance()->set_player_log_file(wx_to_std(_log_file->GetPath())); } + void dcp_directory_changed () + { + Config::instance()->set_player_dcp_directory(wx_to_std(_dcp_directory->GetPath())); + } + wxChoice* _player_mode; wxChoice* _image_display; wxCheckBox* _respect_kdm; FilePickerCtrl* _log_file; + wxDirPickerCtrl* _dcp_directory; }; wxPreferencesEditor* -- 2.30.2