From 50e7a5b7239f45c782f1814c185a1cdef31748d8 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 23 Oct 2012 14:36:59 +0200 Subject: QStyleAnimation: writable duration & delay properties These will be needed by upcoming QFadeStyleAnimation and QBlendStyleAnimation. Change-Id: Ibc5092d5dbd834cb9b16353d3e83b95b04d9484b Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qstyleanimation.cpp | 37 +++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'src/widgets/styles/qstyleanimation.cpp') diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp index 6b12ca9540..d81532f8a5 100644 --- a/src/widgets/styles/qstyleanimation.cpp +++ b/src/widgets/styles/qstyleanimation.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE QStyleAnimation::QStyleAnimation(QObject *target) : QAbstractAnimation(), - _startTime(QTime::currentTime()) + _delay(0), _duration(-1), _startTime(QTime::currentTime()) { if (target) { moveToThread(target->thread()); @@ -61,14 +61,29 @@ QStyleAnimation::~QStyleAnimation() { } +QObject *QStyleAnimation::target() const +{ + return parent(); +} + int QStyleAnimation::duration() const { - return -1; + return _duration; } -QObject *QStyleAnimation::target() const +void QStyleAnimation::setDuration(int duration) { - return parent(); + _duration = duration; +} + +int QStyleAnimation::delay() const +{ + return _delay; +} + +void QStyleAnimation::setDelay(int delay) +{ + _delay = delay; } QTime QStyleAnimation::startTime() const @@ -89,7 +104,7 @@ void QStyleAnimation::updateTarget() bool QStyleAnimation::isUpdateNeeded() const { - return true; + return currentTime() > _delay; } void QStyleAnimation::updateCurrentTime(int) @@ -137,11 +152,13 @@ void QProgressStyleAnimation::setSpeed(int speed) bool QProgressStyleAnimation::isUpdateNeeded() const { - int current = animationStep(); - if (_step == -1 || _step != current) - { - _step = current; - return true; + if (QStyleAnimation::isUpdateNeeded()) { + int current = animationStep(); + if (_step == -1 || _step != current) + { + _step = current; + return true; + } } return false; } -- cgit v1.2.3