diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2013-12-18 16:37:17 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-11 18:36:05 +0100 |
commit | 062d2a1f801a03db09db23763f024bd0397305a0 (patch) | |
tree | 9300a606bf5141ee1585e250e4daedc8d0938dbb /src/widgets/styles/qstyleanimation.cpp | |
parent | e14885a18a3ab0bffd6d638dcccffd39cb52bf0e (diff) |
Promote the scrollbar style animation to qstyleanimation_p.h
Makes it possible for QFusionStyle to utilize the same animation.
Change-Id: Ifac9eaa3138cf1068439d5b0271a2acce54a3c16
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/widgets/styles/qstyleanimation.cpp')
-rw-r--r-- | src/widgets/styles/qstyleanimation.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp index 90fb371982..85dc357ab5 100644 --- a/src/widgets/styles/qstyleanimation.cpp +++ b/src/widgets/styles/qstyleanimation.cpp @@ -46,6 +46,9 @@ QT_BEGIN_NAMESPACE +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()) { @@ -301,4 +304,43 @@ void QBlendStyleAnimation::updateCurrentTime(int time) _current = blendedImage(_start, _end, alpha); } +QScrollbarStyleAnimation::QScrollbarStyleAnimation(Mode mode, QObject *target) : QNumberStyleAnimation(target), _mode(mode), _active(false) +{ + switch (mode) { + case Activating: + setDuration(ScrollBarFadeOutDuration); + setStartValue(0.0); + setEndValue(1.0); + break; + case Deactivating: + setDuration(ScrollBarFadeOutDelay + ScrollBarFadeOutDuration); + setDelay(ScrollBarFadeOutDelay); + setStartValue(1.0); + setEndValue(0.0); + break; + } +} + +QScrollbarStyleAnimation::Mode QScrollbarStyleAnimation::mode() const +{ + return _mode; +} + +bool QScrollbarStyleAnimation::wasActive() const +{ + return _active; +} + +void QScrollbarStyleAnimation::setActive(bool active) +{ + _active = active; +} + +void QScrollbarStyleAnimation::updateCurrentTime(int time) +{ + QNumberStyleAnimation::updateCurrentTime(time); + if (_mode == Deactivating && qFuzzyIsNull(currentValue())) + target()->setProperty("visible", false); +} + QT_END_NAMESPACE |