[amarok] /: PlaylistController: don't queue tracks on middle-click, just append & play
Matěj Laitl
matej at laitl.cz
Sun Jun 30 13:52:41 UTC 2013
Git commit 447af2c9e831f5b89efafd86df94b80a76e69464 by Matěj Laitl.
Committed on 30/06/2013 at 13:46.
Pushed by laitl into branch 'master'.
PlaylistController: don't queue tracks on middle-click, just append & play
...if nothing is already playing.
This is the last change to mouse playlist-related behaviour, which
hopefully makes everyone happy. Sorry for all the bumps along the road.
Playlist::AddOptions::StartPlay behaviour was improved, it now tries
harder to start playing the first added track. However, if there is
something in the queue, it just gives up.
Revised ChanegLog entry:
CHANGES:
* Playlist-related actions were harmonized, double-clicking or pressing enter will
append tracks to playlist, using any "play media" action will prepend tracks to queue
and immediately start playing; middle-clicking or will append & play while other
append or replace actions will no longer start playback. (BR 145468, BR 145490,
BR 194549)
CCMAIL: amarok-promo at kde.org
M +4 -3 ChangeLog
M +15 -3 src/playlist/PlaylistController.cpp
M +2 -3 src/playlist/PlaylistController.h
http://commits.kde.org/amarok/447af2c9e831f5b89efafd86df94b80a76e69464
diff --git a/ChangeLog b/ChangeLog
index 538a908..8287506 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -39,9 +39,10 @@ VERSION 2.8-Beta 1
Artist by default. Various Artists item is no longer shown under Track Artist level.
* Removed the splash screen.
* Playlist-related actions were harmonized, double-clicking or pressing enter will
- append tracks to playlist, middle-clicking or using any "play media" action will
- prepend tracks to queue and immediately start playing; append or replace actions will
- no longer start playback. (BR 145468, BR 145490, BR 194549)
+ append tracks to playlist, using any "play media" action will prepend tracks to queue
+ and immediately start playing; middle-clicking or will append & play while other
+ append or replace actions will no longer start playback. (BR 145468, BR 145490,
+ BR 194549)
* When a new collection plugin is enabled, its collections appear immediately without a
need for restart.
* Update the MusicBrainz tagger to MusicBrainz web service 2, make it show some more
diff --git a/src/playlist/PlaylistController.cpp b/src/playlist/PlaylistController.cpp
index c9c49bc..9ce60f8 100644
--- a/src/playlist/PlaylistController.cpp
+++ b/src/playlist/PlaylistController.cpp
@@ -195,11 +195,23 @@ Controller::insertOptioned( Meta::TrackList list, AddOptions options )
m_undoStack->endMacro();
+ bool startPlaying = false;
EngineController *engine = The::engineController();
if( options.testFlag( DirectPlay ) ) // implies PrependToQueue
- Actions::instance()->requestUserNextTrack(); // inserted track will be first in queue
- if( options.testFlag( Playlist::StartPlay ) && engine && !engine->isPlaying() )
- engine->play();
+ startPlaying = true;
+ else if( options.testFlag( StartPlay ) && engine && engine->isStopped() )
+ {
+ // if nothing is in the queue, queue the first item we have added so that the call
+ // to ->requestUserNextTrack() pops it. The queueing is therefore invisible to
+ // user. Else we start playing the queue.
+ if( Actions::instance()->queue().isEmpty() )
+ Actions::instance()->queue( QList<quint64>() << m_bottomModel->idAt( bottomModelInsertRow ) );
+
+ startPlaying = true;
+ }
+
+ if( startPlaying )
+ Actions::instance()->requestUserNextTrack(); // desired track will be first in queue
emit changed();
}
diff --git a/src/playlist/PlaylistController.h b/src/playlist/PlaylistController.h
index a338153..185b422 100644
--- a/src/playlist/PlaylistController.h
+++ b/src/playlist/PlaylistController.h
@@ -48,15 +48,14 @@ enum AddOption
DirectPlay = PrependToQueue | 8, ///< start playback of the first item in the list, implies PrependToQueue
RemotePlaylistsAreStreams = 16, ///< treat remote urls pointing to playlists as streams.
/// only has sense for methods that accept urls or playlists
- StartPlay = 32, ///< start playing (something arbitrary, not necessarily the tracks that
- /// have been just added) if nothing else is already playing
+ StartPlay = 32, ///< start playing the first added track if nothing else is already playing
// following are "consistency convenience enums" so that it is easy for us to make the
// bahaviour of similarly-looking UI elements the same. These enums are the preferred
// ones on calling sites. Feel free to add a new one if you find another UI element
// that appears on multiple places. Prefix these with On*.
OnDoubleClickOnSelectedItems = 0, // append
- OnMiddleClickOnSelectedItems = DirectPlay,
+ OnMiddleClickOnSelectedItems = StartPlay,
OnReturnPressedOnSelectedItems = 0, // append, should be kept same as double-click
OnPlayMediaAction = DirectPlay,
More information about the Amarok-promo
mailing list