diff options
author | Bea Lam <bea.lam@nokia.com> | 2009-11-24 02:58:40 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2009-11-24 02:58:40 (GMT) |
commit | 635dc8d2746a1409e7cdd91cfa451519248715bb (patch) | |
tree | d6c742e0e80ce69d72e42c881b65b4e7a82e2129 | |
parent | e111b77a1c1a02c3508db4981ae7daf4730f23dd (diff) | |
parent | 3d2b0d622908fe2c89ac1c2d5a5cb7ed96a24b6a (diff) | |
download | Qt-635dc8d2746a1409e7cdd91cfa451519248715bb.zip Qt-635dc8d2746a1409e7cdd91cfa451519248715bb.tar.gz Qt-635dc8d2746a1409e7cdd91cfa451519248715bb.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
25 files changed, 437 insertions, 112 deletions
diff --git a/doc/src/declarative/advtutorial1.qdoc b/doc/src/declarative/advtutorial1.qdoc index a96485c..86d14ad 100644 --- a/doc/src/declarative/advtutorial1.qdoc +++ b/doc/src/declarative/advtutorial1.qdoc @@ -41,7 +41,6 @@ /*! \page advtutorial1.html -\example declarative/tutorials/samegame/samegame1 \title Advanced Tutorial 1 - Creating the Game Canvas and Blocks The first step is to create the items in your application. In Same Game we have a main game screen and the blocks that populate it. diff --git a/doc/src/declarative/advtutorial2.qdoc b/doc/src/declarative/advtutorial2.qdoc index 9fab289..40a760d 100644 --- a/doc/src/declarative/advtutorial2.qdoc +++ b/doc/src/declarative/advtutorial2.qdoc @@ -41,7 +41,6 @@ /*! \page advtutorial2.html -\example declarative/tutorials/samegame/samegame2 \title Advanced Tutorial 2 - Populating the Game Canvas Now that we've written some basic elements, let's start writing the game. The diff --git a/doc/src/declarative/advtutorial3.qdoc b/doc/src/declarative/advtutorial3.qdoc index 5ac1be3..e6e4e97 100644 --- a/doc/src/declarative/advtutorial3.qdoc +++ b/doc/src/declarative/advtutorial3.qdoc @@ -41,7 +41,6 @@ /*! \page advtutorial3.html -\example declarative/tutorials/samegame/samegame3 \title Advanced Tutorial 3 - Implementing the Game Logic First we add to the \c initBoard function clearing of the board before filling it up again, so that clicking new game won't leave the previous game diff --git a/doc/src/declarative/advtutorial4.qdoc b/doc/src/declarative/advtutorial4.qdoc index 2599e32..aaa7293 100644 --- a/doc/src/declarative/advtutorial4.qdoc +++ b/doc/src/declarative/advtutorial4.qdoc @@ -41,7 +41,6 @@ /*! \page advtutorial4.html -\example declarative/tutorials/samegame/samegame4 \title Advanced Tutorial 4 - Finishing Touches Now we're going to do two things to liven the game up. Animate the blocks and add a web-based high score system. diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index 1314493..d05a444 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -186,7 +186,7 @@ Transition { } \endcode -To insert an explicit animation into your transition, you can use \target and \property as normal. +To insert an explicit animation into your transition, you can use \c target and \c property as normal. \code Transition { @@ -214,8 +214,8 @@ Transition { \section1 Property Behaviors -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 +A \l{Behavior}{property behavior} specifies a default animation to run whenever the property's value changes, regardless +of what caused the change. Unlike Transition, \l 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 diff --git a/doc/src/declarative/example-slideswitch.qdoc b/doc/src/declarative/example-slideswitch.qdoc new file mode 100644 index 0000000..c942918 --- /dev/null +++ b/doc/src/declarative/example-slideswitch.qdoc @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qmlexampletoggleswitch.html +\title QML Example - Toggle Switch + +This example shows how to create a reusable switch component in QML. + +The code for this example can be found in the \c $QTDIR/examples/declarative/slideswitch directory. + +\section1 Overview + +The elements that composed the switch are: + +\list +\o a \c on property (the interface to interact with the switch), +\o two images (the background image and the knob), +\o two mouse regions for user interation (on the background image and on the knob), +\o two states (a \e on state and a \e off state), +\o two functions or slots to react to the user interation (\c toggle() and \c dorelease()), +\o and a transition that describe how to go from one state to the other. +\endlist + +\section1 Switch.qml +\snippet examples/declarative/slideswitch/content/Switch.qml 0 + +\section1 Walkthrough + +\section2 Interface +\snippet examples/declarative/slideswitch/content/Switch.qml 1 + +This property is the interface of the switch. By default, the switch is off and this property is \c false. +It can be used to activate/disactivate the switch or to query its current state. + +In this example: + +\qml +Switch { id: mySwitch; on: true } +Text { text: "The switch is on"; visible: mySwitch.on == true } +\endqml + +the text will only be visible when the switch is on. + +\section2 Images and user interaction +\snippet examples/declarative/slideswitch/content/Switch.qml 4 + +First, we create the background image of the switch. +In order for the switch to toggle when the user clicks on the background, we add a \l{MouseRegion} as a child item of the image. +A \c MouseRegion has a \c onClicked property that is triggered when the item is clicked. For the moment we will just call a +\c toggle() function. We will see what this function does in a moment. + +\snippet examples/declarative/slideswitch/content/Switch.qml 5 + +Then, we place the image of the knob on top of the background. +The interaction here is a little more complex. We want the knob to move with the finger when it is clicked. That is what the \c drag +property of the \c MouseRegion is for. We also want to toggle the switch if the knob is released between state. We handle this case +in the \c dorelease() function that is called in the \c onReleased property. + +\section2 States +\snippet examples/declarative/slideswitch/content/Switch.qml 6 + +We define the two states of the switch: +\list +\o In the \e on state the knob is on the right (\c x position is 78) and the \c on property is \c true. +\o In the \e off state the knob is on the left (\c x position is 1) and the \c on property is \c false. +\endlist + +For more information on states see \l{qmlstates}{QML States}. + +\section2 Functions + +We add two ECMAScript functions to our switch: + +\snippet examples/declarative/slideswitch/content/Switch.qml 2 + +This first function is called when the background image or the knob are clicked. We simply want the switch to toggle between the two +states (\e on and \e off). + + +\snippet examples/declarative/slideswitch/content/Switch.qml 3 + +This second function is called when the knob is released and we want to make sure that the knob does not end up between states +(neither \e on nor \e off). If it is the case call the \c toggle() function otherwise we do nothing. + +For more information on scripts see \l{qmlecmascript.html}{ECMAScript Blocks}. + +\section2 Transition +\snippet examples/declarative/slideswitch/content/Switch.qml 7 + +At this point, when the switch toggles between the two states the knob will instantly change its \c x position between 1 and 78. +In order for the the knob to move smoothly we add a transistion that will animate the \c x property with an easing curve for a duration of 200ms. + +For more information on transitions see \l{state-transitions}{QML Transitions}. + +*/ diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index 9d66089..7950f66 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -65,47 +65,25 @@ or Many other simple examples can be found under the \c examples/declarative sub directory. Some can be run directly using the viewer like those above, and -others require you to build and run an executable. More sophisticated demos of -large applications can be found under the \c demos/declarative sub directory. -These are intended to show more integrated functionality rather than to be +others require you to build and run an executable. More sophisticated demos of +large applications can be found under the \c demos/declarative sub directory. +These are intended to show more integrated functionality rather than to be instructive on specific elements. \section1 Examples These will be documented, and demonstrate how to achieve various things in QML. -\raw HTML -<center> -<table cellspacing="10"> -<tr> -<td> -\endraw -\image dial-example.gif -\raw HTML -</td> -<td> -\endraw -\image switch-example.gif -\raw HTML -</td> -<td> -\endraw -\image declarative-adv-tutorial4.gif -\raw HTML -</td> -</tr> -<tr> -<td> -<center>Elastic Dial</center> -</td> -<td> -<center>Touch Toggle Switch</center> -</td> -<td> -<center>Samegame</center> -</td> -</table> -</center> -\endraw +\table +\row + \o Elastic Dial + \o \image dial-example.gif +\row + \o \l{qmlexampletoggleswitch.html}{Toggle Switch} + \o \image switch-example.gif +\row + \o \l{Advanced Tutorial}{SameGame} + \o \image declarative-adv-tutorial4.gif +\endtable */ diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc index a97d0d1..2487a85 100644 --- a/doc/src/declarative/qmlintro.qdoc +++ b/doc/src/declarative/qmlintro.qdoc @@ -239,8 +239,8 @@ Image { \section2 Default properties -Each object type can specify one of its list properties as its default property. -If a list property has been declared as the default property, the property tag can be omitted. +Each object type can specify one of its list or object properties as its default property. +If a property has been declared as the default property, the property tag can be omitted. For example this code: \code @@ -263,9 +263,27 @@ State { because \c changes is the default property of the \c State type. -\section2 Dot Properties +\section2 Grouped Properties +In some cases properties form a logical group and use a 'dot' or grouped notation +to show this. +Grouped properties can be written like this: +\qml +Text { + font.pixelSize: 12 + font.bold: true +} +\endqml + +or like this: +\qml +Text { + font { pixelSize: 12; bold: true } +} +\endqml + +In the element documentation grouped properties are shown using the 'dot' notation. \section2 Attached Properties \target attached-properties diff --git a/doc/src/declarative/qmlreference.qdoc b/doc/src/declarative/qmlreference.qdoc index f17e9d7..2c79aeb 100644 --- a/doc/src/declarative/qmlreference.qdoc +++ b/doc/src/declarative/qmlreference.qdoc @@ -45,16 +45,22 @@ \target qtdeclarativemainpage - QML is a language for building highly dynamic and fluid applications. It is targetted at the sorts of user - interface (and the sorts of hardware) in embedded devices such as phones, media - players, and set-top boxes. It is also appropriate for highly custom desktop + QML is a language for building the animation rich, + highly fluid user interfaces that are becoming common in portable consumer + electronics devices such as mobile phones, media players, set-top boxes and + netbooks. It is also appropriate for highly custom desktop user interfaces, or special elements in more traditional desktop user interfaces. Building fluid applications is done declaratively, rather than procedurally. That is, you specify \e what the UI should look like and how it should behave rather than specifying step-by-step \e how to build it. Specifying a UI declaratively does not just include the layout of the interface items, but also the way each - individual item looks and behaves and the overall flow of the application. + individual item looks and behaves and the overall flow of the application. + + The QML elements provide a sophisticated set of graphical and behavioral building + blocks. These different elements are combined together in \l {QML Documents}{QML documents} to build components + ranging in complexity from simple buttons and sliders, to complete + internet-enabled applications like a \l {http://www.flickr.com}{Flickr} photo browser. Getting Started: \list @@ -69,6 +75,7 @@ \o \l {QML Documents} \o \l {Property Binding} \o \l {ECMAScript Blocks} + \o \l {QML Scope} \o \l {Network Transparency} \o \l {qmlmodels}{Data Models} \o \l {anchor-layout}{Anchor-based Layout} @@ -82,5 +89,6 @@ QML Reference: \list \o \l {elements}{QML Elements} + \o \l {QML Global Object} \endlist */ diff --git a/doc/src/declarative/qmlstates.qdoc b/doc/src/declarative/qmlstates.qdoc index 261e3f5..ddb0fc8 100644 --- a/doc/src/declarative/qmlstates.qdoc +++ b/doc/src/declarative/qmlstates.qdoc @@ -3,7 +3,7 @@ \target qmlstates \title QML States -QML states describe user interface configurations, including: +QML states typically describe user interface configurations, including: \list \o What UI elements are present \o The properties of those elements (including how they behave) @@ -52,7 +52,7 @@ To animate state changes, you can use \l{state-transitions}{transitions}. Other things you can do in a state change: \list \o override signal handlers with PropertyChanges -\o change an item's parent with ParentChange +\o change an item's visual parent with ParentChange \o change an item's anchors with AnchorChanges \o run some script with StateChangeScript \endlist diff --git a/doc/src/declarative/qmlviewer.qdoc b/doc/src/declarative/qmlviewer.qdoc index f153df2..df96535 100644 --- a/doc/src/declarative/qmlviewer.qdoc +++ b/doc/src/declarative/qmlviewer.qdoc @@ -71,7 +71,7 @@ that is a qreal from 0 to 86400 representing the number of seconds since midnight, dummy data for this could be provided by \c dummydata/clock.qml: \code - Object { property real time: 12345 } + QtObject { property real time: 12345 } \endcode Any QML can be used in the dummy data files. You could even animate the fictional data! diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml index b65936a..29a62f7 100644 --- a/examples/declarative/slideswitch/content/Switch.qml +++ b/examples/declarative/slideswitch/content/Switch.qml @@ -1,38 +1,42 @@ +//![0] import Qt 4.6 Item { - id: mySwitch + id: toggleswitch width: background.width; height: background.height +//![1] property bool on: false +//![1] - Script { - function toggle() { - if (mySwitch.state == "On") - mySwitch.state = "Off"; - else - mySwitch.state = "On"; - } +//![2] + function toggle() { + if (toggleswitch.state == "on") + toggleswitch.state = "off"; + else toggleswitch.state = "on"; + } +//![2] - function dorelease() { - if (knob.x == 1) { - if (mySwitch.state == "Off") - return; - } - - if (knob.x == 78) { - if (mySwitch.state == "On") - return; - } - toggle(); +//![3] + function dorelease() { + if (knob.x == 1) { + if (toggleswitch.state == "off") return; + } + if (knob.x == 78) { + if (toggleswitch.state == "on") return; } + toggle(); } +//![3] +//![4] Image { id: background; source: "background.svg" MouseRegion { anchors.fill: parent; onClicked: toggle() } } +//![4] +//![5] Image { id: knob; source: "knob.svg"; x: 1; y: 2 @@ -43,21 +47,27 @@ Item { onReleased: dorelease() } } +//![5] +//![6] states: [ State { - name: "On" + name: "on" PropertyChanges { target: knob; x: 78 } - PropertyChanges { target: mySwitch; on: true } + PropertyChanges { target: toggleswitch; on: true } }, State { - name: "Off" + name: "off" PropertyChanges { target: knob; x: 1 } - PropertyChanges { target: mySwitch; on: false } + PropertyChanges { target: toggleswitch; on: false } } ] +//![6] +//![7] transitions: Transition { NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad"; duration: 200 } } +//![7] } +//![0] diff --git a/examples/declarative/tic-tac-toe/content/TicTac.qml b/examples/declarative/tic-tac-toe/content/TicTac.qml new file mode 100644 index 0000000..eb80743 --- /dev/null +++ b/examples/declarative/tic-tac-toe/content/TicTac.qml @@ -0,0 +1,20 @@ +import Qt 4.6 + +Item { + signal clicked + + states: [ + State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } }, + State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } } + ] + + Image { + id: image + anchors.centerIn: parent + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.clicked() + } +} diff --git a/examples/declarative/tic-tac-toe/content/pics/board.png b/examples/declarative/tic-tac-toe/content/pics/board.png Binary files differnew file mode 100644 index 0000000..cd85971 --- /dev/null +++ b/examples/declarative/tic-tac-toe/content/pics/board.png diff --git a/examples/declarative/tic-tac-toe/content/pics/o.png b/examples/declarative/tic-tac-toe/content/pics/o.png Binary files differnew file mode 100644 index 0000000..abc7ee0 --- /dev/null +++ b/examples/declarative/tic-tac-toe/content/pics/o.png diff --git a/examples/declarative/tic-tac-toe/content/pics/x.png b/examples/declarative/tic-tac-toe/content/pics/x.png Binary files differnew file mode 100644 index 0000000..ddc65c8 --- /dev/null +++ b/examples/declarative/tic-tac-toe/content/pics/x.png diff --git a/examples/declarative/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/tic-tac-toe/tic-tac-toe.qml new file mode 100644 index 0000000..63ee483 --- /dev/null +++ b/examples/declarative/tic-tac-toe/tic-tac-toe.qml @@ -0,0 +1,115 @@ +import Qt 4.6 +import "content" + +Item { + width: boardimage.width + height: boardimage.height + + Image { + id: boardimage + source: "content/pics/board.png" + } + + Grid { + id: board + anchors.fill: boardimage + + columns: 3 + + Repeater { + model: 9 + TicTac { + width: board.width/3 + height: board.height/3 + onClicked: { + if (!endtimer.running) { + if (!makeMove(index,"X")) + computerTurn() + } + } + } + } + + Script { + function winner() + { + for (var i=0; i<3; ++i) { + if (board.children[i].state!="" + && board.children[i].state==board.children[i+3].state + && board.children[i].state==board.children[i+6].state) + return true + + if (board.children[i*3].state!="" + && board.children[i*3].state==board.children[i*3+1].state + && board.children[i*3].state==board.children[i*3+2].state) + return true + } + + if (board.children[0].state!="" + && board.children[0].state==board.children[4].state!="" + && board.children[0].state==board.children[8].state!="") + return true + + if (board.children[2].state!="" + && board.children[2].state==board.children[4].state!="" + && board.children[2].state==board.children[6].state!="") + return true + + return false + } + + function restart() + { + // No moves left - start again + for (var i=0; i<9; ++i) + board.children[i].state = "" + } + + function makeMove(pos,player) + { + board.children[pos].state = player + if (winner()) { + win(player + " wins") + return true + } else { + return false + } + } + + function computerTurn() + { + // world's dumbest player + for (var i=0; i<9; ++i) + if (board.children[i].state == "") { + makeMove(i,"O") + return + } + restart() + } + + function win(s) + { + msg.text = s + msg.opacity = 1 + endtimer.running = true + } + } + + Timer { + id: endtimer + interval: 1600 + onTriggered: { msg.opacity = 0; restart() } + } + } + + Text { + id: msg + opacity: 0 + anchors.centerIn: parent + color: "blue" + styleColor: "white" + style: Text.Outline + font.pixelSize: 50 + font.bold: true + } +} diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp index 6f953bc..d7d725b 100644 --- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp @@ -394,7 +394,7 @@ void QmlGraphicsBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem * p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); const QmlGraphicsScaleGrid *border = d->getScaleGrid(); - QMargins margins(border->top(), border->left(), border->bottom(), border->right()); + QMargins margins(border->left(), border->top(), border->right(), border->bottom()); QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode); qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, d->pix, d->pix.rect(), margins, rules); if (d->smooth) { diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp index 28c8e4f..6a393ee 100644 --- a/src/declarative/util/qmlpropertychanges.cpp +++ b/src/declarative/util/qmlpropertychanges.cpp @@ -57,7 +57,8 @@ QT_BEGIN_NAMESPACE \brief The PropertyChanges element describes new property values for a state. PropertyChanges changes the properties of an item. It allows you to specify the property - names and values similar to how you normally would specify them for the actual item: + names and values for a state similar to how you normally would specify them for the + actual item: \code PropertyChanges { @@ -67,6 +68,20 @@ QT_BEGIN_NAMESPACE width: 48 } \endcode + + State-specific script for signal handlers can also be specified: + + \qml + PropertyChanges { + target: myMouseRegion + onClicked: doSomethingDifferent() + } + \endqml + + Changes to an Item's parent or anchors should be done using the associated change elements + (ParentChange and AnchorChanges, respectively) rather than PropertyChanges. + + \sa {qmlstate}{States} */ /*! diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index e2933b2..9727ca7 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -153,6 +153,9 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics More specifically, it will not work if the transform property has been set for any Items involved in the reparenting (defined as any Items in the common ancestor tree for the original and new parent). + + You can specify at which point in a transition you want a ParentChange to occur by + using a ParentAction. */ QML_DEFINE_TYPE(Qt,4,6,ParentChange,QmlParentChange) @@ -166,7 +169,7 @@ QmlParentChange::~QmlParentChange() } /*! - \qmlproperty Object ParentChange::target + \qmlproperty Item ParentChange::target This property holds the item to be reparented */ @@ -310,6 +313,10 @@ public: /*! \qmlclass StateChangeScript QmlStateChangeScript \brief The StateChangeScript element allows you to run a script in a state. + + The script specified will be run immediately when the state is made current. + Alternatively you can use a ScriptAction to specify at which point in the transition + you want the StateChangeScript to be run. */ QML_DEFINE_TYPE(Qt,4,6,StateChangeScript,QmlStateChangeScript) QmlStateChangeScript::QmlStateChangeScript(QObject *parent) @@ -385,8 +392,16 @@ QString QmlStateChangeScript::typeName() const \qmlclass AnchorChanges QmlAnchorChanges \brief The AnchorChanges element allows you to change the anchors of an item in a state. + In the following example we change the top and bottom anchors of an item: \snippet examples/declarative/anchors/anchor-changes.qml 0 + AnchorChanges will 'inject' \c x, \c y, \c width, and \c height changes into the transition, + so you can animate them as you would normally changes to these properties: + \qml + //animate our anchor changes + NumberAnimation { matchTargets: content; matchProperties: "x,y,width,height" } + \endqml + For more information on anchors see \l {anchor-layout}{Anchor Layouts}. */ @@ -432,8 +447,8 @@ public: }; /*! - \qmlproperty Object AnchorChanges::target - This property holds the object that the anchors to change belong to + \qmlproperty Item AnchorChanges::target + This property holds the Item whose anchors will change */ QmlAnchorChanges::QmlAnchorChanges(QObject *parent) diff --git a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp index f23c7d7..bcdfa2e 100644 --- a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp +++ b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp @@ -112,12 +112,27 @@ void tst_qmlgraphicsborderimage::noSource() delete obj; } +void tst_qmlgraphicsborderimage::imageSource_data() +{ + QTest::addColumn<QString>("source"); + QTest::addColumn<bool>("remote"); + QTest::addColumn<QString>("error"); + + QTest::newRow("local") << SRCDIR "/data/colors.png" << false << ""; + QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false + << "Cannot open QUrl( \"file://" SRCDIR "/data/no-such-file.png\" ) "; + QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true + << "Network error loading QUrl( \"" SERVER_ADDR "/no-such-file.png\" ) " + "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; +} + void tst_qmlgraphicsborderimage::imageSource() { QFETCH(QString, source); - QFETCH(bool, valid); + QFETCH(bool, remote); + QFETCH(QString, error); - bool remote = source.startsWith("http"); TestHTTPServer *server = 0; if (remote) { server = new TestHTTPServer(SERVER_PORT); @@ -125,6 +140,9 @@ void tst_qmlgraphicsborderimage::imageSource() server->serveDirectory(SRCDIR "/data"); } + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }"; QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); @@ -135,7 +153,7 @@ void tst_qmlgraphicsborderimage::imageSource() QCOMPARE(obj->source(), remote ? source : QUrl::fromLocalFile(source)); - if (valid) { + if (error.isEmpty()) { TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Ready); QCOMPARE(obj->width(), 120.); QCOMPARE(obj->height(), 120.); @@ -168,17 +186,6 @@ void tst_qmlgraphicsborderimage::clearSource() QCOMPARE(obj->height(), 0.); } -void tst_qmlgraphicsborderimage::imageSource_data() -{ - QTest::addColumn<QString>("source"); - QTest::addColumn<bool>("valid"); - - QTest::newRow("local") << SRCDIR "/data/colors.png" << true; - QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false; - QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << false; -} - void tst_qmlgraphicsborderimage::resized() { QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }"; @@ -290,6 +297,9 @@ void tst_qmlgraphicsborderimage::sciSource_data() void tst_qmlgraphicsborderimage::invalidSciFile() { + QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Roun" + QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Repea" + QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/invalid.sci\"; width: 300; height: 300 }"; QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml index cf98dd9..3e08359 100644 --- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml +++ b/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml @@ -8,7 +8,7 @@ Flickable { id: row Repeater { model: 4 - Rectangle { width: 200; height: 300; color: dayColor } + Rectangle { width: 200; height: 300; color: "blue" } } } } diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml index 001bf2f..3ed173d 100644 --- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml +++ b/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml @@ -8,7 +8,7 @@ Flickable { id: column Repeater { model: 4 - Rectangle { width: 200; height: 300; color: dayColor } + Rectangle { width: 200; height: 300; color: "blue" } } } } diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml index 5a27869..1425d85 100644 --- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml +++ b/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml @@ -10,7 +10,7 @@ Flickable { id: column Repeater { model: 4 - Rectangle { width: 200; height: 300; color: dayColor } + Rectangle { width: 200; height: 300; color: "blue" } } } } diff --git a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp index 5ce5faf..784ad42 100644 --- a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp +++ b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp @@ -106,11 +106,26 @@ void tst_qmlgraphicsimage::noSource() delete obj; } +void tst_qmlgraphicsimage::imageSource_data() +{ + QTest::addColumn<QString>("source"); + QTest::addColumn<bool>("remote"); + QTest::addColumn<QString>("error"); + + QTest::newRow("local") << SRCDIR "/data/colors.png" << false << ""; + QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false + << "Cannot open QUrl( \"file://" SRCDIR "/data/no-such-file.png\" ) "; + QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true + << "Network error loading QUrl( \"" SERVER_ADDR "/no-such-file.png\" ) " + "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; +} + void tst_qmlgraphicsimage::imageSource() { QFETCH(QString, source); QFETCH(bool, remote); - QFETCH(bool, valid); + QFETCH(QString, error); TestHTTPServer server(SERVER_PORT); if (remote) { @@ -118,6 +133,9 @@ void tst_qmlgraphicsimage::imageSource() server.serveDirectory(SRCDIR "/data"); } + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }"; QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create()); @@ -128,7 +146,7 @@ void tst_qmlgraphicsimage::imageSource() QCOMPARE(obj->source(), remote ? source : QUrl::fromLocalFile(source)); - if (valid) { + if (error.isEmpty()) { TRY_WAIT(obj->status() == QmlGraphicsImage::Ready); QCOMPARE(obj->width(), 120.); QCOMPARE(obj->height(), 120.); @@ -162,18 +180,6 @@ void tst_qmlgraphicsimage::clearSource() QCOMPARE(obj->progress(), 0.0); } -void tst_qmlgraphicsimage::imageSource_data() -{ - QTest::addColumn<QString>("source"); - QTest::addColumn<bool>("remote"); - QTest::addColumn<bool>("valid"); - - QTest::newRow("local") << SRCDIR "/data/colors.png" << false << true; - QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false << false; - QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << true; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << false; -} - void tst_qmlgraphicsimage::resized() { QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }"; |