Center on last played song when restoring playlist. Fixes issue 410.
This commit is contained in:
parent
0544cfa90a
commit
79159700fc
@ -1123,6 +1123,7 @@ void Playlist::ItemsLoaded() {
|
||||
|
||||
last_played_item_index_ =
|
||||
p.last_played == -1 ? QModelIndex() : index(p.last_played);
|
||||
current_item_index_ = last_played_item_index_;
|
||||
|
||||
if (!p.dynamic_type.isEmpty()) {
|
||||
GeneratorPtr gen = Generator::Create(p.dynamic_type);
|
||||
@ -1143,6 +1144,7 @@ void Playlist::ItemsLoaded() {
|
||||
}
|
||||
}
|
||||
}
|
||||
emit RestoreFinished();
|
||||
}
|
||||
|
||||
static bool DescendingIntLessThan(int a, int b) {
|
||||
|
@ -233,6 +233,7 @@ class Playlist : public QAbstractListModel {
|
||||
void TurnOffDynamicPlaylist();
|
||||
|
||||
signals:
|
||||
void RestoreFinished();
|
||||
void CurrentSongChanged(const Song& metadata);
|
||||
void EditingFinished(const QModelIndex& index);
|
||||
void PlayRequested(const QModelIndex& index);
|
||||
|
@ -168,8 +168,11 @@ void PlaylistView::SetPlaylist(Playlist *playlist) {
|
||||
LoadGeometry();
|
||||
ReloadSettings();
|
||||
DynamicModeChanged(playlist->is_dynamic());
|
||||
setFocus();
|
||||
read_only_settings_ = false;
|
||||
|
||||
connect(playlist_, SIGNAL(RestoreFinished()), SLOT(JumpToLastPlayedTrack()));
|
||||
|
||||
connect(playlist_, SIGNAL(CurrentSongChanged(Song)), SLOT(MaybeAutoscroll()));
|
||||
connect(playlist_, SIGNAL(DynamicModeChanged(bool)), SLOT(DynamicModeChanged(bool)));
|
||||
connect(playlist_, SIGNAL(destroyed()), SLOT(PlaylistDestroyed()));
|
||||
@ -671,6 +674,25 @@ void PlaylistView::JumpToCurrentlyPlayingTrack() {
|
||||
currently_autoscrolling_ = false;
|
||||
}
|
||||
|
||||
void PlaylistView::JumpToLastPlayedTrack() {
|
||||
Q_ASSERT(playlist_);
|
||||
|
||||
if (playlist_->last_played_row() == -1)
|
||||
return;
|
||||
|
||||
QModelIndex last_played = playlist_->proxy()->mapFromSource(
|
||||
playlist_->index(playlist_->last_played_row(), 0));
|
||||
if (!last_played.isValid())
|
||||
return;
|
||||
|
||||
currently_autoscrolling_ = true;
|
||||
|
||||
// Scroll to the item
|
||||
scrollTo(last_played, QAbstractItemView::PositionAtCenter);
|
||||
|
||||
currently_autoscrolling_ = false;
|
||||
}
|
||||
|
||||
void PlaylistView::paintEvent(QPaintEvent* event) {
|
||||
// Reimplemented to draw the drop indicator
|
||||
// When the user is dragging some stuff over the playlist paintEvent gets
|
||||
|
@ -81,6 +81,7 @@ class PlaylistView : public QTreeView {
|
||||
void StopGlowing();
|
||||
void StartGlowing();
|
||||
void JumpToCurrentlyPlayingTrack();
|
||||
void JumpToLastPlayedTrack();
|
||||
void closeEditor(QWidget* editor, QAbstractItemDelegate::EndEditHint hint);
|
||||
void DynamicModeChanged(bool dynamic);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user