summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-09-24 21:46:50 +0100
committerCarl Hetherington <cth@carlh.net>2018-09-24 21:46:50 +0100
commitab8ef6d729e6a858c8719e463011813f82c9a6ea (patch)
tree337a4f3181754825aa0652b65de3a9e39f04d814 /src
parente571e208d540a5bb6dafa49a8e91cb0428931abb (diff)
Fix up DCP list in player.
Diffstat (limited to 'src')
-rw-r--r--src/lib/config.h5
-rw-r--r--src/tools/dcpomatic_player.cc2
-rw-r--r--src/wx/controls.cc83
-rw-r--r--src/wx/controls.h42
-rw-r--r--src/wx/player_config_dialog.cc19
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 <cth@carlh.net>
+
+ 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 <http://www.gnu.org/licenses/>.
+
+*/
+
#include "controls.h"
#include "film_viewer.h"
#include "wx_util.h"
@@ -6,6 +26,7 @@
#include "lib/job_manager.h"
#include <wx/wx.h>
#include <wx/tglbtn.h>
+#include <wx/listctrl.h>
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<FilmViewer> viewer, bool outline_content, bool jump_to_selected, bool eye)
+Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> 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<FilmViewer> 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<FilmViewer> 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<FilmViewer> 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<path> 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 <cth@carlh.net>
+
+ 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 <http://www.gnu.org/licenses/>.
+
+*/
+
#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<FilmViewer>, bool outline_content = true, bool jump_to_selected = true, bool eyes = true);
+ Controls (
+ wxWindow* parent,
+ boost::shared_ptr<FilmViewer>,
+ bool outline_content = true,
+ bool jump_to_selected = true,
+ bool eyes = true,
+ bool dcp_directory = false
+ );
boost::shared_ptr<Film> film () const;
void back_frame ();
void forward_frame ();
+ void show_dcp_directory (bool s);
+
+ boost::signals2::signal<void (boost::filesystem::path)> 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> _film;
boost::shared_ptr<FilmViewer> _viewer;
@@ -56,6 +92,8 @@ private:
wxCheckBox* _outline_content;
wxChoice* _eye;
wxCheckBox* _jump_to_selected;
+ wxListCtrl* _dcp_directory;
+ std::vector<boost::filesystem::path> _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 <cth@carlh.net>
+ Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
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*