diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-11-11 07:58:21 +1000 |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-11-11 07:58:21 +1000 |
commit | 1ef5affa7aa12f9f70bcdd6d984b8e1b9ccd646b (patch) | |
tree | bee5308c4bafb944b0a2400fd276380bc1171ac2 /src/gui/styles | |
parent | de0dcfdb1133dcee7b6d0d50a2bcd95f5bdf2515 (diff) | |
parent | b1998f4f59c3b10700963b2d13a17a0cc77ef665 (diff) | |
download | qt4-tools-1ef5affa7aa12f9f70bcdd6d984b8e1b9ccd646b.tar.gz |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
Repaint QProgressBar when minimum or maximum changed
Fix QProgressBar causing timer event spam
Compile fix for Mac OS X 10.7 with 10.6 sdk
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/qwindowsstyle.cpp | 56 | ||||
-rw-r--r-- | src/gui/styles/qwindowsstyle_p.h | 4 |
2 files changed, 37 insertions, 23 deletions
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 2244c11faf..6ab29b9203 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -133,6 +133,26 @@ QWindowsStylePrivate::QWindowsStylePrivate() startTime.start(); } +void QWindowsStylePrivate::startAnimation(QObject *o, QProgressBar *bar) +{ + if (!animatedProgressBars.contains(bar)) { + animatedProgressBars << bar; + if (!animateTimer) { + Q_ASSERT(animationFps > 0); + animateTimer = o->startTimer(1000 / animationFps); + } + } +} + +void QWindowsStylePrivate::stopAnimation(QObject *o, QProgressBar *bar) +{ + animatedProgressBars.removeAll(bar); + if (animatedProgressBars.isEmpty() && animateTimer) { + o->killTimer(animateTimer); + animateTimer = 0; + } +} + // Returns true if the toplevel parent of \a widget has seen the Alt-key bool QWindowsStylePrivate::hasSeenAlt(const QWidget *widget) const { @@ -150,10 +170,8 @@ void QWindowsStyle::timerEvent(QTimerEvent *event) if (event->timerId() == d->animateTimer) { Q_ASSERT(d->animationFps> 0); d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps); - foreach (QProgressBar *bar, d->bars) { - if ((bar->minimum() == 0 && bar->maximum() == 0)) - bar->update(); - } + foreach (QProgressBar *bar, d->animatedProgressBars) + bar->update(); } #endif // QT_NO_PROGRESSBAR event->ignore(); @@ -215,29 +233,23 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) break; #ifndef QT_NO_PROGRESSBAR case QEvent::StyleChange: + case QEvent::Paint: case QEvent::Show: if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) { - if (!d->bars.contains(bar)) { - d->bars << bar; - if (d->bars.size() == 1) { - Q_ASSERT(d->animationFps> 0); - if (d->animateTimer == 0) - d->animateTimer = startTimer(1000 / d->animationFps); - } - } + // Animation by timer for progress bars that have their min and + // max values the same + if (bar->minimum() == bar->maximum()) + d->startAnimation(this, bar); + else + d->stopAnimation(this, 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)) { - d->bars.removeAll(bar); - if (d->bars.isEmpty() && d->animateTimer) { - killTimer(d->animateTimer); - d->animateTimer = 0; - } - } + // Do static_cast because there is no type info when getting + // the destroy event. We know that it is a QProgressBar, since + // we only install a widget event filter for QScrollBars. + d->stopAnimation(this, static_cast<QProgressBar *>(o)); break; #endif // QT_NO_PROGRESSBAR default: @@ -343,7 +355,7 @@ void QWindowsStyle::unpolish(QWidget *widget) if (QProgressBar *bar=qobject_cast<QProgressBar *>(widget)) { Q_D(QWindowsStyle); widget->removeEventFilter(this); - d->bars.removeAll(bar); + d->stopAnimation(this, bar); } #endif } diff --git a/src/gui/styles/qwindowsstyle_p.h b/src/gui/styles/qwindowsstyle_p.h index b9f39a0940..1e517e9e79 100644 --- a/src/gui/styles/qwindowsstyle_p.h +++ b/src/gui/styles/qwindowsstyle_p.h @@ -71,13 +71,15 @@ class QWindowsStylePrivate : public QCommonStylePrivate Q_DECLARE_PUBLIC(QWindowsStyle) public: QWindowsStylePrivate(); + void startAnimation(QObject *o, QProgressBar *bar); + void stopAnimation(QObject *o, QProgressBar *bar); bool hasSeenAlt(const QWidget *widget) const; bool altDown() const { return alt_down; } bool alt_down; QList<const QWidget *> seenAlt; int menuBarTimer; - QList<QProgressBar *> bars; + QList<QProgressBar *> animatedProgressBars; int animationFps; int animateTimer; QElapsedTimer startTime; |