summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2015-05-02 16:03:55 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2015-05-02 16:04:30 +0200
commit3bd9c88f05205277af65f39a4e4294d98ec2a874 (patch)
tree3a04bfbe44e9d270fd1209016802f2121ae9febe
parent7acff1653599467a35904f1dd36639c54afeacf7 (diff)
actions: only shuffle selected range of playlist if applicable
-rw-r--r--NEWS1
-rw-r--r--src/actions.cpp5
-rw-r--r--src/help.cpp2
-rw-r--r--src/mpdpp.cpp7
-rw-r--r--src/mpdpp.h1
5 files changed, 14 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 8f23c34e..278ae6b2 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ ncmpcpp-0.7 (????-??-??)
* Searching with regular expressions are now enabled by default.
* Support for the Perl regular expression syntax was added.
* BOOST_LIB_SUFFIX configure variable is now empty by default.
+* Shuffle function now shuffles only selected range if selection in playlist is active.
ncmpcpp-0.6.3 (2015-03-02)
diff --git a/src/actions.cpp b/src/actions.cpp
index 5d28bc85..2f25ab01 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -1184,7 +1184,10 @@ void ToggleRepeat::run()
void Shuffle::run()
{
- Mpd.Shuffle();
+ auto begin = myPlaylist->main().begin(), end = myPlaylist->main().end();
+ auto range = getSelectedRange(begin, end);
+ Mpd.ShuffleRange(range.first-begin, range.second-begin);
+ Statusbar::print("Range shuffled");
}
void ToggleRandom::run()
diff --git a/src/help.cpp b/src/help.cpp
index 6a4dd090..746c93e5 100644
--- a/src/help.cpp
+++ b/src/help.cpp
@@ -240,7 +240,7 @@ void write_bindings(NC::Scrollpad &w)
key(w, Type::ToggleConsume, "Toggle consume mode");
key(w, Type::ToggleReplayGainMode, "Toggle replay gain mode");
key(w, Type::ToggleBitrateVisibility, "Toggle bitrate visibility");
- key(w, Type::Shuffle, "Shuffle playlist");
+ key(w, Type::Shuffle, "Shuffle selected range in playlist");
key(w, Type::ToggleCrossfade, "Toggle crossfade mode");
key(w, Type::SetCrossfade, "Set crossfade");
key(w, Type::SetVolume, "Set volume");
diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp
index 7974cb42..6604180a 100644
--- a/src/mpdpp.cpp
+++ b/src/mpdpp.cpp
@@ -297,6 +297,13 @@ void Connection::Shuffle()
checkErrors();
}
+void Connection::ShuffleRange(unsigned start, unsigned end)
+{
+ prechecksNoCommandsList();
+ mpd_run_shuffle_range(m_connection.get(), start, end);
+ checkErrors();
+}
+
void Connection::ClearMainPlaylist()
{
prechecksNoCommandsList();
diff --git a/src/mpdpp.h b/src/mpdpp.h
index 4620820b..0ed6e283 100644
--- a/src/mpdpp.h
+++ b/src/mpdpp.h
@@ -498,6 +498,7 @@ struct Connection
void Swap(unsigned, unsigned);
void Seek(unsigned int pos, unsigned int where);
void Shuffle();
+ void ShuffleRange(unsigned start, unsigned end);
void ClearMainPlaylist();
SongIterator GetPlaylistChanges(unsigned);