summaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qmlfollow.cpp
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-07-21 07:24:36 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-07-21 07:24:36 (GMT)
commit34055e0160e2e94b0dd6b972c5bdc96a421adcf1 (patch)
treebf7667e86dfe4d5c8e7ee3be40aa8862ff4042ca /src/declarative/util/qmlfollow.cpp
parentc301d995c646c70f8f943e2e4fc293a3e2d29edf (diff)
parent8db694cb38e1f7f5096db96fcc1f168b13e643a4 (diff)
downloadQt-34055e0160e2e94b0dd6b972c5bdc96a421adcf1.zip
Qt-34055e0160e2e94b0dd6b972c5bdc96a421adcf1.tar.gz
Qt-34055e0160e2e94b0dd6b972c5bdc96a421adcf1.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/util/qmlfollow.cpp')
-rw-r--r--src/declarative/util/qmlfollow.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp
index b8e6685..63b6307 100644
--- a/src/declarative/util/qmlfollow.cpp
+++ b/src/declarative/util/qmlfollow.cpp
@@ -56,7 +56,7 @@ class QmlFollowPrivate : public QObjectPrivate
public:
QmlFollowPrivate()
: sourceValue(0), maxVelocity(0), lastTime(0)
- , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.005), modulus(0.0), enabled(true), mode(Track), clock(this) {}
+ , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.01), modulus(0.0), enabled(true), mode(Track), clock(this) {}
QmlMetaProperty property;
qreal currentValue;
@@ -164,8 +164,10 @@ void QmlFollowPrivate::tick(int time)
}
lastTime = time;
}
- emit q->valueChanged(currentValue);
property.write(currentValue);
+ emit q->valueChanged(currentValue);
+ if (clock.state() != QAbstractAnimation::Running)
+ emit q->syncChanged();
}
void QmlFollowPrivate::updateMode()
@@ -183,12 +185,15 @@ void QmlFollowPrivate::start()
if (!enabled)
return;
+ Q_Q(QmlFollow);
if (mode == QmlFollowPrivate::Track) {
currentValue = sourceValue;
property.write(currentValue);
} else if (sourceValue != currentValue && clock.state() != QAbstractAnimation::Running) {
lastTime = 0;
+ currentValue = property.read().toDouble();
clock.start(); // infinity??
+ emit q->syncChanged();
}
}
@@ -261,8 +266,10 @@ qreal QmlFollow::sourceValue() const
void QmlFollow::setSourceValue(qreal value)
{
Q_D(QmlFollow);
- d->sourceValue = value;
- d->start();
+ if (d->sourceValue != value) {
+ d->sourceValue = value;
+ d->start();
+ }
}
/*!
@@ -338,8 +345,7 @@ void QmlFollow::setDamping(qreal damping)
to 0 to be considered equal to zero. This will depend on the usage of the value.
For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice.
- The default is 0.005. Small performance improvements can result in tuning this
- value.
+ The default is 0.01. Tuning this value can provide small performance improvements.
*/
qreal QmlFollow::epsilon() const
{
@@ -397,6 +403,19 @@ void QmlFollow::setEnabled(bool enabled)
d->stop();
}
+/*!
+ \qmlproperty bool Follow::inSync
+ This property is true when target is equal to the source; otherwise
+ false. If inSync is true the target is not being animated.
+
+ If \l enabled is false then inSync will also be false.
+*/
+bool QmlFollow::inSync() const
+{
+ Q_D(const QmlFollow);
+ return d->enabled && d->clock.state() != QAbstractAnimation::Running;
+}
+
qreal QmlFollow::value() const
{
Q_D(const QmlFollow);