diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2014-07-26 17:29:54 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@digia.com> | 2014-07-30 10:18:08 +0200 |
commit | 8738f09b9fc1b35e3dc78211368d87069f3071f7 (patch) | |
tree | a52ef7c94e374743fd9da997e898b69fb3fe2542 /src/widgets/styles/qstyleanimation.cpp | |
parent | 0240110c58f0d6b694445f6685f0f77b14b769d8 (diff) |
Reduce the default frame rate of style animations
Halves the amount of paint events triggered by transient scrollbars.
Task-number: QTBUG-30316
Change-Id: Ifdf968d5c45013332758a6b751ce11d1ef2a2ca8
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/widgets/styles/qstyleanimation.cpp')
-rw-r--r-- | src/widgets/styles/qstyleanimation.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp index 85dc357ab5..e6e47a98e9 100644 --- a/src/widgets/styles/qstyleanimation.cpp +++ b/src/widgets/styles/qstyleanimation.cpp @@ -50,7 +50,7 @@ static const qreal ScrollBarFadeOutDuration = 200.0; static const qreal ScrollBarFadeOutDelay = 450.0; QStyleAnimation::QStyleAnimation(QObject *target) : QAbstractAnimation(target), - _delay(0), _duration(-1), _startTime(QTime::currentTime()) + _delay(0), _duration(-1), _startTime(QTime::currentTime()), _fps(ThirtyFps), _skip(0) { } @@ -93,6 +93,16 @@ void QStyleAnimation::setStartTime(const QTime &time) _startTime = time; } +QStyleAnimation::FrameRate QStyleAnimation::frameRate() const +{ + return _fps; +} + +void QStyleAnimation::setFrameRate(FrameRate fps) +{ + _fps = fps; +} + void QStyleAnimation::updateTarget() { QEvent event(QEvent::StyleAnimationUpdate); @@ -102,6 +112,12 @@ void QStyleAnimation::updateTarget() stop(); } +void QStyleAnimation::start() +{ + _skip = 0; + QAbstractAnimation::start(DeleteWhenStopped); +} + bool QStyleAnimation::isUpdateNeeded() const { return currentTime() > _delay; @@ -109,8 +125,11 @@ bool QStyleAnimation::isUpdateNeeded() const void QStyleAnimation::updateCurrentTime(int) { - if (target() && isUpdateNeeded()) - updateTarget(); + if (++_skip >= _fps) { + _skip = 0; + if (target() && isUpdateNeeded()) + updateTarget(); + } } QProgressStyleAnimation::QProgressStyleAnimation(int speed, QObject *target) : |