summaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qmleasefollow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/util/qmleasefollow.cpp')
-rw-r--r--src/declarative/util/qmleasefollow.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qmleasefollow.cpp
index 83dbde7..b58ad14 100644
--- a/src/declarative/util/qmleasefollow.cpp
+++ b/src/declarative/util/qmleasefollow.cpp
@@ -56,7 +56,7 @@ public:
QmlEaseFollowPrivate()
: source(0), velocity(200), duration(-1),
reversingMode(QmlEaseFollow::Eased), initialVelocity(0),
- initialValue(0), invert(false), trackVelocity(0), clockOffset(0),
+ initialValue(0), invert(false), enabled(true), trackVelocity(0), clockOffset(0),
lastTick(0), clock(this)
{}
@@ -68,6 +68,7 @@ public:
qreal initialVelocity;
qreal initialValue;
bool invert;
+ bool enabled;
qreal trackVelocity;
@@ -267,7 +268,7 @@ qreal QmlEaseFollow::sourceValue() const
/*!
\qmlproperty enumeration EaseFollow::reversingMode
- Sets how the EaseFollow behaves if an animation diration is reversed.
+ Sets how the EaseFollow behaves if an animation direction is reversed.
If reversing mode is \c Eased, the animation will smoothly decelerate, and
then reverse direction. If the reversing mode is \c Immediate, the
@@ -289,6 +290,9 @@ void QmlEaseFollow::setReversingMode(ReversingMode m)
void QmlEaseFollowPrivate::restart()
{
+ if (!enabled)
+ return;
+
initialValue = target.read().toReal();
if (source == initialValue) {
@@ -382,6 +386,26 @@ void QmlEaseFollow::setVelocity(qreal v)
d->restart();
}
+/*!
+ \qmlproperty bool EaseFollow::enabled
+ This property holds whether the target will track the source.
+*/
+bool QmlEaseFollow::enabled() const
+{
+ Q_D(const QmlEaseFollow);
+ return d->enabled;
+}
+
+void QmlEaseFollow::setEnabled(bool enabled)
+{
+ Q_D(QmlEaseFollow);
+ d->enabled = enabled;
+ if (enabled)
+ d->restart();
+ else
+ d->clockStop();
+}
+
void QmlEaseFollow::setTarget(const QmlMetaProperty &t)
{
Q_D(QmlEaseFollow);