summaryrefslogtreecommitdiffstats
path: root/src/plugins/styles/motif/qmotifstyle.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/motif/qmotifstyle.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/motif/qmotifstyle.cpp')
-rw-r--r--src/plugins/styles/motif/qmotifstyle.cpp47
1 files changed, 33 insertions, 14 deletions
diff --git a/src/plugins/styles/motif/qmotifstyle.cpp b/src/plugins/styles/motif/qmotifstyle.cpp
index 7bc340d..508057d 100644
--- a/src/plugins/styles/motif/qmotifstyle.cpp
+++ b/src/plugins/styles/motif/qmotifstyle.cpp
@@ -114,7 +114,6 @@ QMotifStyle::QMotifStyle(bool useHighlightCols) : QCommonStyle(), focus(0),
highlightCols(useHighlightCols), animationFps(25), animateTimer(0), animateStep(0),
spinboxHCoeff(6)
{
- startTime.start();
}
/*!
@@ -136,26 +135,22 @@ bool QMotifStyle::eventFilter(QObject *o, QEvent *e)
#ifndef QT_NO_PROGRESSBAR
switch (e->type()) {
case QEvent::StyleChange:
+ case QEvent::Paint:
case QEvent::Show:
if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
- bars << bar;
- if (bars.size() == 1) {
- Q_ASSERT(animationFps> 0);
- animateTimer = startTimer(1000 / animationFps);
- }
+ // Animation by timer for progress bars that have their min and
+ // max values the same
+ if (bar->minimum() == bar->maximum())
+ startProgressAnimation(bar);
+ else
+ stopProgressAnimation(bar);
}
break;
case QEvent::Destroy:
case QEvent::Hide:
// reinterpret_cast because there is no type info when getting
// the destroy event. We know that it is a QProgressBar.
- if (QProgressBar *bar = reinterpret_cast<QProgressBar *>(o)) {
- bars.removeAll(bar);
- if (bars.isEmpty() && animateTimer) {
- killTimer(animateTimer);
- animateTimer = 0;
- }
- }
+ stopProgressAnimation(reinterpret_cast<QProgressBar *>(o));
default:
break;
}
@@ -163,6 +158,30 @@ bool QMotifStyle::eventFilter(QObject *o, QEvent *e)
return QStyle::eventFilter(o, e);
}
+void QMotifStyle::startProgressAnimation(QProgressBar *bar)
+{
+ if (!bars.contains(bar)) {
+ bars << bar;
+ if (bars.size() == 1) {
+ Q_ASSERT(animationFps > 0);
+ animateStep = 0;
+ startTime.start();
+ animateTimer = startTimer(1000 / animationFps);
+ }
+ }
+}
+
+void QMotifStyle::stopProgressAnimation(QProgressBar *bar)
+{
+ if (!bars.isEmpty()) {
+ bars.removeOne(bar);
+ if (bars.isEmpty() && animateTimer) {
+ killTimer(animateTimer);
+ animateTimer = 0;
+ }
+ }
+}
+
/*!
\reimp
*/
@@ -271,7 +290,7 @@ void QMotifStyle::unpolish(QWidget* widget)
#ifndef QT_NO_PROGRESSBAR
if (qobject_cast<QProgressBar *>(widget)) {
widget->removeEventFilter(this);
- bars.removeAll(static_cast<QProgressBar*>(widget));
+ bars.removeOne(static_cast<QProgressBar*>(widget));
}
#endif
}