summaryrefslogtreecommitdiffstats
path: root/src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp
diff options
context:
space:
mode:
authorBłażej Szczygieł <[email protected]>2017-01-11 21:45:27 +0100
committerBłażej Szczygieł <[email protected]>2017-03-11 09:23:02 +0000
commit335dbece103e2cbf6c7cf819ab6672c2956b17b3 (patch)
treef6ecc6a247235c3dae0d607694356496dcf5d767 /src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp
parent5ef7b26b9792b5aae4d289413a3a0691766b072e (diff)
Fix plastique, cleanlooks and motif animation timerHEADmaster
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 <[email protected]>
Diffstat (limited to 'src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp')
-rw-r--r--src/plugins/styles/cleanlooks/qcleanlooksstyle.cpp38
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;
+ }
}
}