From a6f90ca4d73365d37bdc4eaf8fe15cf55fe1bf83 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 1 Feb 2010 13:23:16 +1000 Subject: Support animating attached properties. Task-number: QTBUG-5580 --- src/declarative/util/qmlanimation.cpp | 2 +- .../auto/declarative/animations/data/attached.qml | 34 ++++++++++++++++++++++ .../auto/declarative/animations/tst_animations.cpp | 12 ++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/animations/data/attached.qml diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index efb4159..63044bc 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -223,7 +223,7 @@ void QmlAbstractAnimationPrivate::commence() QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj) { - QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str); + QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str, qmlContext(infoObj)); if (!prop.isValid()) { qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate non-existant property \"%1\"").arg(str); return QmlMetaProperty(); diff --git a/tests/auto/declarative/animations/data/attached.qml b/tests/auto/declarative/animations/data/attached.qml new file mode 100644 index 0000000..0fb6f8c --- /dev/null +++ b/tests/auto/declarative/animations/data/attached.qml @@ -0,0 +1,34 @@ +import Qt 4.6 + +Rectangle { + width: 180; height: 200; + + Component { + id: delegate + Rectangle { + id: wrapper + width: 180; height: 200 + color: "blue" + + states: State { + name: "otherState" + PropertyChanges { target: wrapper; color: "green" } + } + + transitions: Transition { + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } + ScriptAction { script: console.log(ListView.delayRemove ? "on" : "off") } + } + + Component.onCompleted: { + console.log(ListView.delayRemove ? "on" : "off"); + wrapper.state = "otherState" + } + } + } + + ListView { + model: 1 + delegate: delegate + } +} diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp index 35eae73..7f043ba 100644 --- a/tests/auto/declarative/animations/tst_animations.cpp +++ b/tests/auto/declarative/animations/tst_animations.cpp @@ -67,6 +67,7 @@ private slots: void propertiesTransition(); void easingStringConversion(); void invalidDuration(); + void attached(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -563,6 +564,17 @@ void tst_animations::invalidDuration() QCOMPARE(pauseAnimation->duration(), 250); } +void tst_animations::attached() +{ + QmlEngine engine; + + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/attached.qml")); + QTest::ignoreMessage(QtDebugMsg, "off"); + QTest::ignoreMessage(QtDebugMsg, "on"); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); +} + QTEST_MAIN(tst_animations) #include "tst_animations.moc" -- cgit v0.12