From: Carl Hetherington Date: Thu, 1 Dec 2022 19:00:09 +0000 (+0100) Subject: Save playlist when content is added, moved or removed. X-Git-Tag: v2.16.36~39^2~9 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=a733da8088152a2487691629753fe8a2addfa5a3 Save playlist when content is added, moved or removed. --- diff --git a/src/lib/spl.h b/src/lib/spl.h index b002a0882..f55a9fe1f 100644 --- a/src/lib/spl.h +++ b/src/lib/spl.h @@ -114,6 +114,21 @@ public: Changed(Change::NAME); } + void add(SPLEntry e) { + SPL::add(e); + Changed(Change::CONTENT); + } + + void remove(std::size_t index) { + SPL::remove(index); + Changed(Change::CONTENT); + } + + void swap(size_t a, size_t b) { + SPL::swap(a, b); + Changed(Change::CONTENT); + } + boost::signals2::signal Changed; }; diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc index 5a8ee9126..5368cb3af 100644 --- a/src/tools/dcpomatic_playlist.cc +++ b/src/tools/dcpomatic_playlist.cc @@ -176,7 +176,9 @@ private: return; } - if (change == SignalSPL::Change::NAME) { + switch (change) { + case SignalSPL::Change::NAME: + { int N = 0; for (auto i: _playlists) { if (i == playlist) { @@ -184,6 +186,13 @@ private: } ++N; } + break; + } + case SignalSPL::Change::CONTENT: + if (auto dir = Config::instance()->player_playlist_directory()) { + playlist->write(*dir / (playlist->id() + ".xml")); + } + break; } }