diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index c68102b79..3e90e6376 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -69,6 +69,7 @@ #include "core/player.h" #include "core/qt_blurimage.h" #include "core/song.h" +#include "playlistmanager.h" #include "playlist.h" #include "playlistdelegates.h" #include "playlistheader.h" @@ -216,11 +217,11 @@ void PlaylistView::SetApplication(Application *app) { Q_ASSERT(app); app_ = app; - connect(app_->current_albumcover_loader(), SIGNAL(AlbumCoverLoaded(const Song&, const QUrl&, const QImage&)), SLOT(CurrentSongChanged(const Song&, const QUrl&, const QImage&))); - connect(app_->player(), SIGNAL(Paused()), SLOT(StopGlowing())); + connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(const Song&)), this, SLOT(SongChanged(const Song&))); + connect(app_->current_albumcover_loader(), SIGNAL(AlbumCoverLoaded(const Song&, const QUrl&, const QImage&)), SLOT(AlbumCoverLoaded(const Song&, const QUrl&, const QImage&))); connect(app_->player(), SIGNAL(Playing()), SLOT(StartGlowing())); - connect(app_->player(), SIGNAL(Stopped()), SLOT(StopGlowing())); - connect(app_->player(), SIGNAL(Stopped()), SLOT(PlayerStopped())); + connect(app_->player(), SIGNAL(Paused()), SLOT(StopGlowing())); + connect(app_->player(), SIGNAL(Stopped()), SLOT(Stopped())); } @@ -502,24 +503,30 @@ void PlaylistView::GlowIntensityChanged() { } void PlaylistView::StopGlowing() { + currently_glowing_ = false; glow_timer_.stop(); glow_intensity_step_ = kGlowIntensitySteps; + } void PlaylistView::StartGlowing() { + currently_glowing_ = true; if (isVisible() && glow_enabled_) glow_timer_.start(1500 / kGlowIntensitySteps, this); + } void PlaylistView::hideEvent(QHideEvent *) { glow_timer_.stop(); } void PlaylistView::showEvent(QShowEvent *) { + if (currently_glowing_ && glow_enabled_) glow_timer_.start(1500 / kGlowIntensitySteps, this); MaybeAutoscroll(); + } bool CompareSelectionRanges(const QItemSelectionRange &a, const QItemSelectionRange &b) { @@ -1214,9 +1221,24 @@ void PlaylistView::CopyCurrentSongToClipboard() const { } -void PlaylistView::CurrentSongChanged(const Song &song, const QUrl &cover_url, const QImage &song_art) { +void PlaylistView::SongChanged(const Song &song) { + song_playing_ = song; +} - if (current_song_cover_art_ == song_art) return; +void PlaylistView::Playing() {} + +void PlaylistView::Stopped() { + + if (song_playing_ == Song()) return; + song_playing_ = Song(); + StopGlowing(); + AlbumCoverLoaded(Song(), QUrl(), QImage()); + +} + +void PlaylistView::AlbumCoverLoaded(const Song &song, const QUrl &cover_url, const QImage &song_art) { + + if ((song != Song() && song_playing_ == Song()) || song_art == current_song_cover_art_) return; current_song_cover_art_ = song_art; if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Album) { @@ -1284,10 +1306,6 @@ void PlaylistView::FadePreviousBackgroundImage(qreal value) { } -void PlaylistView::PlayerStopped() { - CurrentSongChanged(Song(), QUrl(), QImage()); -} - void PlaylistView::focusInEvent(QFocusEvent *event) { QTreeView::focusInEvent(event); diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index a93bf61d0..deebe6e71 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -50,6 +50,7 @@ #include #include +#include "core/song.h" #include "settings/appearancesettingspage.h" #include "playlist.h" @@ -68,7 +69,6 @@ class QPaintEvent; class QTimerEvent; class Application; -class Song; class CollectionBackend; class PlaylistHeader; @@ -119,16 +119,8 @@ class PlaylistView : public QTreeView { void ReloadSettings(); void SaveGeometry(); void SaveSettings(); - void StopGlowing(); - void StartGlowing(); - void JumpToCurrentlyPlayingTrack(); - void JumpToLastPlayedTrack(); - void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint); void SetColumnAlignment(int section, Qt::Alignment alignment); - - void CopyCurrentSongToClipboard() const; - void CurrentSongChanged(const Song &new_song, const QUrl &cover_url, const QImage &song_art); - void PlayerStopped(); + void JumpToCurrentlyPlayingTrack(); signals: void PlayItem(const QModelIndex &index); @@ -155,7 +147,6 @@ class PlaylistView : public QTreeView { void dragEnterEvent(QDragEnterEvent *event); void dragLeaveEvent(QDragLeaveEvent *event); void dropEvent(QDropEvent *event); - //void resizeEvent(QResizeEvent *event); bool eventFilter(QObject *object, QEvent *event); void focusInEvent(QFocusEvent *event); @@ -164,18 +155,26 @@ class PlaylistView : public QTreeView { // QAbstractItemView void rowsInserted(const QModelIndex &parent, int start, int end); + void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint); private slots: - void LoadGeometry(); - void GlowIntensityChanged(); void InhibitAutoscrollTimeout(); void MaybeAutoscroll(); void InvalidateCachedCurrentPixmap(); void PlaylistDestroyed(); void StretchChanged(bool stretch); void FadePreviousBackgroundImage(qreal value); + void StopGlowing(); + void StartGlowing(); + void JumpToLastPlayedTrack(); + void CopyCurrentSongToClipboard() const; + void Playing(); + void Stopped(); + void SongChanged(const Song &song); + void AlbumCoverLoaded(const Song &new_song, const QUrl &cover_url, const QImage &song_art); private: + void LoadGeometry(); void ReloadBarPixmaps(); QList LoadBarPixmap(const QString &filename); void UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option, const QModelIndex &index); @@ -188,6 +187,8 @@ class PlaylistView : public QTreeView { // Should be used instead of modifying background_image_ directly void set_background_image(const QImage &image); + void GlowIntensityChanged(); + private: static const int kGlowIntensitySteps; static const int kAutoscrollGraceTimeout; @@ -268,6 +269,8 @@ class PlaylistView : public QTreeView { QByteArray state_; + Song song_playing_; + }; #endif // PLAYLISTVIEW_H