summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qstyleanimation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/styles/qstyleanimation.cpp')
-rw-r--r--src/widgets/styles/qstyleanimation.cpp56
1 files changed, 41 insertions, 15 deletions
diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp
index 6173dc9ddb..d81532f8a5 100644
--- a/src/widgets/styles/qstyleanimation.cpp
+++ b/src/widgets/styles/qstyleanimation.cpp
@@ -47,23 +47,43 @@
QT_BEGIN_NAMESPACE
-QStyleAnimation::QStyleAnimation(QObject *target) : QAbstractAnimation(target),
- _startTime(QTime::currentTime())
+QStyleAnimation::QStyleAnimation(QObject *target) : QAbstractAnimation(),
+ _delay(0), _duration(-1), _startTime(QTime::currentTime())
{
+ if (target) {
+ moveToThread(target->thread());
+ setParent(target);
+ }
+ connect(this, SIGNAL(finished()), SLOT(deleteLater()));
}
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
@@ -76,9 +96,15 @@ void QStyleAnimation::setStartTime(const QTime &time)
_startTime = time;
}
+void QStyleAnimation::updateTarget()
+{
+ QEvent event(QEvent::StyleAnimationUpdate);
+ QCoreApplication::sendEvent(target(), &event);
+}
+
bool QStyleAnimation::isUpdateNeeded() const
{
- return true;
+ return currentTime() > _delay;
}
void QStyleAnimation::updateCurrentTime(int)
@@ -90,10 +116,8 @@ void QStyleAnimation::updateCurrentTime(int)
stop();
}
- if (isUpdateNeeded()) {
- QEvent event(QEvent::StyleAnimationUpdate);
- QCoreApplication::sendEvent(tgt, &event);
- }
+ if (isUpdateNeeded())
+ updateTarget();
}
}
@@ -128,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;
}