diff options
author | Patryk HachuĊa <hahiserw@gmail.com> | 2018-02-05 17:13:00 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-02-25 09:50:03 +0100 |
commit | 1628d801f9534ab33a711d337cdd691dca2c5710 (patch) | |
tree | 2cd898e2769fe9a897b7c67acf13ac7422df4ed2 /src/queue/Playlist.cxx | |
parent | 1fb358249b2a4f63d82103348d2904fcef608353 (diff) |
playlist/Queue: add one-shot to single mode
Diffstat (limited to 'src/queue/Playlist.cxx')
-rw-r--r-- | src/queue/Playlist.cxx | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/queue/Playlist.cxx b/src/queue/Playlist.cxx index aaed7190a..cb1de5171 100644 --- a/src/queue/Playlist.cxx +++ b/src/queue/Playlist.cxx @@ -23,6 +23,7 @@ #include "PlaylistError.hxx" #include "player/Control.hxx" #include "DetachedSong.hxx" +#include "SingleMode.hxx" #include "Log.hxx" #include <assert.h> @@ -136,7 +137,7 @@ playlist::UpdateQueuedSong(PlayerControl &pc, const DetachedSong *prev) ? queue.GetNextOrder(current) : 0; - if (next_order == 0 && queue.random && !queue.single) { + if (next_order == 0 && queue.random && queue.single == SingleMode::OFF) { /* shuffle the song order again, so we get a different order each time the playlist is played completely */ @@ -257,7 +258,7 @@ playlist::SetRepeat(PlayerControl &pc, bool status) queue.repeat = status; - pc.LockSetBorderPause(queue.single && !queue.repeat); + pc.LockSetBorderPause(queue.single != SingleMode::OFF && !queue.repeat); /* if the last song is currently being played, the "next song" might change when repeat mode is toggled */ @@ -277,14 +278,15 @@ playlist_order(playlist &playlist) } void -playlist::SetSingle(PlayerControl &pc, bool status) +playlist::SetSingle(PlayerControl &pc, SingleMode status) { if (status == queue.single) return; queue.single = status; - pc.LockSetBorderPause(queue.single && !queue.repeat); + + pc.LockSetBorderPause(queue.single != SingleMode::OFF && !queue.repeat); /* if the last song is currently being played, the "next song" might change when single mode is toggled */ @@ -353,7 +355,7 @@ playlist::GetNextPosition() const noexcept if (current < 0) return -1; - if (queue.single && queue.repeat) + if (queue.single != SingleMode::OFF && queue.repeat) return queue.OrderToPosition(current); else if (queue.IsValidOrder(current + 1)) return queue.OrderToPosition(current + 1); @@ -362,3 +364,14 @@ playlist::GetNextPosition() const noexcept return -1; } + +void +playlist::BorderPause(PlayerControl &pc) +{ + if (queue.single == SingleMode::ONE_SHOT) { + queue.single = SingleMode::OFF; + pc.LockSetBorderPause(false); + + listener.OnQueueOptionsChanged(); + } +} |