summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-07-01 05:52:50 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-07-01 05:52:50 (GMT)
commitf1b6711ab742c9ab56304861f2bef01a8beecebc (patch)
tree7c919a7182f48a449e8c50bf2181b912297315a0 /src/declarative/util
parent10c1e4a09d8e2fa671f5538bde5f9126954272ed (diff)
downloadQt-f1b6711ab742c9ab56304861f2bef01a8beecebc.zip
Qt-f1b6711ab742c9ab56304861f2bef01a8beecebc.tar.gz
Qt-f1b6711ab742c9ab56304861f2bef01a8beecebc.tar.bz2
Have ColorAnimation select all properties of type QColor by default.
This allows you to write ColorAnimation {} in a transition and all colors that are changing will be handled by default.
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qmlanimation.cpp11
-rw-r--r--src/declarative/util/qmlanimation_p.h4
2 files changed, 11 insertions, 4 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 0c8f55f..6ad47f5 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -709,6 +709,10 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation()
\code
ColorAnimation { from: "white"; to: "#c0c0c0"; duration: 100 }
\endcode
+
+ When used in a transition, ColorAnimation will by default animate
+ all properties of type color that are changing. If a property or properties
+ are explicity set for the animation, then those will be used instead.
*/
/*!
\internal
@@ -728,6 +732,7 @@ QmlColorAnimation::QmlColorAnimation(QObject *parent)
d->init();
d->interpolatorType = QMetaType::QColor;
d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+ d->defaultToInterpolatorType = true;
}
QmlColorAnimation::~QmlColorAnimation()
@@ -1828,8 +1833,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
if (!d->propertyName.isEmpty() && !props.contains(d->propertyName))
props.append(d->propertyName);
- /* ### we used to select properties of name 'color' by default for color animations
- props << QLatin1String("color");*/
+ bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false;
if (d->userProperty.isValid() && props.isEmpty() && !target()) {
props.append(d->userProperty.value.name());
@@ -1853,7 +1857,8 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) &&
(!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
- (props.contains(propertyName) || (!same && props.contains(sPropertyName))) &&
+ (props.contains(propertyName) || (!same && props.contains(sPropertyName))
+ || (useType && action.property.propertyType() == d->interpolatorType)) &&
(!target() || target() == obj || (!same && target() == sObj))) {
objs.insert(obj);
Action myAction = action;
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 051516d..fce5eca 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -319,7 +319,8 @@ class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate
public:
QmlPropertyAnimationPrivate()
: QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- interpolatorType(0), interpolator(0), va(0), value(this, &QmlPropertyAnimationPrivate::valueChanged) {}
+ defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0),
+ value(this, &QmlPropertyAnimationPrivate::valueChanged) {}
void init();
@@ -335,6 +336,7 @@ public:
bool fromSourced;
bool fromIsDefined;
bool toIsDefined;
+ bool defaultToInterpolatorType;
int interpolatorType;
QVariantAnimation::Interpolator interpolator;