summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-10-28 19:44:53 +0000
committerCarl Hetherington <cth@carlh.net>2018-10-28 19:44:53 +0000
commit5feadb30fc839601345c4553c5a954ffc37bc1c7 (patch)
tree118dfc31cecf9dad728a37de370e3a6328d9633f /src
parent47bf227f163b3dca8b07ae593f067793bccaefc8 (diff)
Untested loading of playlists into the list view.
Diffstat (limited to 'src')
-rw-r--r--src/lib/config.h5
-rw-r--r--src/wx/controls.cc50
-rw-r--r--src/wx/controls.h3
3 files changed, 54 insertions, 4 deletions
diff --git a/src/lib/config.h b/src/lib/config.h
index 23286ddb0..a162750fe 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -78,6 +78,7 @@ public:
SOUND_OUTPUT,
INTERFACE_COMPLEXITY,
PLAYER_CONTENT_DIRECTORY,
+ PLAYER_PLAYLIST_DIRECTORY,
HISTORY,
#ifdef DCPOMATIC_VARIANT_SWAROOP
PLAYER_BACKGROUND_IMAGE,
@@ -964,7 +965,7 @@ public:
}
void set_player_playlist_directory (boost::filesystem::path p) {
- maybe_set (_player_playlist_directory, p);
+ maybe_set (_player_playlist_directory, p, PLAYER_PLAYLIST_DIRECTORY);
}
void unset_player_playlist_directory () {
@@ -972,7 +973,7 @@ public:
return;
}
_player_playlist_directory = boost::none;
- changed ();
+ changed (PLAYER_PLAYLIST_DIRECTORY);
}
void set_player_kdm_directory (boost::filesystem::path p) {
diff --git a/src/wx/controls.cc b/src/wx/controls.cc
index d8df6f2f3..62f75fde3 100644
--- a/src/wx/controls.cc
+++ b/src/wx/controls.cc
@@ -42,6 +42,7 @@
using std::string;
using std::list;
using std::make_pair;
+using std::exception;
using boost::optional;
using boost::shared_ptr;
using boost::weak_ptr;
@@ -200,6 +201,7 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
setup_sensitivity ();
update_content_directory ();
+ update_playlist_directory ();
JobManager::instance()->ActiveJobsChanged.connect (
bind (&Controls::active_jobs_changed, this, _2)
@@ -236,7 +238,9 @@ Controls::save_clicked ()
);
if (d->ShowModal() == wxID_OK) {
- _film->write_metadata(wx_to_std(d->GetPath()));
+ boost::filesystem::path p(wx_to_std(d->GetPath()));
+ _film->set_name(p.stem().string());
+ _film->write_metadata(p);
}
d->Destroy ();
@@ -266,6 +270,8 @@ Controls::config_changed (int property)
{
if (property == Config::PLAYER_CONTENT_DIRECTORY) {
update_content_directory ();
+ } else if (property == Config::PLAYER_PLAYLIST_DIRECTORY) {
+ update_playlist_directory ();
} else {
setup_sensitivity ();
}
@@ -581,10 +587,11 @@ void
Controls::show_extended_player_controls (bool s)
{
_content_view->Show (s);
+ _spl_view->Show (s);
if (s) {
update_content_directory ();
+ update_playlist_directory ();
}
- _spl_view->Show (s);
_current_spl_view->Show (s);
_log->Show (s);
_add_button->Show (s);
@@ -625,6 +632,18 @@ Controls::add_content_to_list (shared_ptr<Content> content, wxListCtrl* ctrl)
}
void
+Controls::add_playlist_to_list (shared_ptr<Film> film)
+{
+ int const N = _spl_view->GetItemCount();
+
+ wxListItem it;
+ it.SetId(N);
+ it.SetColumn(0);
+ it.SetText (std_to_wx(film->name()));
+ _spl_view->InsertItem (it);
+}
+
+void
Controls::update_content_directory ()
{
if (!_content_view->IsShown()) {
@@ -677,6 +696,33 @@ Controls::update_content_directory ()
}
}
+void
+Controls::update_playlist_directory ()
+{
+ if (!_spl_view->IsShown()) {
+ return;
+ }
+
+ using namespace boost::filesystem;
+
+ _spl_view->DeleteAllItems ();
+ optional<path> dir = Config::instance()->player_playlist_directory();
+ if (!dir) {
+ return;
+ }
+
+ for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) {
+ try {
+ shared_ptr<Film> film (new Film(optional<path>()));
+ film->read_metadata (i->path());
+ _playlists.push_back (film);
+ add_playlist_to_list (film);
+ } catch (exception& e) {
+ /* Never mind */
+ }
+ }
+}
+
#ifdef DCPOMATIC_VARIANT_SWAROOP
void
Controls::pause_clicked ()
diff --git a/src/wx/controls.h b/src/wx/controls.h
index 2c0b84d8d..d916beaf8 100644
--- a/src/wx/controls.h
+++ b/src/wx/controls.h
@@ -80,6 +80,7 @@ private:
void stopped ();
void film_changed ();
void update_content_directory ();
+ void update_playlist_directory ();
void config_changed (int property);
typedef std::pair<boost::shared_ptr<dcp::CPL>, boost::filesystem::path> CPL;
@@ -93,6 +94,7 @@ private:
void save_clicked ();
void load_clicked ();
void add_content_to_list (boost::shared_ptr<Content> content, wxListCtrl* list);
+ void add_playlist_to_list (boost::shared_ptr<Film> film);
boost::shared_ptr<Film> _film;
boost::shared_ptr<FilmViewer> _viewer;
@@ -112,6 +114,7 @@ private:
wxButton* _save_button;
wxButton* _load_button;
std::vector<boost::shared_ptr<Content> > _content;
+ std::vector<boost::shared_ptr<Film> > _playlists;
wxSlider* _slider;
wxButton* _rewind_button;
wxButton* _back_button;