diff options
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/config_dialog.cc | 19 | ||||
| -rw-r--r-- | src/wx/config_dialog.h | 4 | ||||
| -rw-r--r-- | src/wx/content_view.cc | 41 | ||||
| -rw-r--r-- | src/wx/content_view.h | 12 | ||||
| -rw-r--r-- | src/wx/playlist_controls.cc | 120 | ||||
| -rw-r--r-- | src/wx/playlist_controls.h | 9 | ||||
| -rw-r--r-- | src/wx/wx_util.cc | 6 | ||||
| -rw-r--r-- | src/wx/wx_util.h | 2 |
8 files changed, 110 insertions, 103 deletions
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 17ee0fb21..bca2e20b9 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -24,6 +24,7 @@ #include "check_box.h" #include "config_dialog.h" #include "dcpomatic_button.h" +#include "file_picker_ctrl.h" #include "nag_dialog.h" #include "static_text.h" #include "wx_variant.h" @@ -1041,9 +1042,9 @@ LocationsPage::setup () 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, char_to_wx(wxDirSelectorPromptStr), wxDefaultPosition, wxSize (300, -1)); - table->Add (_playlist_directory, wxGBPosition (r, 1)); + add_label_to_sizer(table, _panel, _("Show playlists file"), true, wxGBPosition (r, 0)); + _show_playlists_file = new FilePickerCtrl(_panel, _("Select show playlists file"), _("SQLite3 files (.sqlite3)|*.sqlite3)"), false, true, "ShowPlaylistsFile"); + table->Add(_show_playlists_file, wxGBPosition (r, 1)); ++r; add_label_to_sizer (table, _panel, _("KDM directory"), true, wxGBPosition (r, 0)); @@ -1052,7 +1053,7 @@ LocationsPage::setup () ++r; _content_directory->Bind (wxEVT_DIRPICKER_CHANGED, bind(&LocationsPage::content_directory_changed, this)); - _playlist_directory->Bind (wxEVT_DIRPICKER_CHANGED, bind(&LocationsPage::playlist_directory_changed, this)); + _show_playlists_file->Bind(wxEVT_FILEPICKER_CHANGED, bind(&LocationsPage::show_playlists_file_changed, this)); _kdm_directory->Bind (wxEVT_DIRPICKER_CHANGED, bind(&LocationsPage::kdm_directory_changed, this)); } @@ -1064,9 +1065,7 @@ LocationsPage::config_changed () 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()); - } + checked_set(_show_playlists_file, config->show_playlists_file()); if (config->player_kdm_directory()) { checked_set (_kdm_directory, *config->player_kdm_directory()); } @@ -1079,9 +1078,11 @@ LocationsPage::content_directory_changed () } void -LocationsPage::playlist_directory_changed () +LocationsPage::show_playlists_file_changed() { - Config::instance()->set_player_playlist_directory(wx_to_std(_playlist_directory->GetPath())); + if (auto path = _show_playlists_file->path()) { + Config::instance()->set_show_playlists_file(*path); + } } void diff --git a/src/wx/config_dialog.h b/src/wx/config_dialog.h index ce2686864..62cee0145 100644 --- a/src/wx/config_dialog.h +++ b/src/wx/config_dialog.h @@ -235,11 +235,11 @@ private: void setup () override; void config_changed () override; void content_directory_changed (); - void playlist_directory_changed (); + void show_playlists_file_changed(); void kdm_directory_changed (); wxDirPickerCtrl* _content_directory; - wxDirPickerCtrl* _playlist_directory; + FilePickerCtrl* _show_playlists_file; wxDirPickerCtrl* _kdm_directory; }; diff --git a/src/wx/content_view.cc b/src/wx/content_view.cc index f3c11fa04..46da832a0 100644 --- a/src/wx/content_view.cc +++ b/src/wx/content_view.cc @@ -62,55 +62,50 @@ ContentView::ContentView (wxWindow* parent) } -shared_ptr<Content> -ContentView::selected () const +optional<ShowPlaylistEntry> +ContentView::selected() const { - long int s = GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + long int s = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (s == -1) { return {}; } - DCPOMATIC_ASSERT(s < int(_content_digests.size())); - return ContentStore::instance()->get(_content_digests[s]); + DCPOMATIC_ASSERT(s < int(_uuids.size())); + return ShowPlaylistContentStore::instance()->get(_uuids[s]); } void -ContentView::update () +ContentView::update() { - DeleteAllItems (); - _content_digests.clear(); - for (auto content: ContentStore::instance()->all()) { - add(content); + DeleteAllItems(); + _uuids.clear(); + for (auto entry: ShowPlaylistContentStore::instance()->all()) { + add(entry); } } void -ContentView::add(shared_ptr<Content> content) +ContentView::add(ShowPlaylistEntry entry) { int const N = GetItemCount(); wxListItem it; it.SetId(N); it.SetColumn(0); - auto length = content->approximate_length (); - auto const hmsf = length.split (24); - it.SetText(wxString::Format(char_to_wx("%02d:%02d:%02d"), hmsf.h, hmsf.m, hmsf.s)); + it.SetText(std_to_wx(entry.approximate_length())); InsertItem(it); - auto dcp = dynamic_pointer_cast<DCPContent>(content); - if (dcp && dcp->content_kind()) { - it.SetId(N); - it.SetColumn(1); - it.SetText(std_to_wx(dcp->content_kind()->name())); - SetItem(it); - } + it.SetId(N); + it.SetColumn(1); + it.SetText(std_to_wx(entry.kind().name())); + SetItem(it); it.SetId(N); it.SetColumn(2); - it.SetText(std_to_wx(content->summary())); + it.SetText(std_to_wx(entry.name())); SetItem(it); - _content_digests.push_back(content->digest()); + _uuids.push_back(entry.uuid()); } diff --git a/src/wx/content_view.h b/src/wx/content_view.h index 65f806340..e27b14132 100644 --- a/src/wx/content_view.h +++ b/src/wx/content_view.h @@ -19,7 +19,7 @@ */ -#include "lib/content_store.h" +#include "lib/show_playlist_content_store.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/listctrl.h> @@ -31,17 +31,21 @@ class Content; class Film; +/** @class ContentView + * + * @brief A GUI list of content from our ShowPlaylistContentStore. + */ class ContentView : public wxListCtrl { public: ContentView (wxWindow* parent); - std::shared_ptr<Content> selected () const; + boost::optional<ShowPlaylistEntry> selected() const; void update (); private: - void add (std::shared_ptr<Content> content); + void add(ShowPlaylistEntry entry); std::weak_ptr<Film> _film; - std::vector<std::string> _content_digests; + std::vector<std::string> _uuids; }; diff --git a/src/wx/playlist_controls.cc b/src/wx/playlist_controls.cc index 0f88f2881..488215fe9 100644 --- a/src/wx/playlist_controls.cc +++ b/src/wx/playlist_controls.cc @@ -35,6 +35,7 @@ #include "lib/internet.h" #include "lib/player_video.h" #include "lib/scoped_temporary.h" +#include "lib/show_playlist_list.h" #include <dcp/exceptions.h> #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS @@ -118,10 +119,10 @@ PlaylistControls::PlaylistControls(wxWindow* parent, FilmViewer& viewer) _spl_view->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind(&PlaylistControls::spl_selection_changed, this)); _spl_view->Bind (wxEVT_LIST_ITEM_DESELECTED, boost::bind(&PlaylistControls::spl_selection_changed, this)); _viewer.Finished.connect(boost::bind(&PlaylistControls::viewer_finished, this)); - _refresh_spl_view->Bind (wxEVT_BUTTON, boost::bind(&PlaylistControls::update_playlist_directory, this)); + _refresh_spl_view->Bind (wxEVT_BUTTON, boost::bind(&PlaylistControls::update_playlists, this)); _refresh_content_view->Bind (wxEVT_BUTTON, boost::bind(&ContentView::update, _content_view)); - update_playlist_directory (); + update_playlists(); } void @@ -209,7 +210,9 @@ PlaylistControls::previous_clicked () bool PlaylistControls::can_do_next () { - return _selected_playlist && (_selected_playlist_position + 1) < int(_playlists[*_selected_playlist].get().size()); + ShowPlaylistList spl_list; + auto entries = spl_list.entries(_playlists[*_selected_playlist].uuid()); + return _selected_playlist && (_selected_playlist_position + 1) < int(entries.size()); } void @@ -225,61 +228,44 @@ PlaylistControls::next_clicked () void -PlaylistControls::add_playlist_to_list (SPL spl) +PlaylistControls::add_playlist_to_list(ShowPlaylist show_playlist) { int const N = _spl_view->GetItemCount(); wxListItem it; it.SetId(N); it.SetColumn(0); - string t = spl.name(); - if (spl.missing()) { - t += " (content missing)"; - } + string t = show_playlist.name(); + // XXX + // if (spl.missing()) { + // t += " (content missing)"; + // } it.SetText (std_to_wx(t)); _spl_view->InsertItem (it); } -struct SPLComparator -{ - bool operator() (SPL const & a, SPL const & b) { - return a.name() < b.name(); - } -}; void -PlaylistControls::update_playlist_directory () +PlaylistControls::update_playlists() { using namespace boost::filesystem; _spl_view->DeleteAllItems (); - optional<path> dir = Config::instance()->player_playlist_directory(); - if (!dir) { - return; - } + _playlists.clear(); - _playlists.clear (); - - for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) { - try { - if (is_regular_file(i->path()) && i->path().extension() == ".xml") { - SPL spl; - spl.read(i->path(), ContentStore::instance()); - _playlists.push_back (spl); - } - } catch (exception& e) { - /* Never mind */ - } + ShowPlaylistList spl_list; + for (auto const& spl: spl_list.show_playlists()) { + _playlists.push_back(spl.second); } - sort (_playlists.begin(), _playlists.end(), SPLComparator()); for (auto i: _playlists) { - add_playlist_to_list (i); + add_playlist_to_list(i); } _selected_playlist = boost::none; } + optional<dcp::EncryptedKDM> PlaylistControls::get_kdm_from_directory (shared_ptr<DCPContent> dcp) { @@ -313,13 +299,17 @@ PlaylistControls::spl_selection_changed () return; } - if (_playlists[selected].missing()) { - error_dialog(this, _("This playlist cannot be loaded as some content is missing.")); - deselect_playlist (); - return; - } + // XXX + // if (_playlists[selected].missing()) { + // error_dialog(this, _("This playlist cannot be loaded as some content is missing.")); + // deselect_playlist (); + // return; + // } + + ShowPlaylistList spl_list; + auto const entries = spl_list.entries(_playlists[selected].uuid()); - if (_playlists[selected].get().empty()) { + if (entries.empty()) { error_dialog(this, _("This playlist is empty.")); return; } @@ -332,13 +322,20 @@ PlaylistControls::select_playlist (int selected, int position) { wxProgressDialog dialog(variant::wx::dcpomatic(), _("Loading playlist and KDMs")); - for (auto const& i: _playlists[selected].get()) { + _playlist.clear(); + + ShowPlaylistList spl_list; + for (auto const& uuid: spl_list.entries(_playlists[selected].uuid())) { dialog.Pulse (); - shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (i.content); + + auto entry = ShowPlaylistContentStore::instance()->get(uuid); + if (!entry) { + continue; + } + + auto dcp = dynamic_pointer_cast<DCPContent>(entry->content()); if (dcp && dcp->needs_kdm()) { - optional<dcp::EncryptedKDM> kdm; - kdm = get_kdm_from_directory (dcp); - if (kdm) { + if (auto kdm = get_kdm_from_directory(dcp)) { try { dcp->add_kdm (*kdm); dcp->examine(_film, shared_ptr<Job>(), true); @@ -358,13 +355,15 @@ PlaylistControls::select_playlist (int selected, int position) _current_spl_view->DeleteAllItems (); int N = 0; - for (auto i: _playlists[selected].get()) { - wxListItem it; - it.SetId (N); - it.SetColumn (0); - it.SetText (std_to_wx(i.name)); - _current_spl_view->InsertItem (it); - ++N; + for (auto const& uuid: spl_list.entries(_playlists[selected].uuid())) { + if (auto entry = ShowPlaylistContentStore::instance()->get(uuid)) { + wxListItem it; + it.SetId(N); + it.SetColumn(0); + it.SetText(std_to_wx(entry->name())); + _current_spl_view->InsertItem(it); + ++N; + } } _selected_playlist = selected; @@ -379,9 +378,13 @@ void PlaylistControls::reset_film () { DCPOMATIC_ASSERT (_selected_playlist); - shared_ptr<Film> film (new Film(optional<boost::filesystem::path>())); - film->add_content (_playlists[*_selected_playlist].get()[_selected_playlist_position].content); - ResetFilm (film); + auto film = std::make_shared<Film>(optional<boost::filesystem::path>()); + ShowPlaylistList spl_list; + auto uuid = spl_list.entries(_playlists[*_selected_playlist].uuid())[_selected_playlist_position]; + if (auto entry = ShowPlaylistContentStore::instance()->get(uuid)) { + film->add_content(entry->content()); + } + ResetFilm(film); } void @@ -391,8 +394,8 @@ PlaylistControls::config_changed (int property) if (property == Config::PLAYER_CONTENT_DIRECTORY) { _content_view->update (); - } else if (property == Config::PLAYER_PLAYLIST_DIRECTORY) { - update_playlist_directory (); + } else if (property == Config::SHOW_PLAYLISTS_FILE) { + update_playlists(); } } @@ -417,8 +420,11 @@ PlaylistControls::viewer_finished () return; } + ShowPlaylistList spl_list; + auto entries = spl_list.entries(_playlists[*_selected_playlist].uuid()); + _selected_playlist_position++; - if (_selected_playlist_position < int(_playlists[*_selected_playlist].get().size())) { + if (_selected_playlist_position < int(entries.size())) { /* Next piece of content on the SPL */ update_current_content (); _viewer.start(); diff --git a/src/wx/playlist_controls.h b/src/wx/playlist_controls.h index 76ec63824..a9516ef3c 100644 --- a/src/wx/playlist_controls.h +++ b/src/wx/playlist_controls.h @@ -20,7 +20,7 @@ #include "controls.h" -#include "lib/spl.h" +#include "lib/show_playlist.h" class DCPContent; @@ -46,9 +46,9 @@ private: void stop_clicked (); void next_clicked (); void previous_clicked (); - void add_playlist_to_list (SPL spl); + void add_playlist_to_list(ShowPlaylist spl); void update_content_directory (); - void update_playlist_directory (); + void update_playlists(); void spl_selection_changed (); void select_playlist (int selected, int position); void started () override; @@ -76,7 +76,8 @@ private: wxButton* _refresh_spl_view; wxListCtrl* _current_spl_view; - std::vector<SPL> _playlists; + std::vector<ShowPlaylist> _playlists; boost::optional<int> _selected_playlist; + std::vector<std::shared_ptr<Content>> _playlist; int _selected_playlist_position; }; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index bc2d593f1..cb231eb5f 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -33,7 +33,7 @@ #include "wx_util.h" #include "wx_variant.h" #include "lib/config.h" -#include "lib/content_store.h" +#include "lib/show_playlist_content_store.h" #include "lib/cross.h" #include "lib/job.h" #include "lib/job_manager.h" @@ -845,7 +845,7 @@ layout_for_short_screen(wxWindow* reference) void -update_content_store() +update_show_playlist_content_store() { auto dir = Config::instance()->player_content_directory(); if (!dir || !dcp::filesystem::is_directory(*dir)) { @@ -854,7 +854,7 @@ update_content_store() wxProgressDialog progress(variant::wx::dcpomatic(), _("Reading content directory")); - auto store = ContentStore::instance(); + auto store = ShowPlaylistContentStore::instance(); auto errors = store->update([&progress]() { return progress.Pulse(); diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index 6c3f12ef2..3f513f0a3 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -126,7 +126,7 @@ extern double dpi_scale_factor (wxWindow* window); extern int search_ctrl_height (); extern void report_config_load_failure(wxWindow* parent, Config::LoadFailure what); extern bool layout_for_short_screen(wxWindow* reference); -extern void update_content_store(); +extern void update_show_playlist_content_store(); struct Offset |
