Commit cbfe92c3 authored by Michael Pyne's avatar Michael Pyne
Browse files

playlist: Ensure playing track is visible when it changes.

I tried to ensure this only causes the playlist to jump when the user
isn't directly interacting with the track (e.g. double click to play).

BUG:356224
FIXED-IN:21.04
parent a9f85d8d
......@@ -208,7 +208,7 @@ void PlayerManager::play(const QString &file)
{
CollectionListItem *item = CollectionList::instance()->lookup(file);
if(item) {
Playlist::setPlaying(item); // Will reentrantly call play(FileHandle)
item->playlist()->setPlaying(item); // Will reentrantly call play(FileHandle)
}
}
......
......@@ -773,7 +773,7 @@ void Playlist::slotShowPlaying()
m_collection->raise(l);
l->setCurrentItem(playingItem());
l->scrollToItem(playingItem());
l->scrollToItem(playingItem(), QAbstractItemView::PositionAtCenter);
}
void Playlist::slotColumnResizeModeChanged()
......@@ -1610,7 +1610,6 @@ void Playlist::loadFile(const QString &fileName, const QFileInfo &fileInfo)
playlistItemsChanged();
}
// static
void Playlist::setPlaying(PlaylistItem *item, bool addToHistory)
{
auto wasPlayingItem = playingItem();
......@@ -1631,6 +1630,15 @@ void Playlist::setPlaying(PlaylistItem *item, bool addToHistory)
if(item) {
item->setPlaying(true);
if(wasPlayingItem
&& m_search->isEmpty()
&& state() == QAbstractItemView::NoState
&& (!m_rmbMenu || m_rmbMenu->isHidden())
)
{
scrollToItem(item, QAbstractItemView::PositionAtCenter);
}
}
}
......
......@@ -233,7 +233,7 @@ public:
* Set item to be the playing item. If \a item is null then this will clear
* the playing indicator.
*/
static void setPlaying(PlaylistItem *item, bool addToHistory = true);
void setPlaying(PlaylistItem *item, bool addToHistory = true);
/**
* Returns true if this playlist is currently playing.
......
......@@ -668,6 +668,12 @@ void PlaylistCollection::raise(Playlist *playlist)
playlist->setSearchEnabled(m_searchEnabled);
m_playlistStack->setCurrentWidget(playlist);
clearShowMore(false);
const auto playingItem = Playlist::playingItem();
if(playingItem && visiblePlaylist() != playlist && playingItem->playlist() == playlist) {
playlist->scrollToItem(playingItem, QAbstractItemView::PositionAtCenter);
}
playlistItemsChanged();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment