summaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qmlfollow.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-20 08:33:57 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-20 08:33:57 (GMT)
commitc0a02f5c67d3de5e16fd506df83fef968e09c798 (patch)
tree53643122e75a4d549159a9ec6000aa5b6c4a1e03 /src/declarative/util/qmlfollow.cpp
parent86529642cfdc5cc5a94b735042d0807e3b57e9e1 (diff)
parent3182e16fa31a7def9775375971bea203af419d76 (diff)
downloadQt-c0a02f5c67d3de5e16fd506df83fef968e09c798.zip
Qt-c0a02f5c67d3de5e16fd506df83fef968e09c798.tar.gz
Qt-c0a02f5c67d3de5e16fd506df83fef968e09c798.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.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp
index b8e6685..1e6fea2 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,7 +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
+ The default is 0.01. Small performance improvements can result in tuning this
value.
*/
qreal QmlFollow::epsilon() const
@@ -397,6 +404,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);