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