diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-03-23 14:31:47 +0100 |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2012-03-23 14:31:47 +0100 |
commit | 0655209fdad022bd0f6eb20ce85522cb56506bf0 (patch) | |
tree | cdba0c1590655f5cb75a68cedff74f8a683db3a2 /examples | |
parent | c3babc03c99c6ca5fa210486e133eb456a405bab (diff) | |
parent | 3d8f103c2641f35e7681485102a1b59886db8934 (diff) |
Merge master into api_changes
Conflicts:
src/qml/qml/qqmlboundsignal.cpp
src/qml/qml/qqmlpropertycache.cpp
Change-Id: I5193a193fa301c0b518291645bf626a5fa07118f
Diffstat (limited to 'examples')
52 files changed, 1110 insertions, 415 deletions
diff --git a/examples/demos/samegame/content/Button.qml b/examples/demos/samegame/content/Button.qml index 2d1a993226..44da525144 100644 --- a/examples/demos/samegame/content/Button.qml +++ b/examples/demos/samegame/content/Button.qml @@ -45,6 +45,7 @@ Rectangle { id: container property string text: "Button" + property int fontSize: 24 signal clicked @@ -70,6 +71,6 @@ Rectangle { MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } Text { - id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText; font.pixelSize: 24 + id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText; font.pixelSize: container.fontSize } } diff --git a/examples/demos/samegame/content/NameInputDialog.qml b/examples/demos/samegame/content/NameInputDialog.qml index 7c3bfa274a..26101d6645 100644 --- a/examples/demos/samegame/content/NameInputDialog.qml +++ b/examples/demos/samegame/content/NameInputDialog.qml @@ -62,7 +62,7 @@ Dialog { Text { id: dialogText anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter } - text: "You won! Please enter your name: " + text: "You won! Your name: " } MouseArea { anchors.fill: parent diff --git a/examples/demos/samegame/content/samegame.js b/examples/demos/samegame/content/samegame.js index 611767584b..d530718927 100755 --- a/examples/demos/samegame/content/samegame.js +++ b/examples/demos/samegame/content/samegame.js @@ -173,7 +173,7 @@ function victoryCheck() } initHighScoreBar(); if(gameCanvas.score > highScoreBar){ - nameInputDialog.show("You won! Please enter your name: "); + nameInputDialog.show("You won! Your name: "); nameInputDialog.initialWidth = nameInputDialog.text.width + 20; if (nameInputDialog.name == "") nameInputDialog.width = nameInputDialog.initialWidth; diff --git a/examples/demos/samegame/main.cpp b/examples/demos/samegame/main.cpp new file mode 100644 index 0000000000..4a0f88ae70 --- /dev/null +++ b/examples/demos/samegame/main.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QStringList> +#include <QQuickView> +#include <QQmlEngine> + +void usage() +{ + printf("Pass -desktop to use the Desktop UI. Default is the mobile UI."); + exit(0); +} + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc,argv); + QQuickView view; + QUrl launchFile = QUrl::fromLocalFile(QLatin1String("samegame-mobile.qml")); + if (app.arguments().contains(QLatin1String("-help"))) + usage(); + if (app.arguments().contains(QLatin1String("-desktop"))) + launchFile = QUrl::fromLocalFile(QLatin1String("samegame-desktop.qml")); + view.setSource(launchFile); + view.show(); + return app.exec(); +} + diff --git a/examples/demos/samegame/samegame.qml b/examples/demos/samegame/samegame-desktop.qml index b98b6a0074..b98b6a0074 100644 --- a/examples/demos/samegame/samegame.qml +++ b/examples/demos/samegame/samegame-desktop.qml diff --git a/examples/demos/samegame/samegame-mobile.qml b/examples/demos/samegame/samegame-mobile.qml new file mode 100644 index 0000000000..04555a8f25 --- /dev/null +++ b/examples/demos/samegame/samegame-mobile.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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.1, 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" +import "content/samegame.js" as Logic + +Rectangle { + id: screen + width: 320; height: 480 + + SystemPalette { id: activePalette } + + GameArea { + id: gameCanvas + width: parent.width + blockSize: 40 + anchors { top: parent.top; bottom: toolBar.top } + } + + Rectangle { + id: toolBar + width: parent.width; height: 40 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + id: newGameButton + anchors { left: parent.left; leftMargin: 12; verticalCenter: parent.verticalCenter } + fontSize: 12 + text: "New Game" + onClicked: Logic.startNewGame(gameCanvas) + } + + Text { + id: score + anchors { right: parent.right; rightMargin: 12; verticalCenter: parent.verticalCenter } + text: "Score: " + gameCanvas.score + font.bold: true + font.pixelSize: 12 + color: activePalette.windowText + } + } +} diff --git a/examples/demos/samegame/samegame.pro b/examples/demos/samegame/samegame.pro new file mode 100644 index 0000000000..4f9a295dc4 --- /dev/null +++ b/examples/demos/samegame/samegame.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += qml +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/samegame +qml.files = samegame-desktop.qml samegame-mobile.qml content +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/samegame +INSTALLS += target qml diff --git a/examples/demos/samegame/samegame.qdoc b/examples/demos/samegame/samegame.qdoc new file mode 100644 index 0000000000..7a311600c6 --- /dev/null +++ b/examples/demos/samegame/samegame.qdoc @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \title QML Demo - SameGame + \example demos/samegame + \brief This is an example game written in QML. + \image qml-samegame-demo-small.png + + The SameGame demo implements a simple game in QML. It is written for desktop and portrait devices. + + This game has the logic implemented in Javascipt and the appearance implemented in QML. +*/ + diff --git a/examples/demos/samegame/samegame.qmlproject b/examples/demos/samegame/samegame.qmlproject index 42ffacf4f8..e0f1074913 100644 --- a/examples/demos/samegame/samegame.qmlproject +++ b/examples/demos/samegame/samegame.qmlproject @@ -1,7 +1,7 @@ import QmlProject 1.1 Project { - mainFile: "samegame.qml" + mainFile: "samegame-desktop.qml" /* Include .qml, .js, and image files from current directory and subdirectories */ QmlFiles { diff --git a/examples/declarative/accessibility/widgets/Checkbox.qml b/examples/quick/accessibility/content/Checkbox.qml index 17eb733197..17eb733197 100644 --- a/examples/declarative/accessibility/widgets/Checkbox.qml +++ b/examples/quick/accessibility/content/Checkbox.qml diff --git a/examples/declarative/accessibility/widgets/Slider.qml b/examples/quick/accessibility/content/Slider.qml index 32aa6a3a41..32aa6a3a41 100644 --- a/examples/declarative/accessibility/widgets/Slider.qml +++ b/examples/quick/accessibility/content/Slider.qml diff --git a/examples/quick/keyinteraction/keyinteraction.pro b/examples/quick/keyinteraction/keyinteraction.pro new file mode 100644 index 0000000000..890d5b1449 --- /dev/null +++ b/examples/quick/keyinteraction/keyinteraction.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +QT += quick declarative +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/keyinteraction +qml.files = keyinteraction.qml focus +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/keyinteraction +INSTALLS += target qml + diff --git a/examples/quick/keyinteraction/keyinteraction.qml b/examples/quick/keyinteraction/keyinteraction.qml new file mode 100644 index 0000000000..546ba4cf05 --- /dev/null +++ b/examples/quick/keyinteraction/keyinteraction.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../../shared" as Examples + +/*! + \title QtQuick Examples - Key Interaction + \example quick/keyinteraction + \brief This is a collection of QML keyboard interaction examples. + \image qml-keyinteraction-example.png + + This example demonstrates combining various methods of interacting with keyboard focus. +*/ + +Loader {//Just loader, since there's only one. + source: "focus/focus.qml" + focus: true + // Exception to the standard sizing, because this is primarily a desktop + // example and it benefits from being able to see everything at once. +} diff --git a/examples/quick/keyinteraction/keyinteraction.qmlproject b/examples/quick/keyinteraction/keyinteraction.qmlproject new file mode 100644 index 0000000000..e8cbc449d5 --- /dev/null +++ b/examples/quick/keyinteraction/keyinteraction.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "keyinteraction.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/keyinteraction/main.cpp b/examples/quick/keyinteraction/main.cpp new file mode 100644 index 0000000000..1c9d67ef85 --- /dev/null +++ b/examples/quick/keyinteraction/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(keyinteraction) diff --git a/examples/quick/modelviews/listview/dynamiclist.qml b/examples/quick/modelviews/listview/dynamiclist.qml index ee7c6329bc..e6d43a0d61 100644 --- a/examples/quick/modelviews/listview/dynamiclist.qml +++ b/examples/quick/modelviews/listview/dynamiclist.qml @@ -87,70 +87,84 @@ Rectangle { Item { id: delegateItem - width: listView.width; height: 55 + width: listView.width; height: 100 clip: true - Row { - anchors.verticalCenter: parent.verticalCenter - spacing: 10 - - Column { - Image { - source: "content/pics/arrow-up.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) } - } - Image { source: "content/pics/arrow-down.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) } - } + Column { + id: arrows + anchors { + left: parent.left + verticalCenter: parent.verticalCenter } - - Column { - anchors.verticalCenter: parent.verticalCenter - - Text { - text: name - font.pixelSize: 15 - color: "white" - } - Row { - spacing: 5 - Repeater { - model: attributes - Text { text: description; color: "White" } - } - } + Image { + source: "content/pics/arrow-up.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) } + } + Image { source: "content/pics/arrow-down.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) } } } - Row { - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - spacing: 10 - - PressAndHoldButton { - anchors.verticalCenter: parent.verticalCenter - source: "content/pics/plus-sign.png" - onClicked: fruitModel.setProperty(index, "cost", cost + 0.25) + Column { + anchors { + left: arrows.right + horizontalCenter: parent.horizontalCenter; + bottom: parent.verticalCenter } - Text { - id: costText - anchors.verticalCenter: parent.verticalCenter - text: '$' + Number(cost).toFixed(2) + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: name font.pixelSize: 15 color: "white" - font.bold: true } + Row { + anchors.horizontalCenter: parent.horizontalCenter + spacing: 5 + Repeater { + model: attributes + Text { text: description; color: "White" } + } + } + } - PressAndHoldButton { - anchors.verticalCenter: parent.verticalCenter - source: "content/pics/minus-sign.png" - onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) + Item { + anchors { + left: arrows.right + horizontalCenter: parent.horizontalCenter; + top: parent.verticalCenter + bottom: parent.bottom } - Image { - source: "content/pics/list-delete.png" - MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } + Row { + anchors.centerIn: parent + spacing: 10 + + PressAndHoldButton { + anchors.verticalCenter: parent.verticalCenter + source: "content/pics/plus-sign.png" + onClicked: fruitModel.setProperty(index, "cost", cost + 0.25) + } + + Text { + id: costText + anchors.verticalCenter: parent.verticalCenter + text: '$' + Number(cost).toFixed(2) + font.pixelSize: 15 + color: "white" + font.bold: true + } + + PressAndHoldButton { + anchors.verticalCenter: parent.verticalCenter + source: "content/pics/minus-sign.png" + onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) + } + + Image { + source: "content/pics/list-delete.png" + MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } + } } } @@ -174,12 +188,17 @@ Rectangle { // The view: ListView { id: listView - anchors.fill: parent; anchors.margins: 20 + anchors { + left: parent.left; top: parent.top; + right: parent.right; bottom: buttons.top; + margins: 20 + } model: fruitModel delegate: listDelegate } Row { + id: buttons anchors { left: parent.left; bottom: parent.bottom; margins: 20 } spacing: 10 diff --git a/examples/quick/modelviews/listview/highlight.qml b/examples/quick/modelviews/listview/highlight.qml index d8f76080e6..2dca1f4b18 100644 --- a/examples/quick/modelviews/listview/highlight.qml +++ b/examples/quick/modelviews/listview/highlight.qml @@ -69,6 +69,10 @@ Rectangle { transitions: Transition { NumberAnimation { properties: "x"; duration: 200 } } + MouseArea { + anchors.fill: parent + onClicked: wrapper.ListView.view.currentIndex = index + } } } diff --git a/examples/quick/modelviews/listview/highlightranges.qml b/examples/quick/modelviews/listview/highlightranges.qml index a536ddcbb2..1cf5c06f45 100644 --- a/examples/quick/modelviews/listview/highlightranges.qml +++ b/examples/quick/modelviews/listview/highlightranges.qml @@ -44,7 +44,27 @@ import "content" Rectangle { id: root property int current: 0 - width: 600; height: 300 + // Example index automation for convenience, disabled on click or tap + SequentialAnimation on current { + id: anim + loops: -1 + NumberAnimation { + duration: 5000 + to: aModel.count - 1 + } + NumberAnimation { + duration: 5000 + to: 0 + } + } + MouseArea{ + id: ma + z: 1 + anchors.fill: parent + onClicked: {ma.enabled = false; anim.running = false;} + } + + width: 320; height: 480 // This example shows the same model in three different ListView items, // with different highlight ranges. The highlight ranges are set by the @@ -72,9 +92,10 @@ Rectangle { ListView { id: list1 - width: 200; height: parent.height - model: PetsModel {} + height: 160; width: parent.width + model: PetsModel {id: aModel} delegate: petDelegate + orientation: ListView.Horizontal highlight: Rectangle { color: "lightsteelblue" } currentIndex: root.current @@ -84,10 +105,11 @@ Rectangle { ListView { id: list2 - x: list1.width - width: 200; height: parent.height + y: list1.height + height: 160; width: parent.width model: PetsModel {} delegate: petDelegate + orientation: ListView.Horizontal highlight: Rectangle { color: "yellow" } currentIndex: root.current @@ -97,10 +119,11 @@ Rectangle { ListView { id: list3 - x: list1.width + list2.width - width: 200; height: parent.height + y: list1.height + list2.height + height: 160; width: parent.width model: PetsModel {} delegate: petDelegate + orientation: ListView.Horizontal highlight: Rectangle { color: "yellow" } currentIndex: root.current @@ -112,11 +135,20 @@ Rectangle { // The delegate for each list Component { id: petDelegate - Column { - width: 200 - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } + Item { + width: 160 + height: column.height + Column { + id: column + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } + + MouseArea { + anchors.fill: parent + onClicked: wrapper.ListView.view.currentIndex = index + } } } } diff --git a/examples/quick/modelviews/main.cpp b/examples/quick/modelviews/main.cpp new file mode 100644 index 0000000000..77f0e59b34 --- /dev/null +++ b/examples/quick/modelviews/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(modelviews) diff --git a/examples/quick/modelviews/modelviews.pro b/examples/quick/modelviews/modelviews.pro index 7748da0471..59c5e231a2 100644 --- a/examples/quick/modelviews/modelviews.pro +++ b/examples/quick/modelviews/modelviews.pro @@ -1,8 +1,18 @@ -TEMPLATE = subdirs +TEMPLATE = app -SUBDIRS += \ - abstractitemmodel \ - objectlistmodel \ - stringlistmodel +QT += quick qml +SOURCES += main.cpp +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/modelviews +qml.files = \ + modelviews.qml \ + gridview \ + listview \ + package \ + parallax \ + pathview \ + visualdatamodel \ + visualitemmodel +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/modelviews +INSTALLS += target qml diff --git a/examples/quick/modelviews/modelviews.qml b/examples/quick/modelviews/modelviews.qml index f11608bcc7..ce0880c057 100644 --- a/examples/quick/modelviews/modelviews.qml +++ b/examples/quick/modelviews/modelviews.qml @@ -39,26 +39,49 @@ ****************************************************************************/ import QtQuick 2.0 -import "../../shared" +import "../../shared" as Examples + +/*! + \title QtQuick Examples - ModelViews + \example quick/modelviews + \brief This is a collection of QML drag and drop examples + \image qml-modelviews-example.png + + This is a collection of small QML examples relating to model and view functionality. + + GridView and PathView demonstrate usage of these elements to display views. + + Dynamic List demonstrates runtime modification of a ListModel. + + Expanding Delegates demonstrates delegates that expand when activated. + + Highlight demonstrates adding a custom highlight to a ListView. + + Highlight Ranges shows the three different highlight range modes of ListView. + + Sections demonstrates the various section headers and footers available to ListView. + + Packages demonstrates using Packages to transition delegates between two views. + + VisualItemModel uses a VisualItemModel for the model instead of a ListModel. +*/ Item { height: 480 - width: 480 - LauncherList { + width: 320 + Examples.LauncherList { id: ll anchors.fill: parent Component.onCompleted: { - addExample("Dynamic List", "A ListView harboring dynamic data", Qt.resolvedUrl("listview/dynamiclist.qml")); - addExample("Expanding Delegates", "Delegates that expand to fill the list when clicked", Qt.resolvedUrl("listview/expandingdelegates.qml")); - addExample("Highlight", "Adding a highlight to the current item", Qt.resolvedUrl("listview/highlight.qml")); - addExample("Sections", "A ListView with section headers", Qt.resolvedUrl("listview/sections.qml")); - addExample("GridView", "A view laid out in a grid", Qt.resolvedUrl("gridview/gridview-example.qml")); - addExample("PathView", "A view laid out along a path", Qt.resolvedUrl("pathview/pathview-example.qml")); - addExample("Package", "Using a package to transition items between views", Qt.resolvedUrl("package/view.qml")); - addExample("Parallax", "Adds a background and a parallax effect to a ListView", Qt.resolvedUrl("parallax/parallax.qml")); - addExample("Slideshow", "A model demonstrating delayed image loading", Qt.resolvedUrl("visualdatamodel/slideshow.qml")); - addExample("Sorted Model", "Two views on a model, one of which is sorted", Qt.resolvedUrl("visualdatamodel/sortedmodel.qml")); - addExample("VisualItemModel", "A model that consists of the actual Items", Qt.resolvedUrl("visualitemmodel/visualitemmodel.qml")); + addExample("GridView", "A simple GridView", Qt.resolvedUrl("gridview/gridview-example.qml")) + addExample("Dynamic List", "A dynamically alterable list", Qt.resolvedUrl("listview/dynamiclist.qml")) + addExample("Expanding Delegates", "A ListView with delegates that expand", Qt.resolvedUrl("listview/expandingdelegates.qml")) + addExample("Highlight", "A ListView with a custom highlight", Qt.resolvedUrl("listview/highlight.qml")) + addExample("Highlight Ranges", "The three highlight ranges of ListView", Qt.resolvedUrl("listview/highlightranges.qml")) + addExample("Sections", "ListView section headers and footers", Qt.resolvedUrl("listview/sections.qml")) + addExample("Packages", "Transitions between a ListView and GridView", Qt.resolvedUrl("package/view.qml")) + addExample("PathView", "A simple PathView", Qt.resolvedUrl("pathview/pathview-example.qml")) + addExample("VisualItemModel", "Using a VisualItemModel", Qt.resolvedUrl("visualitemmodel/visualitemmodel.qml")) } } } diff --git a/examples/quick/modelviews/package/Delegate.qml b/examples/quick/modelviews/package/Delegate.qml index 97c7840cb4..3028318f10 100644 --- a/examples/quick/modelviews/package/Delegate.qml +++ b/examples/quick/modelviews/package/Delegate.qml @@ -42,26 +42,16 @@ import QtQuick 2.0 //![0] Package { - Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } - Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } + Text { id: listDelegate; width: parent.width; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: parent.width / 2; height: 50; text: 'Empty'; Package.name: 'grid' } Rectangle { id: wrapper - width: 200; height: 25 + width: parent.width; height: 25 color: 'lightsteelblue' Text { text: display; anchors.centerIn: parent } - MouseArea { - anchors.fill: parent - onClicked: { - if (wrapper.state == 'inList') - wrapper.state = 'inGrid'; - else - wrapper.state = 'inList'; - } - } - - state: 'inList' + state: root.upTo > index ? 'inGrid' : 'inList' states: [ State { name: 'inList' diff --git a/examples/quick/modelviews/package/view.qml b/examples/quick/modelviews/package/view.qml index 7ba6664ae2..b12dec3de2 100644 --- a/examples/quick/modelviews/package/view.qml +++ b/examples/quick/modelviews/package/view.qml @@ -41,9 +41,16 @@ import QtQuick 2.0 Rectangle { + id: root color: "white" - width: 400 - height: 200 + width: 320 + height: 480 + property int upTo: 0 + SequentialAnimation on upTo { + loops: -1 + NumberAnimation { to: 8; duration: 3500 } + NumberAnimation { to: 0; duration: 3500 } + } ListModel { id: myModel @@ -64,17 +71,22 @@ Rectangle { } ListView { - width: 200; height:200 + id: lv + height: parent.height/2 + width: parent.width + model: visualModel.parts.list } GridView { - x: 200; width: 200; height:200 + y: parent.height/2 + height: parent.height/2 + width: parent.width + cellWidth: width / 2 cellHeight: 50 model: visualModel.parts.grid } //![0] Text { anchors.bottom: parent.bottom - text: "Tap a delegate to move between views" } } diff --git a/examples/quick/modelviews/parallax/parallax.qml b/examples/quick/modelviews/parallax/parallax.qml index 30578e510e..9e0a957f97 100644 --- a/examples/quick/modelviews/parallax/parallax.qml +++ b/examples/quick/modelviews/parallax/parallax.qml @@ -69,7 +69,7 @@ Rectangle { anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter } width: 300; height: 400 clip: true; - source: "../../samegame/samegame.qml" + source: "../../../demos/samegame/samegame.qml" } } } diff --git a/examples/quick/modelviews/visualdatamodel/sortedmodel.qml b/examples/quick/modelviews/visualdatamodel/sortedmodel.qml deleted file mode 100644 index 8d3b0a58e5..0000000000 --- a/examples/quick/modelviews/visualdatamodel/sortedmodel.qml +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 480; height: 640 - - Component { - id: numberDelegate - - Text { - id: numberText - anchors { left: parent.left; right: parent.right } - text: number - - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 18 - - Text { - anchors { left: parent.left; baseline: parent.baseline } - text: index - - horizontalAlignment: Text.AlignLeft - font.pixelSize: 12 - } - Text { - anchors { right: parent.right; baseline: parent.baseline } - text: numberText.VisualDataModel.itemsIndex - - horizontalAlignment: Text.AlignRight - font.pixelSize: 12 - } - } - } - - ListView { - anchors { - left: parent.left; top: parent.top; - right: parent.horizontalCenter; bottom: button.top - leftMargin: 2; topMargin: 2; rightMargin: 1; bottomMargin: 2 - } - - model: ListModel { - id: unsortedModel - } - delegate: numberDelegate - } - ListView { - anchors { - left: parent.horizontalCenter; top: parent.top; - right: parent.right; bottom: button.top - leftMargin: 1; topMargin: 2; rightMargin: 2; bottomMargin: 2 - } - model: VisualDataModel { - model: unsortedModel - delegate: numberDelegate - - items.onChanged: { - for (var i = 0; i < inserted.length; ++i) { - for (var j = inserted[i].index; j < inserted[i].index + inserted[i].count; ++j) { - var number = items.get(j).model.number - for (var l = 0, k = 0; l < unsortedModel.count; ++l) { - if (l == inserted[k].index) { - l += inserted[k].count - 1 - ++k - } else if (number < items.get(l).model.number) { - items.move(j, l, 1) - break - } - } - inserted[i].index += 1; - inserted[i].count -= 1; - } - } - } - } - } - - Rectangle { - id: button - - anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 } - height: moreText.implicitHeight + 4 - - color: "black" - - Text { - id: moreText - - anchors.fill: parent - text: "More" - color: "white" - font.pixelSize: 18 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - MouseArea { - anchors.fill: parent - - onClicked: unsortedModel.append({ "number": Math.floor(Math.random() * 100) }) - } - } -} diff --git a/examples/quick/mousearea/main.cpp b/examples/quick/mousearea/main.cpp new file mode 100644 index 0000000000..a85bac3b05 --- /dev/null +++ b/examples/quick/mousearea/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(mousearea) diff --git a/examples/quick/mousearea/mousearea.pro b/examples/quick/mousearea/mousearea.pro new file mode 100644 index 0000000000..e9a715aae5 --- /dev/null +++ b/examples/quick/mousearea/mousearea.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +QT += quick declarative +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/mousearea +qml.files = mousearea.qml +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/mousearea +INSTALLS += target qml + diff --git a/examples/quick/mousearea/mousearea-example.qml b/examples/quick/mousearea/mousearea.qml index 30e3e62864..df26e05a3c 100644 --- a/examples/quick/mousearea/mousearea-example.qml +++ b/examples/quick/mousearea/mousearea.qml @@ -40,9 +40,18 @@ import QtQuick 2.0 +/*! + \title QtQuick Examples - MouseArea + \example quick/mousearea + \brief This is a collection of QML Animation examples. + \image qml-mousearea-example.png + + This example shows you how to respond to clicks and drags with a MouseArea. +*/ + Rectangle { id: box - width: 400; height: 300 + width: 320; height: 480 Rectangle { id: redSquare diff --git a/examples/quick/mousearea/mousearea.qmlproject b/examples/quick/mousearea/mousearea.qmlproject new file mode 100644 index 0000000000..6595e118d8 --- /dev/null +++ b/examples/quick/mousearea/mousearea.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "mousearea.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/openglunderqml/main.cpp b/examples/quick/openglunderqml/main.cpp index 3b682deaec..8d1a91bdb2 100644 --- a/examples/quick/openglunderqml/main.cpp +++ b/examples/quick/openglunderqml/main.cpp @@ -49,7 +49,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); - qmlRegisterType<Squircle>("QtQuick", 2, 0, "Squircle"); + qmlRegisterType<Squircle>("OpenGLUnderQML", 2, 0, "Squircle"); QQuickView view; view.setSource(QUrl("main.qml")); diff --git a/examples/quick/openglunderqml/main.qml b/examples/quick/openglunderqml/main.qml index 1485cbbdb8..174bb262ca 100644 --- a/examples/quick/openglunderqml/main.qml +++ b/examples/quick/openglunderqml/main.qml @@ -40,13 +40,16 @@ ****************************************************************************/ import QtQuick 2.0 +import OpenGLUnderQML 2.0 Item { - width: 400 - height: 300 + width: 320 + height: 480 Squircle { + width: 320 + height: 320 SequentialAnimation on t { NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad } NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad } diff --git a/examples/quick/painteditem/smile/smile.qml b/examples/quick/painteditem/smile/smile.qml index 33919bc04f..c30da1b944 100644 --- a/examples/quick/painteditem/smile/smile.qml +++ b/examples/quick/painteditem/smile/smile.qml @@ -40,93 +40,41 @@ import QtQuick 2.0 import MyModule 1.0 +/*! + \title QtQuick Examples - Painted Smile + \example quick/painteditem/smile + \brief This is a simple example the draws a smile with QPainter +*/ Rectangle { - width: 500 - height: 500 + width: 320 + height: 480 gradient: Gradient { GradientStop { position: 0.0; color: "#00249a" } GradientStop { position: 0.7; color: "#ffd94f" } GradientStop { position: 1.0; color: "#ffa322" } } - MyPaintItem { - renderTarget:PaintedItem.Image - clip:true - width:240 - height:240 - anchors.left : parent.left - anchors.top :parent.top - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } + Grid { + columns: 2 + Repeater { + model: 6 + delegate: MyPaintItem { + renderTarget:PaintedItem.Image + clip:true + width:160 + height:160 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } } } - MyPaintItem { - clip:true - renderTarget:PaintedItem.Image - width:240 - height:240 - anchors.right : parent.right - anchors.top :parent.top - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } - MyPaintItem { - clip:true - renderTarget:PaintedItem.Image - width:240 - height:240 - anchors.left : parent.left - anchors.bottom :parent.bottom - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } - MyPaintItem { - clip:true - renderTarget:PaintedItem.Image - width:240 - height:240 - anchors.right : parent.right - anchors.bottom :parent.bottom - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } -}
\ No newline at end of file +} diff --git a/examples/quick/painteditem/textballoons/textballoons.qml b/examples/quick/painteditem/textballoons/textballoons.qml index b00ce2bfed..d5151c9553 100644 --- a/examples/quick/painteditem/textballoons/textballoons.qml +++ b/examples/quick/painteditem/textballoons/textballoons.qml @@ -42,9 +42,14 @@ import QtQuick 2.0 import TextBalloonPlugin 1.0 +/*! + \title QtQuick Examples - Painted Text Balloons + \example quick/painteditem/textballoons + \brief This is a simple example that draws text balloons using QPainter +*/ Item { height: 480 - width: 640 + width: 320 //! [0] ListModel { @@ -53,7 +58,7 @@ Item { balloonWidth: 200 } ListElement { - balloonWidth: 350 + balloonWidth: 120 } } @@ -95,7 +100,7 @@ Item { anchors.fill: parent hoverEnabled: true onClicked: { - balloonModel.append({"balloonWidth": Math.floor(Math.random() * 300 + 100)}) + balloonModel.append({"balloonWidth": Math.floor(Math.random() * 200 + 100)}) balloonView.positionViewAtIndex(balloonView.count -1, ListView.End) } onEntered: { diff --git a/examples/quick/quick.pro b/examples/quick/quick.pro index 529f65ac25..d715d4787c 100644 --- a/examples/quick/quick.pro +++ b/examples/quick/quick.pro @@ -1,11 +1,11 @@ TEMPLATE = subdirs SUBDIRS = accessibility \ animation \ - draganddrop + draganddrop \ #canvas \ #imageelements \ #keyinteraction \ - #modelviews \ + modelviews \ #mousearea \ #openglunderqml \ #painteditem \ diff --git a/examples/quick/threading/main.cpp b/examples/quick/threading/main.cpp new file mode 100644 index 0000000000..e3440b1e4c --- /dev/null +++ b/examples/quick/threading/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(threading) diff --git a/examples/quick/threading/threading.pro b/examples/quick/threading/threading.pro new file mode 100644 index 0000000000..ba6d75433b --- /dev/null +++ b/examples/quick/threading/threading.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/threading +qml.files = threading.qml threadedlistmodel workerscript +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/threading +INSTALLS += target qml + diff --git a/examples/quick/threading/threading.qml b/examples/quick/threading/threading.qml new file mode 100644 index 0000000000..7ba8b8f70d --- /dev/null +++ b/examples/quick/threading/threading.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../../shared" as Examples + +/*! + \title QtQuick Examples - Threading + \example qtquick/threading + \brief This is a collection of QML Multithreading examples. + \image qml-threading-example.png + + Threaded ListModel contains a ListView and a ListModel. The ListModel is updated asynchronusly in another thread, and the results propagate back to the main thread. + + WorkerScript contains an example of using a WorkerScript to offload expensive calculations into another thread. This keeps the UI from being blocked. This example calculates numbers in Pascal's Triangle, and not in a very optimal way, so it will often take several seconds to complete the calculation. By doing this in a WorkerScript in another thread, the UI is not blocked during this time. +*/ + +Item { + height: 480 + width: 320 + Examples.LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("Threaded ListModel", "Updates a ListModel in another thread", Qt.resolvedUrl("threadedlistmodel/timedisplay.qml")); + addExample("WorkerScript", "Performs calculations in another thread", Qt.resolvedUrl("workerscript/workerscript.qml")); + } + } +} diff --git a/examples/quick/threading/threading.qmlproject b/examples/quick/threading/threading.qmlproject new file mode 100644 index 0000000000..d17405d4dc --- /dev/null +++ b/examples/quick/threading/threading.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "threading.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/threading/workerscript/Spinner.qml b/examples/quick/threading/workerscript/Spinner.qml new file mode 100644 index 0000000000..32ab248529 --- /dev/null +++ b/examples/quick/threading/workerscript/Spinner.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 64 + height: 64 + property alias value: list.currentIndex + property alias label: caption.text + + Text { + id: caption + text: "Spinner" + anchors.horizontalCenter: parent.horizontalCenter + } + + Rectangle { + anchors.top: caption.bottom + anchors.topMargin: 4 + anchors.horizontalCenter: parent.horizontalCenter + height: 48 + width: 32 + color: "black" + ListView { + id: list + anchors.fill: parent + highlightRangeMode: ListView.StrictlyEnforceRange + preferredHighlightBegin: height/3 + preferredHighlightEnd: height/3 + clip: true + model: 64 + delegate: Text { + font.pixelSize: 18; + color: "white"; + text: index; + anchors.horizontalCenter: parent.horizontalCenter + } + } + Rectangle { + anchors.fill: parent + gradient: Gradient { + GradientStop { position: 0.0; color: "#FF000000" } + GradientStop { position: 0.2; color: "#00000000" } + GradientStop { position: 0.8; color: "#00000000" } + GradientStop { position: 1.0; color: "#FF000000" } + } + } + } +} diff --git a/examples/quick/threading/workerscript/workerscript.js b/examples/quick/threading/workerscript/workerscript.js index f76471f920..ada3d82589 100644 --- a/examples/quick/threading/workerscript/workerscript.js +++ b/examples/quick/threading/workerscript/workerscript.js @@ -1,15 +1,24 @@ -var lastx = 0; -var lasty = 0; +//Will be initialized when WorkerScript{} is instantiated +var cache = new Array(64); +for (var i = 0; i < 64; i++) + cache[i] = new Array(64); -WorkerScript.onMessage = function(message) { - var ydiff = message.y - lasty; - var xdiff = message.x - lastx; - - var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); - - lastx = message.x; - lasty = message.y; +function triangle(row, column) { + if (cache[row][column]) + return cache[row][column] + if (column < 0 || column > row) + return -1; + if (column == 0 || column == row) + return 1; + return triangle(row-1, column-1) + triangle(row-1, column); +} - WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); +WorkerScript.onMessage = function(message) { + //Calculate result (may take a while, using a naive algorithm) + var calculatedResult = triangle(message.row, message.column); + //Send result back to main thread + WorkerScript.sendMessage( { row: message.row, + column: message.column, + result: calculatedResult} ); } diff --git a/examples/quick/threading/workerscript/workerscript.qml b/examples/quick/threading/workerscript/workerscript.qml index 7fced8166c..640df0b483 100644 --- a/examples/quick/threading/workerscript/workerscript.qml +++ b/examples/quick/threading/workerscript/workerscript.qml @@ -41,43 +41,55 @@ import QtQuick 2.0 Rectangle { - width: 480; height: 320 + width: 320; height: 480 WorkerScript { id: myWorker source: "workerscript.js" onMessage: { - console.log("Moved " + messageObject.xmove + " along the X axis."); - console.log("Moved " + messageObject.ymove + " along the Y axis."); - console.log("Moved " + messageObject.move + " pixels."); + if (messageObject.row == rowSpinner.value && messageObject.column == columnSpinner.value){ //Not an old result + if (messageObject.result == -1) + resultText.text = "Column must be <= Row"; + else + resultText.text = messageObject.result; + } } } + Row { + y: 24 + spacing: 24 + anchors.horizontalCenter: parent.horizontalCenter + Spinner { + id: rowSpinner + label: "Row" + onValueChanged: { + resultText.text = "Loading..."; + myWorker.sendMessage( { row: rowSpinner.value, column: columnSpinner.value } ); + } + } - Rectangle { - width: 200; height: 200 - anchors.left: parent.left; anchors.leftMargin: 20 - color: "red" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); + Spinner { + id: columnSpinner + label: "Column" + onValueChanged: { + resultText.text = "Loading..."; + myWorker.sendMessage( { row: rowSpinner.value, column: columnSpinner.value } ); + } } } - Rectangle { - width: 200; height: 200 - anchors.right: parent.right; anchors.rightMargin: 20 - color: "blue" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); - } + Text { + id: resultText + y: 180 + width: parent.width + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + font.pixelSize: 32 } Text { - text: "Click a Rectangle!" + text: "Pascal's Triangle Calculator" anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } } } diff --git a/examples/quick/touchinteraction/flickable/basic-flickable.qml b/examples/quick/touchinteraction/flickable/basic-flickable.qml new file mode 100644 index 0000000000..58650d7334 --- /dev/null +++ b/examples/quick/touchinteraction/flickable/basic-flickable.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + Flickable { + anchors.fill: parent + contentWidth: 1200 + contentHeight: 1200 + Rectangle { + width: 1000 + height: 1000 + x: 100 + y: 100 + radius: 128 + border.width: 4 + border.color: "black" + gradient: Gradient { + GradientStop { position: 0.0; color: "#000000" } + GradientStop { position: 0.2; color: "#888888" } + GradientStop { position: 0.4; color: "#FFFFFF" } + GradientStop { position: 0.6; color: "#FFFFFF" } + GradientStop { position: 0.8; color: "#888888" } + GradientStop { position: 1.0; color: "#000000" } + } + } + } +} diff --git a/examples/quick/touchinteraction/flickable/content/Day.qml b/examples/quick/touchinteraction/flickable/content/Panel.qml index 7fe625c305..3a402bbc06 100644 --- a/examples/quick/touchinteraction/flickable/content/Day.qml +++ b/examples/quick/touchinteraction/flickable/content/Panel.qml @@ -48,7 +48,7 @@ Component { width: ListView.view.width+40; height: ListView.view.height - Image { + Image { source: "cork.jpg" width: page.ListView.view.width height: page.ListView.view.height diff --git a/examples/quick/touchinteraction/flickable/corkboards.qml b/examples/quick/touchinteraction/flickable/corkboards.qml index dc3aa6b378..85c62f1538 100644 --- a/examples/quick/touchinteraction/flickable/corkboards.qml +++ b/examples/quick/touchinteraction/flickable/corkboards.qml @@ -42,62 +42,33 @@ import QtQuick 2.0 import "content" Rectangle { - width: 800; height: 480 + width: 320; height: 480 color: "#464646" ListModel { id: list ListElement { - name: "Sunday" + name: "Panel One" notes: [ - ListElement { noteText: "Lunch" }, - ListElement { noteText: "Birthday Party" } + ListElement { noteText: "Tap to edit" }, + ListElement { noteText: "Drag to move" }, + ListElement { noteText: "Flick to scroll" } ] } ListElement { - name: "Monday" + name: "Panel Two" notes: [ - ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, - ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } + ListElement { noteText: "Note One" }, + ListElement { noteText: "Note Two" } ] } ListElement { - name: "Tuesday" + name: "Panel Three" notes: [ - ListElement { noteText: "Walk dog" }, - ListElement { noteText: "Buy newspaper" } - ] - } - - ListElement { - name: "Wednesday" - notes: [ ListElement { noteText: "Cook dinner" } ] - } - - ListElement { - name: "Thursday" - notes: [ - ListElement { noteText: "Meeting\n5.30pm" }, - ListElement { noteText: "Weed garden" } - ] - } - - ListElement { - name: "Friday" - notes: [ - ListElement { noteText: "More work" }, - ListElement { noteText: "Grocery shopping" } - ] - } - - ListElement { - name: "Saturday" - notes: [ - ListElement { noteText: "Drink" }, - ListElement { noteText: "Download Qt\nPlay with QML" } + ListElement { noteText: "Note Three" } ] } } @@ -111,6 +82,6 @@ Rectangle { orientation: ListView.Horizontal snapMode: ListView.SnapOneItem model: list - delegate: Day { } + delegate: Panel { } } } diff --git a/examples/quick/touchinteraction/main.cpp b/examples/quick/touchinteraction/main.cpp new file mode 100644 index 0000000000..02b249dace --- /dev/null +++ b/examples/quick/touchinteraction/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(touchinteraction) diff --git a/examples/quick/touchinteraction/multipointtouch/bearwhack.qml b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml index db46473c05..e2910a3c5d 100644 --- a/examples/quick/touchinteraction/multipointtouch/bearwhack.qml +++ b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml @@ -43,7 +43,7 @@ import "content" Item { id: root - height: 640 + height: 480 width: 320 Item { id: startScreen diff --git a/examples/quick/touchinteraction/multipointtouch/content/title.png b/examples/quick/touchinteraction/multipointtouch/content/title.png Binary files differindex d630ea2643..c370ee9990 100644 --- a/examples/quick/touchinteraction/multipointtouch/content/title.png +++ b/examples/quick/touchinteraction/multipointtouch/content/title.png diff --git a/examples/quick/touchinteraction/touchinteraction.pro b/examples/quick/touchinteraction/touchinteraction.pro new file mode 100644 index 0000000000..c56e5c8206 --- /dev/null +++ b/examples/quick/touchinteraction/touchinteraction.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +QT += quick declarative +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/touchinteraction +qml.files = flickable multipointtouch pincharea touchinteraction.qml +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/quick/touchinteraction +INSTALLS += target qml + diff --git a/examples/quick/touchinteraction/touchinteraction.qml b/examples/quick/touchinteraction/touchinteraction.qml index b4a930c495..0be625a160 100644 --- a/examples/quick/touchinteraction/touchinteraction.qml +++ b/examples/quick/touchinteraction/touchinteraction.qml @@ -41,6 +41,25 @@ import QtQuick 2.0 import "../../shared" +/*! + \title QtQuick Examples - Touch Interaction + \example qtquick/touchinteraction + \brief This is a collection of QML Touch Interaction examples. + \image qml-touchinteraction-example.png + + This is a collection of small QML examples relating to touch interaction methods. + + Multipoint Flames demonstrates distinguishing different fingers in a MultiPointTouchArea, by assignning a different colored flame to each touch point. + + Bear-Whack demonstrates using a MultiPointTouchArea to add multiple finger support to a simple game. + + Flick Resize uses a PinchArea to allow Pinch-to-Resize behavior. + + Flickable is a simple example demonstrating the Flickable element. + + Corkboards shows a more complex Flickable usecase, with elements on the flickable that respond to mouse and keyboard interaction. +*/ + Item { height: 480 width: 320 @@ -51,6 +70,8 @@ Item { addExample("Multipoint Flames", "Create multiple flames with multiple fingers", Qt.resolvedUrl("multipointtouch/multiflame.qml")); addExample("Bear-Whack", "Use multiple touches to knock all the bears down", Qt.resolvedUrl("multipointtouch/bearwhack.qml")); addExample("Flick Resize", "Manipulate images using pinch gestures", Qt.resolvedUrl("pincharea/flickresize.qml")); + addExample("Flickable", "A viewport you can move with touch gestures", Qt.resolvedUrl("flickable/basic-flickable.qml")); + addExample("Corkboards", "Uses touch input on items inside a Flickable", Qt.resolvedUrl("flickable/corkboards.qml")); } } } diff --git a/examples/tutorials/helloworld/tutorial1.qml b/examples/tutorials/helloworld/tutorial1.qml index f0eb42d696..3de79831f4 100644 --- a/examples/tutorials/helloworld/tutorial1.qml +++ b/examples/tutorials/helloworld/tutorial1.qml @@ -46,7 +46,7 @@ import QtQuick 2.0 //![1] Rectangle { id: page - width: 500; height: 200 + width: 320; height: 480 color: "lightgray" //![1] diff --git a/examples/tutorials/helloworld/tutorial2.qml b/examples/tutorials/helloworld/tutorial2.qml index c5c045aace..3b44f5cf54 100644 --- a/examples/tutorials/helloworld/tutorial2.qml +++ b/examples/tutorials/helloworld/tutorial2.qml @@ -43,7 +43,7 @@ import QtQuick 2.0 Rectangle { id: page - width: 500; height: 200 + width: 320; height: 480 color: "lightgray" Text { diff --git a/examples/tutorials/helloworld/tutorial3.qml b/examples/tutorials/helloworld/tutorial3.qml index c804bfca1d..c35420c1de 100644 --- a/examples/tutorials/helloworld/tutorial3.qml +++ b/examples/tutorials/helloworld/tutorial3.qml @@ -43,7 +43,7 @@ import QtQuick 2.0 Rectangle { id: page - width: 500; height: 200 + width: 320; height: 480 color: "lightgray" Text { |