diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-23 01:03:48 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-23 01:03:48 (GMT) |
commit | 0c412288e68aeccf9d17012b3fee944e99330e25 (patch) | |
tree | 3d7ce941071218506dcc3c63606bc13a7152c928 /src/declarative/util | |
parent | 3b1ec46d388cc1404522730b27ee711ffa888520 (diff) | |
download | Qt-0c412288e68aeccf9d17012b3fee944e99330e25.zip Qt-0c412288e68aeccf9d17012b3fee944e99330e25.tar.gz Qt-0c412288e68aeccf9d17012b3fee944e99330e25.tar.bz2 |
Add NOTIFY signals to EaseFollow
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qmleasefollow.cpp | 28 | ||||
-rw-r--r-- | src/declarative/util/qmleasefollow.h | 17 |
2 files changed, 39 insertions, 6 deletions
diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qmleasefollow.cpp index f020395..0b00de0 100644 --- a/src/declarative/util/qmleasefollow.cpp +++ b/src/declarative/util/qmleasefollow.cpp @@ -287,13 +287,19 @@ QmlEaseFollow::ReversingMode QmlEaseFollow::reversingMode() const void QmlEaseFollow::setReversingMode(ReversingMode m) { Q_D(QmlEaseFollow); + if (d->reversingMode == m) + return; + d->reversingMode = m; + emit reversingModeChanged(); } void QmlEaseFollowPrivate::restart() { - if (!enabled) + if (!enabled || velocity == 0) { + clockStop(); return; + } initialValue = target.read().toReal(); @@ -337,9 +343,14 @@ void QmlEaseFollow::setSourceValue(qreal s) { Q_D(QmlEaseFollow); + if (d->source == s) + return; + d->source = s; d->initialVelocity = d->trackVelocity; d->restart(); + + emit sourceChanged(); } /*! @@ -358,11 +369,16 @@ qreal QmlEaseFollow::duration() const void QmlEaseFollow::setDuration(qreal v) { Q_D(QmlEaseFollow); + if (d->duration == v) + return; + d->duration = v; d->trackVelocity = 0; if (d->clock.state() == QAbstractAnimation::Running) d->restart(); + + emit durationChanged(); } qreal QmlEaseFollow::velocity() const @@ -381,11 +397,16 @@ qreal QmlEaseFollow::velocity() const void QmlEaseFollow::setVelocity(qreal v) { Q_D(QmlEaseFollow); + if (d->velocity == v) + return; + d->velocity = v; d->trackVelocity = 0; if (d->clock.state() == QAbstractAnimation::Running) d->restart(); + + emit velocityChanged(); } /*! @@ -401,11 +422,16 @@ bool QmlEaseFollow::enabled() const void QmlEaseFollow::setEnabled(bool enabled) { Q_D(QmlEaseFollow); + if (d->enabled == enabled) + return; + d->enabled = enabled; if (enabled) d->restart(); else d->clockStop(); + + emit enabledChanged(); } void QmlEaseFollow::setTarget(const QmlMetaProperty &t) diff --git a/src/declarative/util/qmleasefollow.h b/src/declarative/util/qmleasefollow.h index 8e8c59d..decc045 100644 --- a/src/declarative/util/qmleasefollow.h +++ b/src/declarative/util/qmleasefollow.h @@ -62,11 +62,11 @@ class Q_DECLARATIVE_EXPORT QmlEaseFollow : public QObject, Q_INTERFACES(QmlPropertyValueSource) Q_ENUMS(ReversingMode) - Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue) - Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity) - Q_PROPERTY(qreal duration READ duration WRITE setDuration) - Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode) - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) + Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue NOTIFY sourceChanged) + Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged) + Q_PROPERTY(qreal duration READ duration WRITE setDuration NOTIFY durationChanged) + Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged) + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) public: enum ReversingMode { Eased, Immediate, Sync }; @@ -90,6 +90,13 @@ public: void setEnabled(bool enabled); virtual void setTarget(const QmlMetaProperty &); + +signals: + void sourceChanged(); + void velocityChanged(); + void durationChanged(); + void reversingModeChanged(); + void enabledChanged(); }; QT_END_NAMESPACE |