diff options
| author | Błażej Szczygieł <spaz16@wp.pl> | 2017-01-11 21:45:27 +0100 |
|---|---|---|
| committer | Błażej Szczygieł <spaz16@wp.pl> | 2017-03-11 09:23:02 +0000 |
| commit | 335dbece103e2cbf6c7cf819ab6672c2956b17b3 (patch) | |
| tree | f6ecc6a247235c3dae0d607694356496dcf5d767 /src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp | |
| parent | 5ef7b26b9792b5aae4d289413a3a0691766b072e (diff) | |
Move plastique and cleanlooks timer event to "event()" method, because
"timerEvent()" doesn't work on class derivated from "QProxyStyle".
Also unify plastique, cleanlooks and motif animation timer methods.
This allows to kill timer for plastique and motif styles when it will
be no longer necessary (as in cleanlooks style).
Change-Id: I1365e57d56bf35bf07c3efc604482a5405608930
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp')
| -rw-r--r-- | src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp b/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp index 2ebe10f..1843b56 100644 --- a/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp +++ b/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp @@ -609,7 +609,6 @@ static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTi QCleanlooksStyle::QCleanlooksStyle() : QProxyStyle(QStyleFactory::create(QLatin1String("Windows"))), animateStep(0), animateTimer(0) { setObjectName(QLatin1String("CleanLooks")); - startTime.start(); } /*! @@ -3945,17 +3944,26 @@ void QCleanlooksStyle::unpolish(QApplication *app) /*! \reimp */ -void QCleanlooksStyle::timerEvent(QTimerEvent *event) +bool QCleanlooksStyle::event(QEvent *event) { + switch (event->type()) { + case QEvent::Timer: { #ifndef QT_NO_PROGRESSBAR - if (event->timerId() == animateTimer) { - Q_ASSERT(progressAnimationFps> 0); - animateStep = startTime.elapsed() / (1000 / progressAnimationFps); - foreach (QProgressBar *bar, animatedProgressBars) - bar->update(); - } + QTimerEvent *timerEvent = reinterpret_cast<QTimerEvent *>(event); + if (timerEvent->timerId() == animateTimer) { + Q_ASSERT(progressAnimationFps > 0); + animateStep = startTime.elapsed() / (1000 / progressAnimationFps); + foreach (QProgressBar *bar, animatedProgressBars) + bar->update(); + } #endif // QT_NO_PROGRESSBAR - event->ignore(); + event->ignore(); + } + default: + break; + } + + return QProxyStyle::event(event); } /*! @@ -3998,6 +4006,8 @@ void QCleanlooksStyle::startProgressAnimation(QObject *o, QProgressBar *bar) animatedProgressBars << bar; if (!animateTimer) { Q_ASSERT(progressAnimationFps > 0); + animateStep = 0; + startTime.start(); animateTimer = o->startTimer(1000 / progressAnimationFps); } } @@ -4005,10 +4015,12 @@ void QCleanlooksStyle::startProgressAnimation(QObject *o, QProgressBar *bar) void QCleanlooksStyle::stopProgressAnimation(QObject *o, QProgressBar *bar) { - animatedProgressBars.removeAll(bar); - if (animatedProgressBars.isEmpty() && animateTimer) { - o->killTimer(animateTimer); - animateTimer = 0; + if (!animatedProgressBars.isEmpty()) { + animatedProgressBars.removeOne(bar); + if (animatedProgressBars.isEmpty() && animateTimer) { + o->killTimer(animateTimer); + animateTimer = 0; + } } } |
