diff --git a/src/playlistview.cpp b/src/playlistview.cpp index eb63f2208..d6cca56a7 100644 --- a/src/playlistview.cpp +++ b/src/playlistview.cpp @@ -39,7 +39,6 @@ const int PlaylistView::kDropIndicatorGradientWidth = 5; PlaylistView::PlaylistView(QWidget *parent) : QTreeView(parent), glow_enabled_(false), - glow_timer_(new QTimer(this)), glow_intensity_step_(0), inhibit_autoscroll_timer_(new QTimer(this)), inhibit_autoscroll_(false), @@ -59,9 +58,6 @@ PlaylistView::PlaylistView(QWidget *parent) inhibit_autoscroll_timer_->setSingleShot(true); connect(inhibit_autoscroll_timer_, SIGNAL(timeout()), SLOT(InhibitAutoscrollTimeout())); - glow_timer_->setInterval(1500 / kGlowIntensitySteps); - connect(glow_timer_, SIGNAL(timeout()), SLOT(GlowIntensityChanged())); - setAlternatingRowColors(true); } @@ -204,6 +200,11 @@ void PlaylistView::drawRow(QPainter* painter, const QStyleOptionViewItem& option QTreeView::drawRow(painter, opt, index); } +void PlaylistView::timerEvent(QTimerEvent* event) { + if (event->timerId() == glow_timer_.timerId()) + GlowIntensityChanged(); +} + void PlaylistView::GlowIntensityChanged() { glow_intensity_step_ = (glow_intensity_step_ + 1) % (kGlowIntensitySteps * 2); @@ -212,23 +213,23 @@ void PlaylistView::GlowIntensityChanged() { void PlaylistView::StopGlowing() { glow_enabled_ = false; - glow_timer_->stop(); + glow_timer_.stop(); glow_intensity_step_ = kGlowIntensitySteps; } void PlaylistView::StartGlowing() { glow_enabled_ = true; if (isVisible()) - glow_timer_->start(); + glow_timer_.start(1500 / kGlowIntensitySteps, this); } void PlaylistView::hideEvent(QHideEvent*) { - glow_timer_->stop(); + glow_timer_.stop(); } void PlaylistView::showEvent(QShowEvent*) { if (glow_enabled_) - glow_timer_->start(); + glow_timer_.start(1500 / kGlowIntensitySteps, this); MaybeAutoscroll(); } diff --git a/src/playlistview.h b/src/playlistview.h index f76e9d9d0..3395d3dfd 100644 --- a/src/playlistview.h +++ b/src/playlistview.h @@ -21,6 +21,7 @@ #include "library.h" #include +#include class RadioLoadingIndicator; @@ -53,6 +54,7 @@ class PlaylistView : public QTreeView { protected: void hideEvent(QHideEvent* event); void showEvent(QShowEvent* event); + void timerEvent(QTimerEvent *event); void mousePressEvent(QMouseEvent *event); void scrollContentsBy(int dx, int dy); void paintEvent(QPaintEvent *event); @@ -83,7 +85,7 @@ class PlaylistView : public QTreeView { QModelIndex PrevEditableIndex(const QModelIndex& current); bool glow_enabled_; - QTimer* glow_timer_; + QBasicTimer glow_timer_; int glow_intensity_step_; QModelIndex last_current_item_; QRect last_glow_rect_;