diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-06-12 00:56:38 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-06-12 00:56:38 (GMT) |
commit | e0d86a3b3da044c565a34f3a66335e3e977e1d63 (patch) | |
tree | 6290d53bb45464fa00d284a333fcbe44624156ae /src/declarative/util/qmlanimation.cpp | |
parent | 1c0529462067e5ae91199ff51ced56fd40244b36 (diff) | |
download | Qt-e0d86a3b3da044c565a34f3a66335e3e977e1d63.zip Qt-e0d86a3b3da044c565a34f3a66335e3e977e1d63.tar.gz Qt-e0d86a3b3da044c565a34f3a66335e3e977e1d63.tar.bz2 |
Behavior fixes.
You can now write x: Behavior { NumericAnimation { duration: 500 } },
rather than having to specify the target and property for the animation
explicitly. Also other minor fixes.
Diffstat (limited to 'src/declarative/util/qmlanimation.cpp')
-rw-r--r-- | src/declarative/util/qmlanimation.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index d4aea81..7df249e 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1168,12 +1168,17 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions, } }; - QStringList props = d->properties.split(QLatin1Char(',')); + QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); for (int ii = 0; ii < props.count(); ++ii) props[ii] = props.at(ii).trimmed(); if (!d->propertyName.isEmpty() && !props.contains(d->propertyName)) props.append(d->propertyName); + if (d->userProperty.isValid() && props.isEmpty() && !target()) { + props.append(d->userProperty.value.name()); + d->target = d->userProperty.value.object(); + } + QmlSetPropertyAnimationAction *data = new QmlSetPropertyAnimationAction; QSet<QObject *> objs; @@ -1649,12 +1654,17 @@ void QmlNumericAnimation::transition(QmlStateActions &actions, } }; - QStringList props = d->properties.split(QLatin1Char(',')); + QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); for (int ii = 0; ii < props.count(); ++ii) props[ii] = props.at(ii).trimmed(); if (!d->propertyName.isEmpty() && !props.contains(d->propertyName)) props.append(d->propertyName); + if (d->userProperty.isValid() && props.isEmpty() && !target()) { + props.append(d->userProperty.value.name()); + d->target = d->userProperty.value.object(); + } + NTransitionData *data = new NTransitionData; QSet<QObject *> objs; @@ -1785,6 +1795,12 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions, inc = -1; from = d->animations.count() - 1; } + + //### needed for Behavior + if (d->userProperty.isValid() && d->propertyName.isEmpty() && !target()) { + for (int i = 0; i < d->animations.count(); ++i) + d->animations.at(i)->setTarget(d->userProperty); + } //XXX removing and readding isn't ideal; we do it to get around the problem mentioned below. for (int i = d->ag->animationCount()-1; i >= 0; --i) @@ -1870,6 +1886,12 @@ void QmlParallelAnimation::transition(QmlStateActions &actions, { Q_D(QmlAnimationGroup); + //### needed for Behavior + if (d->userProperty.isValid() && d->propertyName.isEmpty() && !target()) { + for (int i = 0; i < d->animations.count(); ++i) + d->animations.at(i)->setTarget(d->userProperty); + } + for (int ii = 0; ii < d->animations.count(); ++ii) { d->animations.at(ii)->transition(actions, modified, direction); } |