X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_playlist.cc;h=bc1f78dc36432935ca539bc2010ba3df3f514212;hp=6f06c0624e91109475a6b320c4ca5e8a56ed6fa1;hb=76e340c36a7c0da70b145c0437b5758eaa7134dc;hpb=3339d3bce70afe9ae2ca10e9fcfc4b54b748fbf4 diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc index 6f06c0624..bc1f78dc3 100644 --- a/src/tools/dcpomatic_playlist.cc +++ b/src/tools/dcpomatic_playlist.cc @@ -19,12 +19,12 @@ */ -#include "wx/wx_util.h" -#include "wx/wx_signal_manager.h" +#include "wx/about_dialog.h" #include "wx/content_view.h" #include "wx/dcpomatic_button.h" -#include "wx/about_dialog.h" #include "wx/playlist_editor_config_dialog.h" +#include "wx/wx_signal_manager.h" +#include "wx/wx_util.h" #include "lib/config.h" #include "lib/cross.h" #include "lib/dcp_content.h" @@ -32,11 +32,14 @@ #include "lib/spl.h" #include "lib/spl_entry.h" #include "lib/util.h" -#include -#include +#include +LIBDCP_DISABLE_WARNINGS #include -#include +#include #include +#include +#include +LIBDCP_ENABLE_WARNINGS using std::cout; @@ -85,7 +88,7 @@ public: return _content_view->selected (); } - shared_ptr get (string digest) const + shared_ptr get (string digest) const override { return _content_view->get (digest); } @@ -163,22 +166,33 @@ private: void add_playlist_to_model (shared_ptr playlist) { _playlists.push_back (playlist); - playlist->NameChanged.connect (bind(&PlaylistList::name_changed, this, weak_ptr(playlist))); + playlist->Changed.connect(bind(&PlaylistList::changed, this, weak_ptr(playlist), _1)); } - void name_changed (weak_ptr wp) + void changed(weak_ptr wp, SignalSPL::Change change) { auto playlist = wp.lock (); if (!playlist) { return; } - int N = 0; - for (auto i: _playlists) { - if (i == playlist) { - _list->SetItem (N, 0, std_to_wx(i->name())); + switch (change) { + case SignalSPL::Change::NAME: + { + int N = 0; + for (auto i: _playlists) { + if (i == playlist) { + _list->SetItem (N, 0, std_to_wx(i->name())); + } + ++N; + } + break; + } + case SignalSPL::Change::CONTENT: + if (auto dir = Config::instance()->player_playlist_directory()) { + playlist->write(*dir / (playlist->id() + ".xml")); } - ++N; + break; } } @@ -279,8 +293,8 @@ public: auto images = new wxImageList (16, 16); wxIcon tick_icon; wxIcon no_tick_icon; - tick_icon.LoadFile (bitmap_path("tick"), wxBITMAP_TYPE_PNG); - no_tick_icon.LoadFile (bitmap_path("no_tick"), wxBITMAP_TYPE_PNG); + tick_icon.LoadFile (bitmap_path("tick.png"), wxBITMAP_TYPE_PNG); + no_tick_icon.LoadFile (bitmap_path("no_tick.png"), wxBITMAP_TYPE_PNG); images->Add (tick_icon); images->Add (no_tick_icon); @@ -357,7 +371,7 @@ private: { _list->SetItem (N, 0, std_to_wx(e.name)); _list->SetItem (N, 1, std_to_wx(e.id)); - _list->SetItem (N, 2, std_to_wx(dcp::content_kind_to_string(e.kind))); + _list->SetItem (N, 2, std_to_wx(e.kind->name())); _list->SetItem (N, 3, e.encrypted ? S_("Question|Y") : S_("Question|N")); } @@ -397,9 +411,7 @@ private: DCPOMATIC_ASSERT (_playlist); - auto tmp = (*_playlist)[s]; - (*_playlist)[s] = (*_playlist)[s-1]; - (*_playlist)[s-1] = tmp; + _playlist->swap(s, s - 1); set_item (s - 1, (*_playlist)[s-1]); set_item (s, (*_playlist)[s]); @@ -414,9 +426,7 @@ private: DCPOMATIC_ASSERT (_playlist); - auto tmp = (*_playlist)[s]; - (*_playlist)[s] = (*_playlist)[s+1]; - (*_playlist)[s+1] = tmp; + _playlist->swap(s, s + 1); set_item (s + 1, (*_playlist)[s+1]); set_item (s, (*_playlist)[s]); @@ -474,8 +484,6 @@ public: _playlist_list->Edit.connect (bind(&DOMFrame::change_playlist, this, _1)); - _playlist_content->set (_playlist_list->first_playlist()); - Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT); Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), wxID_ABOUT); Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES); @@ -590,7 +598,7 @@ public: private: - bool OnInit () + bool OnInit () override try { wxInitAllImageHandlers (); @@ -645,7 +653,7 @@ private: } /* An unhandled exception has occurred inside the main event loop */ - bool OnExceptionInMainLoop () + bool OnExceptionInMainLoop () override { try { throw; @@ -674,7 +682,7 @@ private: return false; } - void OnUnhandledException () + void OnUnhandledException () override { error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM); }