summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-11-06 05:34:03 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-11-06 05:34:03 (GMT)
commit43d005442b66612bc4a16362c09a3e31f519d46c (patch)
treeb54858ca861a555947bb172721e7f6fa416e39a7
parent8d8315df292482d75148a435b9e2bcc4636c57a3 (diff)
parent3a051866fb139afa08fcf1a0c17a171bce567480 (diff)
downloadQt-43d005442b66612bc4a16362c09a3e31f519d46c.zip
Qt-43d005442b66612bc4a16362c09a3e31f519d46c.tar.gz
Qt-43d005442b66612bc4a16362c09a3e31f519d46c.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--doc/src/declarative/animation.qdoc76
-rw-r--r--doc/src/declarative/elements.qdoc3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.cpp11
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp6
-rw-r--r--src/declarative/util/qmlanimation.cpp18
-rw-r--r--tests/auto/declarative/qmlgraphicsitem/data/keynavigation.qml39
-rw-r--r--tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp3
-rw-r--r--tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp55
9 files changed, 190 insertions, 29 deletions
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index ba45d81..1314493 100644
--- a/doc/src/declarative/animation.qdoc
+++ b/doc/src/declarative/animation.qdoc
@@ -81,6 +81,22 @@ Rectangle {
\image propanim.gif
+When you assign an animation as a value source, you do not need to specify \c property
+or \c target; they are automatically selected for you. You do, however, need to specify \c to, and explicitly
+start the animation (usually via the \c running property).
+
+\qml
+Rectangle {
+ id: rect
+ width: 200; height: 200;
+ Rectangle {
+ color: "red"
+ width: 50; height: 50
+ x: NumberAnimation { to: 50; running: true }
+ }
+}
+\endqml
+
A property animation can also be specified as a resource that is manipulated from script.
\qml
@@ -100,12 +116,16 @@ Image {
}
\endqml
+As can be seen, when an animation is used like this (as opposed to as a value source) you will need
+to explicitly set the \c target and \c property to animate.
+
Animations can be joined into a group using SequentialAnimation and ParallelAnimation.
\target state-transitions
\section1 Transitions
-QML transitions describe animations to perform when \l{qmlstates}{state} changes occur.
+QML transitions describe animations to perform when \l{qmlstates}{state} changes occur. A transition
+can only be triggered by a state change.
For example, a transition could describe how an item moves from its initial position to its new position:
@@ -123,11 +143,11 @@ transitions: [
As you can see from the above example, transitions make use of the same basic animation classes introduced
above. However, you generally use a different set of properties when working with transitions. In the example,
-no target or property has been specified. Instead, we have specified matchProperties, which acts as a selector to
-determine which property changes to animate; in this case, we will animate any x,y properties that have
-changed on any objects.
+no \c target or \c property has been specified. Instead, we have specified \c matchProperties,
+which (along with \c matchTargets) acts as a selector to determine which property changes to animate;
+in this case, we will animate any x,y properties that have changed on any objects.
-QML transitions also selectors to determine which state changes a transition should apply to:
+QML transitions also have selectors to determine which state changes a transition should apply to:
\code
Transition {
@@ -137,7 +157,9 @@ Transition {
}
\endcode
-Transitions can happen in parallel, in sequence, or in any combination of the two:
+Transitions can happen in parallel, in sequence, or in any combination of the two. By default, the top-level
+animations in a transition will happen in parallel. The following example shows a rather complex transition
+making use of both sequential and parallel animations:
\code
Transition {
@@ -145,13 +167,8 @@ Transition {
to: "MyState"
reversible: true
SequentialAnimation {
- ColorAnimation {
- property: "color"
- duration: 1000
- }
- PauseAnimation {
- duration: 1000
- }
+ ColorAnimation { duration: 1000 }
+ PauseAnimation { duration: 1000 }
ParallelAnimation {
NumberAnimation {
duration: 1000
@@ -169,9 +186,37 @@ Transition {
}
\endcode
+To insert an explicit animation into your transition, you can use \target and \property as normal.
+
+\code
+Transition {
+ from: "*"
+ to: "MyState"
+ reversible: true
+ SequentialAnimation {
+ NumberAnimation {
+ duration: 1000
+ easing: "easeOutBounce"
+ // animate myItem's x and y if they have changed in the state
+ matchTargets: myItem
+ matchProperties: "x,y"
+ }
+ NumberAnimation {
+ duration: 1000
+ // animate myItem2's y to 200, regardless of what happens in the state
+ target: myItem2
+ property: "y"
+ to: 200
+ }
+ }
+}
+\endcode
+
\section1 Property Behaviors
-A property behavior specifies a default animation to run whenever the property's value changes.
+A property behavior specifies a default animation to run whenever the property's value changes, regardless
+of what caused the change. Unlike Transition, Behavior doesn't provide a way to indicate that a Behavior
+should only apply under certain circumstances.
In the following snippet, we specify that we want the x position of redRect to be animated
whenever it changes. The animation will last 300 milliseconds and use an InOutQuad easing curve.
@@ -185,6 +230,9 @@ Rectangle {
}
\endqml
+Like using an animation as a value source, when used in a Behavior and animation does not need to specify
+a \c target or \c property.
+
To trigger this behavior, we could:
\list
\o Enter a state that changes x
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index 69535ce..81a6c96 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -187,11 +187,8 @@ The following table lists the QML elements provided by the Qt Declarative module
\list
\o \l Blur
\o \l Colorize
-\o \l Grayscale
-\o \l Pixelize
\o \l DropShadow
\o \l Opacity
-\o \l Bloom
\o \l Particles
\list
\o \l ParticleMotionLinear
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index 7427266..f39f5c7 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -1154,7 +1154,7 @@ void QmlGraphicsGridView::keyPressEvent(QKeyEvent *event)
}
/*!
- \qmlmethod GridView::moveCurrentIndexUp
+ \qmlmethod GridView::moveCurrentIndexUp()
Move the currentIndex up one item in the view.
The current index will wrap if keyNavigationWraps is true and it
@@ -1177,7 +1177,7 @@ void QmlGraphicsGridView::moveCurrentIndexUp()
}
/*!
- \qmlmethod GridView::moveCurrentIndexDown
+ \qmlmethod GridView::moveCurrentIndexDown()
Move the currentIndex down one item in the view.
The current index will wrap if keyNavigationWraps is true and it
@@ -1200,7 +1200,7 @@ void QmlGraphicsGridView::moveCurrentIndexDown()
}
/*!
- \qmlmethod GridView::moveCurrentIndexLeft
+ \qmlmethod GridView::moveCurrentIndexLeft()
Move the currentIndex left one item in the view.
The current index will wrap if keyNavigationWraps is true and it
@@ -1223,7 +1223,7 @@ void QmlGraphicsGridView::moveCurrentIndexLeft()
}
/*!
- \qmlmethod GridView::moveCurrentIndexRight
+ \qmlmethod GridView::moveCurrentIndexRight()
Move the currentIndex right one item in the view.
The current index will wrap if keyNavigationWraps is true and it
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
index a46c2be..572aa98 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
@@ -1908,6 +1908,17 @@ void QmlGraphicsItem::setClip(bool c)
*/
/*!
+ \qmlproperty bool Item::visible
+
+ Whether the item is visible. By default this is true.
+
+ \note visible is not linked to actual visibility; if you item
+ goes off screen, or the opacity changes to 0, etc this will
+ not affect the visible property.
+*/
+
+
+/*!
This function is called to handle this item's changes in
geometry from \a oldGeometry to \a newGeometry. If the two
geometries are the same, it doesn't do anything.
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
index 196cdf2..22c2c0a 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
@@ -146,19 +146,19 @@ void QmlGraphicsDrag::setYmax(qreal m)
*/
/*!
- \qmlsignal MouseRegion::onEntered
+ \qmlsignal MouseRegion::onEntered()
This handler is called when the mouse enters the mouse region.
*/
/*!
- \qmlsignal MouseRegion::onExited
+ \qmlsignal MouseRegion::onExited()
This handler is called when the mouse exists the mouse region.
*/
/*!
- \qmlsignal MouseRegion::onPositionChanged(mouse)
+ \qmlsignal MouseRegion::onPositionChanged(MouseEvent mouse)
This handler is called when the mouse position changes.
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 7c5bc50..94cdadf 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -1507,6 +1507,8 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
\code
VariantAnimation { property: "size"; to: "20x20"; duration: 200 }
\endcode
+
+ \a qmlanimation.html
*/
QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent)
@@ -1795,16 +1797,20 @@ void QmlPropertyAnimation::setEasing(const QString &e)
\qmlproperty Object PropertyAnimation::target
This property holds an explicit target object to animate.
- The exact effect of the \c target property depends on how the animation
- is being used. Refer to the \l animation documentation for details.
+ target is used in conjunction with property to determine
+ what property should be animated.
+
+ \sa property matchTargets
*/
/*!
\qmlproperty string PropertyAnimation::property
- This property holds an explicit property to animated.
+ This property holds an explicit property name to animate.
- The exact effect of the \c property property depends on how the animation
- is being used. Refer to the \l animation documentation for details.
+ property is used in conjunction with target to determine
+ what property should be animated.
+
+ \sa target matchProperties
*/
/*!
@@ -1833,6 +1839,8 @@ void QmlPropertyAnimation::setEasing(const QString &e)
This property is typically used for an animation appearing as part of a Transition.
By default, no property names will be matched.
+
+ \sa matchTargets PropertyAction::matchTargets
*/
QString QmlPropertyAnimation::properties() const
{
diff --git a/tests/auto/declarative/qmlgraphicsitem/data/keynavigation.qml b/tests/auto/declarative/qmlgraphicsitem/data/keynavigation.qml
new file mode 100644
index 0000000..9281a17
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsitem/data/keynavigation.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Grid {
+ columns: 2
+ width: 100; height: 100
+ Rectangle {
+ id: item1
+ objectName: "item1"
+ focus: true
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.right: item2
+ KeyNavigation.down: item3
+ }
+ Rectangle {
+ id: item2
+ objectName: "item2"
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.left: item1
+ KeyNavigation.down: item4
+ }
+ Rectangle {
+ id: item3
+ objectName: "item3"
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.right: item4
+ KeyNavigation.up: item1
+ }
+ Rectangle {
+ id: item4
+ objectName: "item4"
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.left: item3
+ KeyNavigation.up: item2
+ }
+}
diff --git a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp
index b3b5374..b4b3eaf 100644
--- a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp
+++ b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp
@@ -213,6 +213,9 @@ void tst_QmlGraphicsItem::keyNavigation()
template<typename T>
T *tst_QmlGraphicsItem::findItem(QmlGraphicsItem *parent, const QString &objectName)
{
+ if (!parent)
+ return 0;
+
const QMetaObject &mo = T::staticMetaObject;
//qDebug() << parent->QGraphicsObject::children().count() << "children";
for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) {
diff --git a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
index 2a3cdde..1e10873 100644
--- a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
+++ b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
@@ -45,6 +45,7 @@
#include <private/qmlgraphicstext_p.h>
#include <private/qmlvaluetype_p.h>
#include <QFontMetrics>
+#include <QGraphicsSceneMouseEvent>
#include <math.h>
class tst_qmlgraphicstext : public QObject
@@ -78,6 +79,8 @@ private slots:
void letterSpacing();
void wordSpacing();
+ void clickLink();
+
private:
QStringList standard;
QStringList richText;
@@ -258,6 +261,10 @@ void tst_qmlgraphicstext::wrap()
QVERIFY(textObject != 0);
QCOMPARE(textObject->width(), 30.);
QVERIFY(textObject->height() > textHeight);
+
+ int oldHeight = textObject->height();
+ textObject->setWidth(100);
+ QVERIFY(textObject->height() < oldHeight);
}
for (int i = 0; i < richText.size(); i++)
@@ -730,6 +737,54 @@ void tst_qmlgraphicstext::wordSpacing()
}
}
+class EventSender : public QGraphicsItem
+{
+public:
+ void sendEvent(QEvent *event) { sceneEvent(event); }
+};
+
+class LinkTest : public QObject
+{
+ Q_OBJECT
+public:
+ LinkTest() {}
+
+ QString link;
+
+public slots:
+ void linkClicked(QString l) { link = l; }
+};
+
+void tst_qmlgraphicstext::clickLink()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"<a href=\\\"http://qt.nokia.com\\\">Hello world!</a>\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
+ QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+
+ LinkTest test;
+ QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString)));
+
+ {
+ QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress);
+ me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
+ me.setButton(Qt::LeftButton);
+ static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
+ }
+
+ {
+ QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseRelease);
+ me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
+ me.setButton(Qt::LeftButton);
+ static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
+ }
+
+ QCOMPARE(test.link, QLatin1String("http://qt.nokia.com"));
+ }
+}
+
QTEST_MAIN(tst_qmlgraphicstext)
#include "tst_qmlgraphicstext.moc"