diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-03-25 02:09:59 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-03-25 02:12:54 (GMT) |
commit | a20828a110ad35a7a98a6234ca0013203d9f8b61 (patch) | |
tree | 9bb92d7cca2339465b79a6070584d2dca6e81c15 /src/declarative | |
parent | 4d078ed668541a4051f91b5c120b8cb0534129bd (diff) | |
download | Qt-a20828a110ad35a7a98a6234ca0013203d9f8b61.zip Qt-a20828a110ad35a7a98a6234ca0013203d9f8b61.tar.gz Qt-a20828a110ad35a7a98a6234ca0013203d9f8b61.tar.bz2 |
Qt.Infinite -> Animation.Infinite
Too misleading to have on the Qt object, as it only means infinite
for animation loops.
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/QmlChanges.txt | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativedom.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 3 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeanimation.cpp | 11 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeanimation_p.h | 3 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativespringfollow.cpp | 2 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeutilmodule.cpp | 35 |
7 files changed, 48 insertions, 12 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index b85cfb6..2a35dda 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -12,7 +12,7 @@ Using Particles now requires "import Qt.labs.particles 1.0" AnchorAnimation must now be used to animate anchor changes (and not NumberAnimation) Removed ParentAction (use ParentAnimation instead) ScriptAction: renamed stateChangeScriptName -> scriptName -Animation: replace repeat with loops (loops: Qt.Infinite gives the old repeat behavior) +Animation: replace repeat with loops (loops: Animation.Infinite gives the old repeat behavior) C++ API ------- diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp index e374a93..366750e 100644 --- a/src/declarative/qml/qdeclarativedom.cpp +++ b/src/declarative/qml/qdeclarativedom.cpp @@ -1107,7 +1107,7 @@ Rectangle { x: NumberAnimation { from: 0 to: 100 - loops: Qt.Infinite + loops: Animation.Infinite } } \endqml @@ -1155,7 +1155,7 @@ Rectangle { x: NumberAnimation { from: 0 to: 100 - loops: Qt.Infinite + loops: Animation.Infinite } } \endqml diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index b4362ce..ddbe433 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -218,9 +218,6 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr // XXX When the above a done some better way, that way should also be // XXX used to add Qt.Sound class. - //for animations that loop forever - qtObject.setProperty(QLatin1String("Infinite"), -1); - //types qtObject.setProperty(QLatin1String("rgba"), newFunction(QDeclarativeEnginePrivate::rgba, 4)); qtObject.setProperty(QLatin1String("hsla"), newFunction(QDeclarativeEnginePrivate::hsla, 4)); diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 81ab3d3..bad142c 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -309,7 +309,7 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f) By default, \c loops is 1: the animation will play through once and then stop. - If set to Qt.Infinite, the animation will continuously repeat until it is explicitly + If set to Animation.Infinite, the animation will continuously repeat until it is explicitly stopped - either by setting the \c running property to false, or by calling the \c stop() method. @@ -319,7 +319,7 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f) Rectangle { width: 100; height: 100; color: "green" RotationAnimation on rotation { - loops: Qt.Infinite + loops: Animation.Infinite from: 0 to: 360 } @@ -335,6 +335,9 @@ int QDeclarativeAbstractAnimation::loops() const void QDeclarativeAbstractAnimation::setLoops(int loops) { Q_D(QDeclarativeAbstractAnimation); + if (loops < 0) + loops = -1; + if (loops == d->loopCount) return; @@ -1598,7 +1601,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int \qml Rectangle { SequentialAnimation on x { - loops: Qt.Infinite + loops: Animation.Infinite PropertyAnimation { to: 50 } PropertyAnimation { to: 0 } } @@ -2007,7 +2010,7 @@ void QDeclarativePropertyAnimation::setProperties(const QString &prop) id: theRect width: 100; height: 100 color: Qt.rgba(0,0,1) - NumberAnimation on x { to: 500; loops: Qt.Infinite } //animate theRect's x property + NumberAnimation on x { to: 500; loops: Animation.Infinite } //animate theRect's x property Behavior on y { NumberAnimation {} } //animate theRect's y property } \endqml diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h index 2e5b87c..816520e 100644 --- a/src/declarative/util/qdeclarativeanimation_p.h +++ b/src/declarative/util/qdeclarativeanimation_p.h @@ -70,6 +70,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeAbstractAnimation : public QObject, public Q Q_INTERFACES(QDeclarativeParserStatus) Q_INTERFACES(QDeclarativePropertyValueSource) + Q_ENUMS(Loops) Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged) @@ -80,6 +81,8 @@ public: QDeclarativeAbstractAnimation(QObject *parent=0); virtual ~QDeclarativeAbstractAnimation(); + enum Loops { Infinite = -2 }; + bool isRunning() const; void setRunning(bool); bool isPaused() const; diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp index ca88b24..76d7c98 100644 --- a/src/declarative/util/qdeclarativespringfollow.cpp +++ b/src/declarative/util/qdeclarativespringfollow.cpp @@ -224,7 +224,7 @@ void QDeclarativeSpringFollowPrivate::stop() color: "#00ff00" y: 200 // initial value SequentialAnimation on y { - loops: Qt.Infinite + loops: Animation.Infinite NumberAnimation { to: 200 easing.type: "OutBounce" diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp index 46c9b73..d79c6ba 100644 --- a/src/declarative/util/qdeclarativeutilmodule.cpp +++ b/src/declarative/util/qdeclarativeutilmodule.cpp @@ -71,6 +71,38 @@ #include "qdeclarativexmllistmodel_p.h" #endif +template<typename T> +int qmlRegisterTypeEnums(const char *qmlName) +{ + QByteArray name(T::staticMetaObject.className()); + + QByteArray pointerName(name + '*'); + QByteArray listName("QDeclarativeListProperty<" + name + ">"); + + QDeclarativePrivate::RegisterType type = { + 0, + + qRegisterMetaType<T *>(pointerName.constData()), + qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()), + 0, 0, + + "Qt", 4, 6, qmlName, &T::staticMetaObject, + + QDeclarativePrivate::attachedPropertiesFunc<T>(), + QDeclarativePrivate::attachedPropertiesMetaObject<T>(), + + QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(), + QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(), + QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(), + + 0, 0, + + 0 + }; + + return QDeclarativePrivate::registerType(type); +} + void QDeclarativeUtilModule::defineModule() { qmlRegisterType<QDeclarativeAnchorAnimation>("Qt",4,6,"AnchorAnimation"); @@ -107,9 +139,10 @@ void QDeclarativeUtilModule::defineModule() #endif qmlRegisterType<QDeclarativeAnchors>(); - qmlRegisterType<QDeclarativeAbstractAnimation>(); qmlRegisterType<QDeclarativeStateOperation>(); + qmlRegisterTypeEnums<QDeclarativeAbstractAnimation>("Animation"); + qmlRegisterCustomType<QDeclarativeListModel>("Qt", 4,6, "ListModel", "QDeclarativeListModel", new QDeclarativeListModelParser); qmlRegisterCustomType<QDeclarativePropertyChanges>("Qt", 4, 6, "PropertyChanges", "QDeclarativePropertyChanges", |