aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative')
-rw-r--r--examples/declarative/calculator/Core/Button.qml80
-rw-r--r--examples/declarative/calculator/Core/Display.qml68
-rw-r--r--examples/declarative/calculator/Core/calculator.js91
-rw-r--r--examples/declarative/calculator/Core/images/button-.pngbin0 -> 1288 bytes
-rw-r--r--examples/declarative/calculator/Core/images/button-blue.pngbin0 -> 1565 bytes
-rw-r--r--examples/declarative/calculator/Core/images/button-green.pngbin0 -> 1543 bytes
-rw-r--r--examples/declarative/calculator/Core/images/button-purple.pngbin0 -> 1566 bytes
-rw-r--r--examples/declarative/calculator/Core/images/button-red.pngbin0 -> 1586 bytes
-rw-r--r--examples/declarative/calculator/Core/images/display.pngbin0 -> 998 bytes
-rw-r--r--examples/declarative/calculator/Core/qmldir2
-rw-r--r--examples/declarative/calculator/calculator.qml162
-rw-r--r--examples/declarative/calculator/calculator.qmlproject16
-rw-r--r--examples/declarative/declarative.pro14
-rw-r--r--examples/declarative/flickr/content/Button.qml79
-rw-r--r--examples/declarative/flickr/content/GridDelegate.qml111
-rw-r--r--examples/declarative/flickr/content/ImageDetails.qml355
-rw-r--r--examples/declarative/flickr/content/ListDelegate.qml64
-rw-r--r--examples/declarative/flickr/content/Progress.qml88
-rw-r--r--examples/declarative/flickr/content/RssModel.qml66
-rw-r--r--examples/declarative/flickr/content/ScrollBar.qml81
-rw-r--r--examples/declarative/flickr/content/Slider.qml91
-rw-r--r--examples/declarative/flickr/content/StreamView.qml107
-rw-r--r--examples/declarative/flickr/content/TitleBar.qml128
-rw-r--r--examples/declarative/flickr/content/ToolBar.qml69
-rw-r--r--examples/declarative/flickr/content/UnifiedDelegate.qml162
-rw-r--r--examples/declarative/flickr/content/images/gloss.pngbin0 -> 1236 bytes
-rw-r--r--examples/declarative/flickr/content/images/lineedit.pngbin0 -> 1415 bytes
-rw-r--r--examples/declarative/flickr/content/images/lineedit.sci5
-rw-r--r--examples/declarative/flickr/content/images/noise.pngbin0 -> 25447 bytes
-rw-r--r--examples/declarative/flickr/content/images/particle.pngbin0 -> 5148 bytes
-rw-r--r--examples/declarative/flickr/content/images/quit.pngbin0 -> 2369 bytes
-rw-r--r--examples/declarative/flickr/content/images/squareParticle.pngbin0 -> 933 bytes
-rw-r--r--examples/declarative/flickr/content/images/stripes.pngbin0 -> 257 bytes
-rw-r--r--examples/declarative/flickr/content/images/titlebar.pngbin0 -> 1436 bytes
-rw-r--r--examples/declarative/flickr/content/images/titlebar.sci5
-rw-r--r--examples/declarative/flickr/content/images/toolbutton.pngbin0 -> 2550 bytes
-rw-r--r--examples/declarative/flickr/content/images/toolbutton.sci5
-rw-r--r--examples/declarative/flickr/content/qmldir10
-rw-r--r--examples/declarative/flickr/flickr-90.qml52
-rw-r--r--examples/declarative/flickr/flickr.qml166
-rw-r--r--examples/declarative/flickr/flickr.qmlproject16
-rw-r--r--examples/declarative/minehunt/MinehuntCore/Explosion.qml66
-rw-r--r--examples/declarative/minehunt/MinehuntCore/Tile.qml128
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/back.pngbin0 -> 558 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/background.pngbin0 -> 313930 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/bomb-color.pngbin0 -> 284 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/bomb.pngbin0 -> 535 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/face-sad.pngbin0 -> 14844 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.pngbin0 -> 13810 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/flag-color.pngbin0 -> 219 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/flag.pngbin0 -> 196 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/front.pngbin0 -> 580 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/quit.pngbin0 -> 583 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/pics/star.pngbin0 -> 2677 bytes
-rw-r--r--examples/declarative/minehunt/MinehuntCore/qmldir2
-rw-r--r--examples/declarative/minehunt/README6
-rw-r--r--examples/declarative/minehunt/main.cpp71
-rw-r--r--examples/declarative/minehunt/minehunt.cpp221
-rw-r--r--examples/declarative/minehunt/minehunt.h129
-rw-r--r--examples/declarative/minehunt/minehunt.pro23
-rw-r--r--examples/declarative/minehunt/minehunt.qml112
-rw-r--r--examples/declarative/minehunt/minehunt.qmlproject16
-rw-r--r--examples/declarative/minehunt/minehunt.qrc20
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml146
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml50
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/Button.qml72
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml86
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml188
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml57
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml54
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/Tag.qml91
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.pngbin0 -> 588 bytes
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/images/busy.pngbin0 -> 2629 bytes
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.pngbin0 -> 8844 bytes
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/qmldir8
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/script/script.js27
-rw-r--r--examples/declarative/photoviewer/i18n/base.ts30
-rw-r--r--examples/declarative/photoviewer/i18n/qml_fr.qmbin0 -> 268 bytes
-rw-r--r--examples/declarative/photoviewer/i18n/qml_fr.ts30
-rw-r--r--examples/declarative/photoviewer/photoviewer.qml110
-rw-r--r--examples/declarative/photoviewer/photoviewer.qmlproject16
-rw-r--r--examples/declarative/plasmapatrol/PlasmaPatrol.qmlproject18
-rw-r--r--examples/declarative/plasmapatrol/TODO10
-rw-r--r--examples/declarative/plasmapatrol/content/BlasterHardpoint.qml133
-rw-r--r--examples/declarative/plasmapatrol/content/Button.qml66
-rw-r--r--examples/declarative/plasmapatrol/content/CannonHardpoint.qml97
-rw-r--r--examples/declarative/plasmapatrol/content/ChoiceBox.qml105
-rw-r--r--examples/declarative/plasmapatrol/content/Cruiser.qml146
-rw-r--r--examples/declarative/plasmapatrol/content/Frigate.qml114
-rw-r--r--examples/declarative/plasmapatrol/content/Hardpoint.qml112
-rw-r--r--examples/declarative/plasmapatrol/content/HelpScreens.qml268
-rw-r--r--examples/declarative/plasmapatrol/content/LaserHardpoint.qml108
-rw-r--r--examples/declarative/plasmapatrol/content/PlasmaPatrolParticles.qml173
-rw-r--r--examples/declarative/plasmapatrol/content/SequentialLoader.qml54
-rw-r--r--examples/declarative/plasmapatrol/content/Ship.qml113
-rw-r--r--examples/declarative/plasmapatrol/content/Sloop.qml108
-rw-r--r--examples/declarative/plasmapatrol/content/pics/TitleText.pngbin0 -> 1109 bytes
-rw-r--r--examples/declarative/plasmapatrol/content/pics/blur-circle2.pngbin0 -> 3627 bytes
-rw-r--r--examples/declarative/plasmapatrol/content/pics/blur-circle3.pngbin0 -> 5148 bytes
-rw-r--r--examples/declarative/plasmapatrol/content/pics/finalfrontier.pngbin0 -> 695061 bytes
-rw-r--r--examples/declarative/plasmapatrol/content/pics/meteor.pngbin0 -> 83169 bytes
-rw-r--r--examples/declarative/plasmapatrol/content/pics/meteor_explo.pngbin0 -> 81528 bytes
-rw-r--r--examples/declarative/plasmapatrol/content/pics/nullRock.pngbin0 -> 140 bytes
-rw-r--r--examples/declarative/plasmapatrol/content/pics/particle.pngbin0 -> 861 bytes
-rw-r--r--examples/declarative/plasmapatrol/content/pics/star.pngbin0 -> 1550 bytes
-rw-r--r--examples/declarative/plasmapatrol/content/pics/star2.pngbin0 -> 6507 bytes
-rw-r--r--examples/declarative/plasmapatrol/content/pics/star3.pngbin0 -> 4602 bytes
-rw-r--r--examples/declarative/plasmapatrol/plasmapatrol.qml386
-rw-r--r--examples/declarative/rssnews/content/BusyIndicator.qml53
-rw-r--r--examples/declarative/rssnews/content/CategoryDelegate.qml82
-rw-r--r--examples/declarative/rssnews/content/NewsDelegate.qml71
-rw-r--r--examples/declarative/rssnews/content/RssFeeds.qml59
-rw-r--r--examples/declarative/rssnews/content/ScrollBar.qml107
-rw-r--r--examples/declarative/rssnews/content/images/busy.pngbin0 -> 2629 bytes
-rw-r--r--examples/declarative/rssnews/content/images/scrollbar.pngbin0 -> 161 bytes
-rw-r--r--examples/declarative/rssnews/rssnews.qml111
-rw-r--r--examples/declarative/rssnews/rssnews.qmlproject16
-rw-r--r--examples/declarative/samegame/SamegameCore/BoomBlock.qml111
-rw-r--r--examples/declarative/samegame/SamegameCore/Button.qml75
-rw-r--r--examples/declarative/samegame/SamegameCore/Dialog.qml80
-rw-r--r--examples/declarative/samegame/SamegameCore/pics/background.pngbin0 -> 313930 bytes
-rw-r--r--examples/declarative/samegame/SamegameCore/pics/blueStone.pngbin0 -> 3054 bytes
-rw-r--r--examples/declarative/samegame/SamegameCore/pics/greenStone.pngbin0 -> 2932 bytes
-rw-r--r--examples/declarative/samegame/SamegameCore/pics/particle.pngbin0 -> 861 bytes
-rw-r--r--examples/declarative/samegame/SamegameCore/pics/redStone.pngbin0 -> 2902 bytes
-rw-r--r--examples/declarative/samegame/SamegameCore/pics/yellowStone.pngbin0 -> 3056 bytes
-rw-r--r--examples/declarative/samegame/SamegameCore/qmldir3
-rwxr-xr-xexamples/declarative/samegame/SamegameCore/samegame.js288
-rw-r--r--examples/declarative/samegame/highscores/README1
-rwxr-xr-xexamples/declarative/samegame/highscores/score_data.xml2
-rwxr-xr-xexamples/declarative/samegame/highscores/score_style.xsl28
-rwxr-xr-xexamples/declarative/samegame/highscores/scores.php34
-rw-r--r--examples/declarative/samegame/samegame.qml192
-rw-r--r--examples/declarative/samegame/samegame.qmlproject16
-rw-r--r--examples/declarative/shadereffects/Slider.qml93
-rw-r--r--examples/declarative/shadereffects/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/declarative/shadereffects/qt-logo.pngbin0 -> 13923 bytes
-rw-r--r--examples/declarative/shadereffects/shader-demo.qml295
-rw-r--r--examples/declarative/snake/content/Button.qml66
-rw-r--r--examples/declarative/snake/content/Cookie.qml94
-rw-r--r--examples/declarative/snake/content/HighScoreModel.qml139
-rw-r--r--examples/declarative/snake/content/Link.qml128
-rw-r--r--examples/declarative/snake/content/Skull.qml62
-rw-r--r--examples/declarative/snake/content/pics/README1
-rw-r--r--examples/declarative/snake/content/pics/background.pngbin0 -> 144508 bytes
-rw-r--r--examples/declarative/snake/content/pics/blueStar.pngbin0 -> 272 bytes
-rw-r--r--examples/declarative/snake/content/pics/blueStone.pngbin0 -> 3139 bytes
-rw-r--r--examples/declarative/snake/content/pics/cookie.pngbin0 -> 2729 bytes
-rw-r--r--examples/declarative/snake/content/pics/eyes.svg118
-rw-r--r--examples/declarative/snake/content/pics/head.pngbin0 -> 3473 bytes
-rw-r--r--examples/declarative/snake/content/pics/head.svg134
-rw-r--r--examples/declarative/snake/content/pics/pause.pngbin0 -> 4327 bytes
-rw-r--r--examples/declarative/snake/content/pics/redStar.pngbin0 -> 273 bytes
-rw-r--r--examples/declarative/snake/content/pics/redStone.pngbin0 -> 3456 bytes
-rw-r--r--examples/declarative/snake/content/pics/skull.pngbin0 -> 2543 bytes
-rw-r--r--examples/declarative/snake/content/pics/snake.jpgbin0 -> 663901 bytes
-rw-r--r--examples/declarative/snake/content/pics/star.pngbin0 -> 262 bytes
-rw-r--r--examples/declarative/snake/content/pics/stoneShadow.pngbin0 -> 1699 bytes
-rw-r--r--examples/declarative/snake/content/pics/yellowStar.pngbin0 -> 276 bytes
-rw-r--r--examples/declarative/snake/content/pics/yellowStone.pngbin0 -> 2667 bytes
-rw-r--r--examples/declarative/snake/content/snake.js316
-rw-r--r--examples/declarative/snake/snake.qml272
-rw-r--r--examples/declarative/snake/snake.qmlproject16
-rw-r--r--examples/declarative/twitter/TwitterCore/Button.qml90
-rw-r--r--examples/declarative/twitter/TwitterCore/FatDelegate.qml105
-rw-r--r--examples/declarative/twitter/TwitterCore/Input.qml65
-rw-r--r--examples/declarative/twitter/TwitterCore/Loading.qml49
-rw-r--r--examples/declarative/twitter/TwitterCore/MultiTitleBar.qml60
-rw-r--r--examples/declarative/twitter/TwitterCore/RssModel.qml76
-rw-r--r--examples/declarative/twitter/TwitterCore/SearchView.qml124
-rw-r--r--examples/declarative/twitter/TwitterCore/TitleBar.qml130
-rw-r--r--examples/declarative/twitter/TwitterCore/ToolBar.qml64
-rw-r--r--examples/declarative/twitter/TwitterCore/UserModel.qml65
-rw-r--r--examples/declarative/twitter/TwitterCore/images/gloss.pngbin0 -> 1236 bytes
-rw-r--r--examples/declarative/twitter/TwitterCore/images/lineedit.pngbin0 -> 1415 bytes
-rw-r--r--examples/declarative/twitter/TwitterCore/images/lineedit.sci5
-rw-r--r--examples/declarative/twitter/TwitterCore/images/loading.pngbin0 -> 813 bytes
-rw-r--r--examples/declarative/twitter/TwitterCore/images/quit.pngbin0 -> 2369 bytes
-rw-r--r--examples/declarative/twitter/TwitterCore/images/stripes.pngbin0 -> 257 bytes
-rw-r--r--examples/declarative/twitter/TwitterCore/images/titlebar.pngbin0 -> 1436 bytes
-rw-r--r--examples/declarative/twitter/TwitterCore/images/titlebar.sci5
-rw-r--r--examples/declarative/twitter/TwitterCore/images/toolbutton.pngbin0 -> 2550 bytes
-rw-r--r--examples/declarative/twitter/TwitterCore/images/toolbutton.sci5
-rw-r--r--examples/declarative/twitter/TwitterCore/qmldir10
-rw-r--r--examples/declarative/twitter/twitter.qml134
-rw-r--r--examples/declarative/twitter/twitter.qmlproject16
187 files changed, 9927 insertions, 2 deletions
diff --git a/examples/declarative/calculator/Core/Button.qml b/examples/declarative/calculator/Core/Button.qml
new file mode 100644
index 0000000000..c5ec39cea8
--- /dev/null
+++ b/examples/declarative/calculator/Core/Button.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+BorderImage {
+ id: button
+
+ property alias operation: buttonText.text
+ property string color: ""
+
+ signal clicked
+
+ source: "images/button-" + color + ".png"; clip: true
+ border { left: 10; top: 10; right: 10; bottom: 10 }
+
+ Rectangle {
+ id: shade
+ anchors.fill: button; radius: 10; color: "black"; opacity: 0
+ }
+
+ Text {
+ id: buttonText
+ anchors.centerIn: parent; anchors.verticalCenterOffset: -1
+ font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5
+ style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ doOp(operation)
+ button.clicked()
+ }
+ }
+
+ states: State {
+ name: "pressed"; when: mouseArea.pressed == true
+ PropertyChanges { target: shade; opacity: .4 }
+ }
+}
diff --git a/examples/declarative/calculator/Core/Display.qml b/examples/declarative/calculator/Core/Display.qml
new file mode 100644
index 0000000000..5e27897bae
--- /dev/null
+++ b/examples/declarative/calculator/Core/Display.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+BorderImage {
+ id: image
+
+ property alias text : displayText.text
+ property alias currentOperation : operationText
+
+ source: "images/display.png"
+ border { left: 10; top: 10; right: 10; bottom: 10 }
+
+ Text {
+ id: displayText
+ anchors {
+ right: parent.right; verticalCenter: parent.verticalCenter; verticalCenterOffset: -1
+ rightMargin: 6; left: operationText.right
+ }
+ font.pixelSize: parent.height * .6; text: "0"; horizontalAlignment: Text.AlignRight; elide: Text.ElideRight
+ color: "#343434"; smooth: true; font.bold: true
+ }
+ Text {
+ id: operationText
+ font.bold: true; font.pixelSize: parent.height * .7
+ color: "#343434"; smooth: true
+ anchors { left: parent.left; leftMargin: 6; verticalCenterOffset: -3; verticalCenter: parent.verticalCenter }
+ }
+}
diff --git a/examples/declarative/calculator/Core/calculator.js b/examples/declarative/calculator/Core/calculator.js
new file mode 100644
index 0000000000..7c363c7f30
--- /dev/null
+++ b/examples/declarative/calculator/Core/calculator.js
@@ -0,0 +1,91 @@
+
+var curVal = 0
+var memory = 0
+var lastOp = ""
+var timer = 0
+
+function disabled(op) {
+ if (op == "." && display.text.toString().search(/\./) != -1) {
+ return true
+ } else if (op == squareRoot && display.text.toString().search(/-/) != -1) {
+ return true
+ } else {
+ return false
+ }
+}
+
+function doOperation(op) {
+ if (disabled(op)) {
+ return
+ }
+
+ if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) {
+ if (display.text.toString().length >= 14)
+ return; // No arbitrary length numbers
+ if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) {
+ display.text = display.text + op.toString()
+ } else {
+ display.text = op
+ }
+ lastOp = op
+ return
+ }
+ lastOp = op
+
+ if (display.currentOperation.text == "+") {
+ display.text = Number(display.text.valueOf()) + Number(curVal.valueOf())
+ } else if (display.currentOperation.text == "-") {
+ display.text = Number(curVal) - Number(display.text.valueOf())
+ } else if (display.currentOperation.text == multiplication) {
+ display.text = Number(curVal) * Number(display.text.valueOf())
+ } else if (display.currentOperation.text == division) {
+ display.text = Number(Number(curVal) / Number(display.text.valueOf())).toString()
+ } else if (display.currentOperation.text == "=") {
+ }
+
+ if (op == "+" || op == "-" || op == multiplication || op == division) {
+ display.currentOperation.text = op
+ curVal = display.text.valueOf()
+ return
+ }
+
+ curVal = 0
+ display.currentOperation.text = ""
+
+ if (op == "1/x") {
+ display.text = (1 / display.text.valueOf()).toString()
+ } else if (op == "x^2") {
+ display.text = (display.text.valueOf() * display.text.valueOf()).toString()
+ } else if (op == "Abs") {
+ display.text = (Math.abs(display.text.valueOf())).toString()
+ } else if (op == "Int") {
+ display.text = (Math.floor(display.text.valueOf())).toString()
+ } else if (op == plusminus) {
+ display.text = (display.text.valueOf() * -1).toString()
+ } else if (op == squareRoot) {
+ display.text = (Math.sqrt(display.text.valueOf())).toString()
+ } else if (op == "mc") {
+ memory = 0;
+ } else if (op == "m+") {
+ memory += display.text.valueOf()
+ } else if (op == "mr") {
+ display.text = memory.toString()
+ } else if (op == "m-") {
+ memory = display.text.valueOf()
+ } else if (op == leftArrow) {
+ display.text = display.text.toString().slice(0, -1)
+ if (display.text.length == 0) {
+ display.text = "0"
+ }
+ } else if (op == "Off") {
+ Qt.quit();
+ } else if (op == "C") {
+ display.text = "0"
+ } else if (op == "AC") {
+ curVal = 0
+ memory = 0
+ lastOp = ""
+ display.text ="0"
+ }
+}
+
diff --git a/examples/declarative/calculator/Core/images/button-.png b/examples/declarative/calculator/Core/images/button-.png
new file mode 100644
index 0000000000..544e514536
--- /dev/null
+++ b/examples/declarative/calculator/Core/images/button-.png
Binary files differ
diff --git a/examples/declarative/calculator/Core/images/button-blue.png b/examples/declarative/calculator/Core/images/button-blue.png
new file mode 100644
index 0000000000..5f92de32d0
--- /dev/null
+++ b/examples/declarative/calculator/Core/images/button-blue.png
Binary files differ
diff --git a/examples/declarative/calculator/Core/images/button-green.png b/examples/declarative/calculator/Core/images/button-green.png
new file mode 100644
index 0000000000..36c93914c7
--- /dev/null
+++ b/examples/declarative/calculator/Core/images/button-green.png
Binary files differ
diff --git a/examples/declarative/calculator/Core/images/button-purple.png b/examples/declarative/calculator/Core/images/button-purple.png
new file mode 100644
index 0000000000..347cbbea9d
--- /dev/null
+++ b/examples/declarative/calculator/Core/images/button-purple.png
Binary files differ
diff --git a/examples/declarative/calculator/Core/images/button-red.png b/examples/declarative/calculator/Core/images/button-red.png
new file mode 100644
index 0000000000..3b335891ae
--- /dev/null
+++ b/examples/declarative/calculator/Core/images/button-red.png
Binary files differ
diff --git a/examples/declarative/calculator/Core/images/display.png b/examples/declarative/calculator/Core/images/display.png
new file mode 100644
index 0000000000..9507f4382e
--- /dev/null
+++ b/examples/declarative/calculator/Core/images/display.png
Binary files differ
diff --git a/examples/declarative/calculator/Core/qmldir b/examples/declarative/calculator/Core/qmldir
new file mode 100644
index 0000000000..a926b93fac
--- /dev/null
+++ b/examples/declarative/calculator/Core/qmldir
@@ -0,0 +1,2 @@
+Button Button.qml
+Display Display.qml
diff --git a/examples/declarative/calculator/calculator.qml b/examples/declarative/calculator/calculator.qml
new file mode 100644
index 0000000000..c844c710aa
--- /dev/null
+++ b/examples/declarative/calculator/calculator.qml
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+import "Core"
+import "Core/calculator.js" as CalcEngine
+
+Rectangle {
+ id: window
+
+ width: 360; height: 480
+ color: "#282828"
+
+ property string rotateLeft: "\u2939"
+ property string rotateRight: "\u2935"
+ property string leftArrow: "\u2190"
+ property string division : "\u00f7"
+ property string multiplication : "\u00d7"
+ property string squareRoot : "\u221a"
+ property string plusminus : "\u00b1"
+
+ function doOp(operation) { CalcEngine.doOperation(operation) }
+
+ Item {
+ id: main
+ state: "orientation " + runtime.orientation
+
+ property bool landscapeWindow: window.width > window.height
+ property real baseWidth: landscapeWindow ? window.height : window.width
+ property real baseHeight: landscapeWindow ? window.width : window.height
+ property real rotationDelta: landscapeWindow ? -90 : 0
+
+ rotation: rotationDelta
+ width: main.baseWidth
+ height: main.baseHeight
+ anchors.centerIn: parent
+
+ Column {
+ id: box; spacing: 8
+
+ anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 }
+
+ Display {
+ id: display
+ width: box.width-3
+ height: 64
+ }
+
+ Column {
+ id: column; spacing: 6
+
+ property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6)
+ property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
+
+ Row {
+ spacing: 6
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "C" }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" }
+ }
+
+ Row {
+ spacing: 6
+ property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
+
+ Button { width: column.w; height: column.h; color: 'green'; operation: "mc" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "m+" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "m-" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "mr" }
+ }
+
+ Grid {
+ id: grid; rows: 5; columns: 5; spacing: 6
+
+ property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns)
+
+ Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: division }
+ Button { width: grid.w; height: column.h; operation: squareRoot }
+ Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: multiplication }
+ Button { width: grid.w; height: column.h; operation: "x^2" }
+ Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "-" }
+ Button { width: grid.w; height: column.h; operation: "1/x" }
+ Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "." }
+ Button { width: grid.w; height: column.h; operation: plusminus }
+ Button { width: grid.w; height: column.h; operation: "+" }
+ Button { width: grid.w; height: column.h; operation: "="; color: 'red' }
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "orientation " + Orientation.Landscape
+ PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
+ },
+ State {
+ name: "orientation " + Orientation.PortraitInverted
+ PropertyChanges { target: main; rotation: 180 + rotationDelta; }
+ },
+ State {
+ name: "orientation " + Orientation.LandscapeInverted
+ PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
+ }
+ ]
+
+ transitions: Transition {
+ SequentialAnimation {
+ RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint }
+ NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/calculator/calculator.qmlproject b/examples/declarative/calculator/calculator.qmlproject
new file mode 100644
index 0000000000..d4909f8685
--- /dev/null
+++ b/examples/declarative/calculator/calculator.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro
index cbeb7e9e26..c2950616a2 100644
--- a/examples/declarative/declarative.pro
+++ b/examples/declarative/declarative.pro
@@ -3,9 +3,10 @@ TEMPLATE = subdirs
# These examples contain some C++ and need to be built
SUBDIRS = \
cppextensions \
+ minehunt \
modelviews \
- tutorials \
- painteditem
+ painteditem \
+ tutorials
# plugins uses a 'Time' class that conflicts with symbian e32std.h also defining a class of the same name
symbian:SUBDIRS -= plugins
@@ -13,18 +14,27 @@ symbian:SUBDIRS -= plugins
# These examples contain no C++ and can simply be copied
sources.files = \
animation \
+ calculator \
cppextensions \
+ flickr \
i18n \
imageelements \
keyinteraction \
+ photoviewer \
positioners \
+ rssnews \
+ samegame \
+ snake \
sqllocalstorage \
text \
threading \
touchinteraction \
toys \
+ twitter \
ui-components \
+ webbrowser \
xml
+
sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative
INSTALLS += sources
diff --git a/examples/declarative/flickr/content/Button.qml b/examples/declarative/flickr/content/Button.qml
new file mode 100644
index 0000000000..7285753a0a
--- /dev/null
+++ b/examples/declarative/flickr/content/Button.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ signal clicked
+
+ property string text
+
+ BorderImage {
+ id: buttonImage
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ BorderImage {
+ id: pressed
+ opacity: 0
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ MouseArea {
+ id: mouseRegion
+ anchors.fill: buttonImage
+ onClicked: { container.clicked(); }
+ }
+ Text {
+ color: "white"
+ anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 15
+ text: container.text; style: Text.Raised; styleColor: "black"
+ }
+ states: [
+ State {
+ name: "Pressed"
+ when: mouseRegion.pressed == true
+ PropertyChanges { target: pressed; opacity: 1 }
+ }
+ ]
+}
diff --git a/examples/declarative/flickr/content/GridDelegate.qml b/examples/declarative/flickr/content/GridDelegate.qml
new file mode 100644
index 0000000000..5b7af23ea0
--- /dev/null
+++ b/examples/declarative/flickr/content/GridDelegate.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: wrapper; width: GridView.view.cellWidth; height: GridView.view.cellHeight
+
+ function photoClicked() {
+ imageDetails.photoTitle = title;
+ imageDetails.photoTags = tags;
+ imageDetails.photoWidth = photoWidth;
+ imageDetails.photoHeight = photoHeight;
+ imageDetails.photoType = photoType;
+ imageDetails.photoAuthor = photoAuthor;
+ imageDetails.photoDate = photoDate;
+ imageDetails.photoUrl = url;
+ imageDetails.rating = 0;
+ scaleMe.state = "Details";
+ }
+
+ Item {
+ anchors.centerIn: parent
+ scale: 0.0
+ Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} }
+ id: scaleMe
+
+ Item {
+ width: 77; height: 77; anchors.centerIn: parent
+ Rectangle {
+ id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true
+ Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true }
+ Image { source: "images/gloss.png" }
+ }
+ }
+
+ Connections {
+ target: toolBar
+ onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'
+ }
+
+ states: [
+ State {
+ name: "Show"; when: thumb.status == Image.Ready
+ PropertyChanges { target: scaleMe; scale: 1 }
+ },
+ State {
+ name: "Details"
+ PropertyChanges { target: scaleMe; scale: 1 }
+ ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer }
+ PropertyChanges { target: background; state: "DetailedView" }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "Show"; to: "Details"
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ },
+ Transition {
+ from: "Details"; to: "Show"
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ }
+ ]
+ }
+ MouseArea { anchors.fill: wrapper; onClicked: photoClicked() }
+}
+
diff --git a/examples/declarative/flickr/content/ImageDetails.qml b/examples/declarative/flickr/content/ImageDetails.qml
new file mode 100644
index 0000000000..74346466e3
--- /dev/null
+++ b/examples/declarative/flickr/content/ImageDetails.qml
@@ -0,0 +1,355 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Flipable {
+ id: container
+
+ property alias frontContainer: containerFront
+ property string photoTitle: ""
+ property string photoTags: ""
+ property int photoWidth
+ property int photoHeight
+ property string photoType
+ property string photoAuthor
+ property string photoDate
+ property string photoUrl
+ property int rating: 2
+ property variant prevScale: 1.0
+
+ property int flipDuration: 1600
+
+ signal closed
+
+ transform: Rotation {
+ id: itemRotation
+ origin.x: container.width / 2;
+ axis.y: 1; axis.z: 0
+ }
+
+ front: Item {
+ id: containerFront; anchors.fill: container
+
+ Rectangle {
+ anchors.fill: parent
+ color: "black"; opacity: 0.4
+ }
+
+ Column {
+ spacing: 10
+ anchors {
+ left: parent.left; leftMargin: 10
+ right: parent.right; rightMargin: 10
+ top: parent.top; topMargin: 120
+ }
+ Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Size: " + container.photoWidth + 'x' + container.photoHeight; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Type: " + container.photoType; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Author: " + container.photoAuthor; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Published: " + container.photoDate; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "Tags: "; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: container.photoTags; width: parent.width }
+ }
+ }
+
+ back: Item {
+ anchors.fill: container
+
+ Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 }
+
+ Progress {
+ anchors.centerIn: parent; width: 200; height: 22
+ progress: bigImage.progress; visible: bigImage.status != Image.Ready
+ }
+
+ Flickable {
+ id: flickable; anchors.fill: parent; clip: true
+ contentWidth: imageContainer.width; contentHeight: imageContainer.height
+
+ function updateMinimumScale() {
+ if (bigImage.status == Image.Ready && bigImage.width != 0) {
+ slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height);
+ if (bigImage.width * slider.value > flickable.width) {
+ var xoff = (flickable.width/2 + flickable.contentX) * slider.value / prevScale;
+ flickable.contentX = xoff - flickable.width/2;
+ }
+ if (bigImage.height * slider.value > flickable.height) {
+ var yoff = (flickable.height/2 + flickable.contentY) * slider.value / prevScale;
+ flickable.contentY = yoff - flickable.height/2;
+ }
+ prevScale = slider.value;
+ }
+ }
+
+ onWidthChanged: updateMinimumScale()
+ onHeightChanged: updateMinimumScale()
+
+ Item {
+ id: imageContainer
+ width: Math.max(bigImage.width * bigImage.scale, flickable.width);
+ height: Math.max(bigImage.height * bigImage.scale, flickable.height);
+ Image {
+ id: bigImage; source: container.photoUrl; scale: slider.value
+ anchors.centerIn: parent; smooth: !flickable.movingVertically
+ onStatusChanged : {
+ // Default scale shows the entire image.
+ if (bigImage.status == Image.Ready && bigImage.width != 0) {
+ slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height);
+ prevScale = Math.min(slider.minimum, 1);
+ slider.value = prevScale;
+ }
+ if (inBackState && bigImage.status == Image.Ready)
+ effectBox.imageInAnim();
+ }
+ property bool inBackState: false
+ onInBackStateChanged:{
+ if(inBackState && bigImage.status == Image.Ready)
+ effectBox.imageInAnim();
+ else if (!inBackState && bigImage.status == Image.Ready)
+ effectBox.imageOutAnim();
+ }
+ }
+ ShaderEffectSource{
+ id: pictureSource
+ sourceItem: bigImage
+ smooth: true
+ //Workaround: Doesn't work below lines
+ width: bigImage.width
+ height: bigImage.width
+ visible: false
+ }
+ Turbulence{//only fill visible rect
+ id: turbulence
+ system: imageSystem
+ anchors.fill: parent
+ frequency: 100
+ strength: 250
+ active: false
+ }
+
+ Item{
+ id: effectBox
+ width: bigImage.width * bigImage.scale
+ height: bigImage.height * bigImage.scale
+ anchors.centerIn: parent
+ function imageInAnim(){
+ bigImage.visible = false;
+ noiseIn.visible = true;
+ endEffectTimer.start();
+ }
+ function imageOutAnim(){
+ bigImage.visible = false;
+ noiseIn.visible = false;
+ turbulence.active = true;
+ endEffectTimer.start();
+ pixelEmitter.burst(2048);
+ }
+ Timer{
+ id: endEffectTimer
+ interval: flipDuration
+ repeat: false
+ running: false
+ onTriggered:{
+ turbulence.active = false;
+ noiseIn.visible = false;
+ bigImage.visible = true;
+ }
+ }
+ ShaderEffectItem{
+ id: noiseIn
+ anchors.fill: parent
+ property real t: 0
+ visible: false
+ onVisibleChanged: tAnim.start()
+ NumberAnimation{
+ id: tAnim
+ target: noiseIn
+ property: "t"
+ from: 0.0
+ to: 1.0
+ duration: flipDuration
+ }
+ property variant source: pictureSource
+ property variant noise: ShaderEffectSource{
+ sourceItem:Image{
+ source: "images/noise.png"
+ }
+ hideSource: true
+ smooth: false
+ }
+ fragmentShader:"
+ uniform sampler2D noise;
+ uniform sampler2D source;
+ uniform highp float t;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main(){
+ //Want to use noise2, but it always returns (0,0)?
+ if(texture2D(noise, qt_TexCoord0).w <= t)
+ gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity;
+ else
+ gl_FragColor = vec4(0.,0.,0.,0.);
+ }
+ "
+ }
+ ParticleSystem{
+ id: imageSystem
+ }
+ Emitter{
+ id: pixelEmitter
+ system: imageSystem
+ //anchors.fill: parent
+ width: Math.min(bigImage.width * bigImage.scale, flickable.width);
+ height: Math.min(bigImage.height * bigImage.scale, flickable.height);
+ anchors.centerIn: parent
+ size: 4
+ lifeSpan: flipDuration
+ emitRate: 2048
+ emitting: false
+ }
+ CustomParticle{
+ id: blowOut
+ system: imageSystem
+ property real maxWidth: effectBox.width
+ property real maxHeight: effectBox.height
+ vertexShader:"
+ attribute highp vec2 vPos;
+ attribute highp vec2 vTex;
+ attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
+ attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
+ attribute highp float r;
+
+ uniform highp float maxWidth;
+ uniform highp float maxHeight;
+
+ uniform highp mat4 qt_ModelViewProjectionMatrix;
+ uniform highp float timestamp;
+ uniform lowp float qt_Opacity;
+
+ varying highp vec2 fTex2;
+ varying lowp float fFade;
+
+ void main() {
+ fTex2 = vec2(vPos.x / maxWidth, vPos.y / maxHeight);
+ highp float size = vData.z;
+ highp float endSize = vData.w;
+
+ highp float t = (timestamp - vData.x) / vData.y;
+
+ highp float currentSize = mix(size, endSize, t * t);
+
+ if (t < 0. || t > 1.)
+ currentSize = 0.;
+
+ highp vec2 pos = vPos
+ - currentSize / 2. + currentSize * vTex // adjust size
+ + vVec.xy * t * vData.y // apply speed vector..
+ + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+
+ gl_Position = qt_ModelViewProjectionMatrix * vec4(pos.x, pos.y, 0, 1);
+
+ highp float fadeIn = min(t * 10., 1.);
+ highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+ fFade = 1.0;//fadeIn * fadeOut * qt_Opacity;
+ }
+ "
+ property variant pictureTexture: pictureSource
+ fragmentShader: "
+ uniform sampler2D pictureTexture;
+ varying highp vec2 fTex2;
+ varying highp float fFade;
+ void main() {
+ gl_FragColor = texture2D(pictureTexture, fTex2) * fFade;
+ }"
+ }
+
+
+
+ }
+ }
+ }
+
+ Text {
+ text: "Image Unavailable"
+ visible: bigImage.status == Image.Error
+ anchors.centerIn: parent; color: "white"; font.bold: true
+ }
+
+ Slider {
+ id: slider; visible: { bigImage.status == Image.Ready && maximum > minimum }
+ anchors {
+ bottom: parent.bottom; bottomMargin: 65
+ left: parent.left; leftMargin: 25
+ right: parent.right; rightMargin: 25
+ }
+ onValueChanged: {
+ if (bigImage.width * value > flickable.width) {
+ var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale;
+ flickable.contentX = xoff - flickable.width/2;
+ }
+ if (bigImage.height * value > flickable.height) {
+ var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale;
+ flickable.contentY = yoff - flickable.height/2;
+ }
+ prevScale = value;
+ }
+ }
+ }
+
+ states: State {
+ name: "Back"
+ PropertyChanges { target: itemRotation; angle: 180 }
+ PropertyChanges { target: toolBar; button2Visible: false }
+ PropertyChanges { target: toolBar; button1Label: "Back" }
+ PropertyChanges { target: bigImage; inBackState: true }
+ }
+
+ transitions: Transition {
+ SequentialAnimation {
+ PropertyAction { target: bigImage; property: "smooth"; value: false }
+ NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: flipDuration }
+ PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically }
+ }
+ }
+}
diff --git a/examples/declarative/flickr/content/ListDelegate.qml b/examples/declarative/flickr/content/ListDelegate.qml
new file mode 100644
index 0000000000..b65704867b
--- /dev/null
+++ b/examples/declarative/flickr/content/ListDelegate.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Component {
+ Item {
+ id: wrapper; width: wrapper.ListView.view.width; height: 86
+ Item {
+ id: moveMe
+ Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
+ Rectangle {
+ x: 6; y: 4; width: 77; height: 77; color: "white"; smooth: true
+
+ Image { source: imagePath; x: 1; y: 1 }
+ Image { source: "images/gloss.png" }
+ }
+ Column {
+ x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2
+ Text { text: title; color: "white"; width: parent.width; font.pixelSize: 14; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" }
+ Text { text: photoAuthor; width: parent.width; font.pixelSize: 14; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
+ Text { text: photoDate; width: parent.width; font.pixelSize: 14; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/flickr/content/Progress.qml b/examples/declarative/flickr/content/Progress.qml
new file mode 100644
index 0000000000..73a91a4aa9
--- /dev/null
+++ b/examples/declarative/flickr/content/Progress.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item{
+ id: container
+ property variant progress: 0
+
+ Rectangle {
+ anchors.fill: parent; smooth: true
+ border.color: "white"; border.width: 0; radius: height/2 - 2
+ gradient: Gradient {
+ GradientStop { position: 0; color: "#66343434" }
+ GradientStop { position: 1.0; color: "#66000000" }
+ }
+ }
+
+ ParticleSystem{
+ running: container.visible
+ id: barSys
+ }
+ ImageParticle{
+ color: "lightsteelblue"
+ alpha: 0.1
+ colorVariation: 0.05
+ source: "images/particle.png"
+ system: barSys
+ }
+ Emitter{
+ y: 2; height: parent.height-4;
+ x: 2; width: Math.max(parent.width * progress - 4, 0);
+ speed: AngledDirection{ angleVariation: 180; magnitudeVariation: 12 }
+ system: barSys
+ emitRate: width;
+ lifeSpan: 1000
+ size: 20
+ sizeVariation: 4
+ endSize: 12
+ emitCap: parent.width;
+ }
+
+ Text {
+ text: Math.round(progress * 100) + "%"
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ color: Qt.rgba(1.0, 1.0 - progress, 1.0 - progress,0.9); font.bold: true; font.pixelSize: 15
+ }
+}
diff --git a/examples/declarative/flickr/content/RssModel.qml b/examples/declarative/flickr/content/RssModel.qml
new file mode 100644
index 0000000000..007f086830
--- /dev/null
+++ b/examples/declarative/flickr/content/RssModel.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+XmlListModel {
+ property string tags : ""
+
+ function commasep(x)
+ {
+ return x.replace(' ',',');
+ }
+
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+commasep(tags)+"&" : "")+"format=rss2"
+ query: "/rss/channel/item"
+ namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" }
+ XmlRole { name: "url"; query: "media:content/@url/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ XmlRole { name: "tags"; query: "media:category/string()" }
+ XmlRole { name: "photoWidth"; query: "media:content/@width/string()" }
+ XmlRole { name: "photoHeight"; query: "media:content/@height/string()" }
+ XmlRole { name: "photoType"; query: "media:content/@type/string()" }
+ XmlRole { name: "photoAuthor"; query: "author/string()" }
+ XmlRole { name: "photoDate"; query: "pubDate/string()" }
+}
diff --git a/examples/declarative/flickr/content/ScrollBar.qml b/examples/declarative/flickr/content/ScrollBar.qml
new file mode 100644
index 0000000000..7d2d9ff7d3
--- /dev/null
+++ b/examples/declarative/flickr/content/ScrollBar.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property variant flickableArea
+
+ Rectangle {
+ radius: 5
+ color: "black"
+ opacity: 0.3
+ border.color: "white"
+ border.width: 2
+ x: 0
+ y: flickableArea.visibleArea.yPosition * container.height
+ width: parent.width
+ height: flickableArea.visibleArea.heightRatio * container.height
+ }
+ states: [
+ State {
+ name: "show"
+ when: flickableArea.movingVertically
+ PropertyChanges {
+ target: container
+ opacity: 1
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "*"
+ NumberAnimation {
+ target: container
+ properties: "opacity"
+ duration: 400
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/flickr/content/Slider.qml b/examples/declarative/flickr/content/Slider.qml
new file mode 100644
index 0000000000..b4a2960ac8
--- /dev/null
+++ b/examples/declarative/flickr/content/Slider.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: slider; width: 400; height: 16
+
+ // value is read/write.
+ property real value: 1
+ onValueChanged: updatePos();
+ property real maximum: 1
+ property real minimum: 1
+ property int xMax: width - handle.width - 4
+ onXMaxChanged: updatePos();
+ onMinimumChanged: updatePos();
+
+ function updatePos() {
+ if (maximum > minimum) {
+ var pos = 2 + (value - minimum) * slider.xMax / (maximum - minimum);
+ pos = Math.min(pos, width - handle.width - 2);
+ pos = Math.max(pos, 2);
+ handle.x = pos;
+ } else {
+ handle.x = 2;
+ }
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ border.color: "white"; border.width: 0; radius: 8
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#66343434" }
+ GradientStop { position: 1.0; color: "#66000000" }
+ }
+ }
+
+ Rectangle {
+ id: handle; smooth: true
+ y: 2; width: 30; height: slider.height-4; radius: 6
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightgray" }
+ GradientStop { position: 1.0; color: "gray" }
+ }
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent; drag.target: parent
+ drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: slider.xMax+2
+ onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; }
+ }
+ }
+}
diff --git a/examples/declarative/flickr/content/StreamView.qml b/examples/declarative/flickr/content/StreamView.qml
new file mode 100644
index 0000000000..e2c65e22fe
--- /dev/null
+++ b/examples/declarative/flickr/content/StreamView.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item{
+ id: container
+ property alias model: mp.model
+ property alias delegate: mp.delegate
+ property bool jumpStarted: false
+ ParticleSystem{
+ id: sys
+ anchors.fill:parent
+ }
+ ModelParticle{
+ id: mp
+ fade: false
+ system: sys
+ anchors.fill: parent
+ onModelCountChanged: {
+ if(!jumpStarted && modelCount > 0){
+ console.log("Jumping");
+ jumpStarted = true;
+ sys.fastForward(8000);
+ }
+ }
+ }
+ property real emitterSpacing: parent.width/3
+ Emitter{
+ system: sys
+ width: emitterSpacing - 64
+ x: emitterSpacing*0 + 32
+ y: -128
+ height: 32
+ speed: PointDirection{ y: (container.height + 128)/12 }
+ emitRate: 0.4
+ lifeSpan: 1000000//eventually -1 should mean a million seconds for neatness
+ emitCap: 15
+ }
+ Emitter{
+ system: sys
+ width: emitterSpacing - 64
+ x: emitterSpacing*1 + 32
+ y: -128
+ height: 32
+ speed: PointDirection{ y: (container.height + 128)/12 }
+ emitRate: 0.4
+ lifeSpan: 1000000//eventually -1 should mean a million seconds for neatness
+ emitCap: 15
+ }
+ Emitter{
+ system: sys
+ width: emitterSpacing - 64
+ x: emitterSpacing*2 + 32
+ y: -128
+ height: 32
+ speed: PointDirection{ y: (container.height + 128)/12 }
+ emitRate: 0.4
+ lifeSpan: 1000000//eventually -1 should mean a million seconds for neatness
+ emitCap: 15
+ }
+ Kill{
+ system: sys
+ y: container.height + 64
+ width: container.width
+ height: 6400
+ }
+}
diff --git a/examples/declarative/flickr/content/TitleBar.qml b/examples/declarative/flickr/content/TitleBar.qml
new file mode 100644
index 0000000000..381d252ed3
--- /dev/null
+++ b/examples/declarative/flickr/content/TitleBar.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: titleBar
+ property string untaggedString: "Uploads from everyone"
+ property string taggedString: "Recent uploads tagged "
+
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+
+ Item {
+ id: container
+ width: (parent.width * 2) - 55 ; height: parent.height
+
+ function accept() {
+ imageDetails.closed()
+ titleBar.state = ""
+ background.state = ""
+ rssModel.tags = editor.text
+ }
+
+ Image {
+ id: quitButton
+ anchors.left: parent.left//; anchors.leftMargin: 0
+ anchors.verticalCenter: parent.verticalCenter
+ source: "images/quit.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+
+ Text {
+ id: categoryText
+ anchors {
+ left: quitButton.right; right: tagButton.left; leftMargin: 10; rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ elide: Text.ElideLeft
+ text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags)
+ font.bold: true; font.pixelSize: 15; color: "White"; style: Text.Raised; styleColor: "Black"
+ }
+
+ Button {
+ id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..."
+ onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags"
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Item {
+ id: lineEdit
+ y: 4; height: parent.height - 9
+ anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 }
+
+ BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
+
+ TextInput {
+ id: editor
+ anchors {
+ left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ cursorVisible: true; font.bold: true
+ color: "#151515"; selectionColor: "Green"
+ }
+
+ Keys.forwardTo: [ (returnKey), (editor)]
+
+ Item {
+ id: returnKey
+ Keys.onReturnPressed: container.accept()
+ Keys.onEnterPressed: container.accept()
+ Keys.onEscapePressed: titleBar.state = ""
+ }
+ }
+ }
+
+ states: State {
+ name: "Tags"
+ PropertyChanges { target: container; x: -tagButton.x + 5 }
+ PropertyChanges { target: tagButton; text: "OK" }
+ PropertyChanges { target: editor; focus: true }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad }
+ }
+}
diff --git a/examples/declarative/flickr/content/ToolBar.qml b/examples/declarative/flickr/content/ToolBar.qml
new file mode 100644
index 0000000000..ca5341e101
--- /dev/null
+++ b/examples/declarative/flickr/content/ToolBar.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: toolbar
+
+ property alias button1Label: button1.text
+ property alias button2Label: button2.text
+ property alias button2Visible: button2.visible
+
+ signal button1Clicked
+ signal button2Clicked
+
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+
+ Row {
+ anchors.right: parent.right; anchors.rightMargin: 5; y: 3; height: 32; spacing: 30
+ Button {
+ id: button1
+ width: 140; height: 32
+ onClicked: toolbar.button1Clicked()
+ }
+
+ Button {
+ id: button2; width: 140; height: 32
+ onClicked: toolbar.button2Clicked()
+ }
+ }
+}
diff --git a/examples/declarative/flickr/content/UnifiedDelegate.qml b/examples/declarative/flickr/content/UnifiedDelegate.qml
new file mode 100644
index 0000000000..f4c926763f
--- /dev/null
+++ b/examples/declarative/flickr/content/UnifiedDelegate.qml
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Package {
+ function photoClicked() {
+ imageDetails.photoTitle = title;
+ imageDetails.photoTags = tags;
+ imageDetails.photoWidth = photoWidth;
+ imageDetails.photoHeight = photoHeight;
+ imageDetails.photoType = photoType;
+ imageDetails.photoAuthor = photoAuthor;
+ imageDetails.photoDate = photoDate;
+ imageDetails.photoUrl = url;
+ imageDetails.rating = 0;
+ scaleMe.state = "Details";
+ }
+
+ Item {
+ id: gridwrapper;
+ width: GridView.view.cellWidth; height: GridView.view.cellHeight
+ Package.name: "grid"
+ }
+ Item {
+ id: streamwrapper;
+ width: 80; height: 80
+ Package.name: "stream"
+ function pleaseFreeze(){
+ ModelParticle.particle.freeze(streamwrapper);
+ }
+ function pleaseUnfreeze(){
+ ModelParticle.particle.unfreeze(streamwrapper);
+ }
+ }
+ Item {
+ //anchors.centerIn: parent//Doesn't animate :(
+ width: 80; height: 80
+ scale: 0.0
+ Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} }
+ id: scaleMe
+
+ Item {
+ id: whiteRectContainer
+ width: 77; height: 77; anchors.centerIn: parent
+ Rectangle {
+ id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true
+ x:0; y:0
+ Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true }
+ Image { source: "images/gloss.png" }
+ MouseArea { anchors.fill: parent; onClicked: photoClicked() }
+ }
+ }
+
+ Connections {
+ target: toolBar
+ onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'
+ }
+
+ state: 'inStream'
+ states: [
+ State {
+ name: "Show"; when: thumb.status == Image.Ready
+ PropertyChanges { target: scaleMe; scale: 1; }
+ },
+ State {
+ name: "Details"
+ PropertyChanges { target: scaleMe; scale: 1 }
+ ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer }
+ PropertyChanges { target: background; state: "DetailedView" }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "Show"; to: "Details"
+ ScriptAction{ script: streamwrapper.pleaseFreeze(); }
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ },
+ Transition {
+ from: "Details"; to: "Show"
+ SequentialAnimation{
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ ScriptAction{ script: streamwrapper.pleaseUnfreeze(); }
+ }
+ }
+ ]
+ Item{
+ id: stateContainer
+ states: [
+ State {
+ name: 'inStream'
+ when: screen.inGridView == false
+ ParentChange {
+ target: scaleMe; parent: streamwrapper
+ x: 0; y: 0;
+ }
+ },
+ State {
+ name: 'inGrid'
+ when: screen.inGridView == true
+ ParentChange {
+ target: scaleMe; parent: gridwrapper
+ x: 0; y: 0;
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParentAnimation {
+ NumberAnimation { target: scaleMe; properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/declarative/flickr/content/images/gloss.png b/examples/declarative/flickr/content/images/gloss.png
new file mode 100644
index 0000000000..5d370cd93d
--- /dev/null
+++ b/examples/declarative/flickr/content/images/gloss.png
Binary files differ
diff --git a/examples/declarative/flickr/content/images/lineedit.png b/examples/declarative/flickr/content/images/lineedit.png
new file mode 100644
index 0000000000..2cc38dc35b
--- /dev/null
+++ b/examples/declarative/flickr/content/images/lineedit.png
Binary files differ
diff --git a/examples/declarative/flickr/content/images/lineedit.sci b/examples/declarative/flickr/content/images/lineedit.sci
new file mode 100644
index 0000000000..054bff78be
--- /dev/null
+++ b/examples/declarative/flickr/content/images/lineedit.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 10
+border.bottom: 10
+border.right: 10
+source: lineedit.png
diff --git a/examples/declarative/flickr/content/images/noise.png b/examples/declarative/flickr/content/images/noise.png
new file mode 100644
index 0000000000..c5a5ba0053
--- /dev/null
+++ b/examples/declarative/flickr/content/images/noise.png
Binary files differ
diff --git a/examples/declarative/flickr/content/images/particle.png b/examples/declarative/flickr/content/images/particle.png
new file mode 100644
index 0000000000..dbc39cb16e
--- /dev/null
+++ b/examples/declarative/flickr/content/images/particle.png
Binary files differ
diff --git a/examples/declarative/flickr/content/images/quit.png b/examples/declarative/flickr/content/images/quit.png
new file mode 100644
index 0000000000..5bda1b6e0d
--- /dev/null
+++ b/examples/declarative/flickr/content/images/quit.png
Binary files differ
diff --git a/examples/declarative/flickr/content/images/squareParticle.png b/examples/declarative/flickr/content/images/squareParticle.png
new file mode 100644
index 0000000000..faf85c24e0
--- /dev/null
+++ b/examples/declarative/flickr/content/images/squareParticle.png
Binary files differ
diff --git a/examples/declarative/flickr/content/images/stripes.png b/examples/declarative/flickr/content/images/stripes.png
new file mode 100644
index 0000000000..9f36727ea4
--- /dev/null
+++ b/examples/declarative/flickr/content/images/stripes.png
Binary files differ
diff --git a/examples/declarative/flickr/content/images/titlebar.png b/examples/declarative/flickr/content/images/titlebar.png
new file mode 100644
index 0000000000..51c90082d0
--- /dev/null
+++ b/examples/declarative/flickr/content/images/titlebar.png
Binary files differ
diff --git a/examples/declarative/flickr/content/images/titlebar.sci b/examples/declarative/flickr/content/images/titlebar.sci
new file mode 100644
index 0000000000..0418d94cd6
--- /dev/null
+++ b/examples/declarative/flickr/content/images/titlebar.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 12
+border.bottom: 12
+border.right: 10
+source: titlebar.png
diff --git a/examples/declarative/flickr/content/images/toolbutton.png b/examples/declarative/flickr/content/images/toolbutton.png
new file mode 100644
index 0000000000..11310013ee
--- /dev/null
+++ b/examples/declarative/flickr/content/images/toolbutton.png
Binary files differ
diff --git a/examples/declarative/flickr/content/images/toolbutton.sci b/examples/declarative/flickr/content/images/toolbutton.sci
new file mode 100644
index 0000000000..9e4f965307
--- /dev/null
+++ b/examples/declarative/flickr/content/images/toolbutton.sci
@@ -0,0 +1,5 @@
+border.left: 15
+border.top: 4
+border.bottom: 4
+border.right: 15
+source: toolbutton.png
diff --git a/examples/declarative/flickr/content/qmldir b/examples/declarative/flickr/content/qmldir
new file mode 100644
index 0000000000..adc2479b9f
--- /dev/null
+++ b/examples/declarative/flickr/content/qmldir
@@ -0,0 +1,10 @@
+ImageDetails ImageDetails.qml
+LikeOMeter LikeOMeter.qml
+Loading Loading.qml
+MediaButton MediaButton.qml
+MediaLineEdit MediaLineEdit.qml
+Progress Progress.qml
+RssModel RssModel.qml
+ScrollBar ScrollBar.qml
+Slider Slider.qml
+Star Star.qml
diff --git a/examples/declarative/flickr/flickr-90.qml b/examples/declarative/flickr/flickr-90.qml
new file mode 100644
index 0000000000..ce22d8a3a9
--- /dev/null
+++ b/examples/declarative/flickr/flickr-90.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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
+
+Item {
+ width: 480; height: 320
+
+ Loader {
+ y: 320; rotation: -90
+ transformOrigin: Item.TopLeft
+ source: "flickr.qml"
+ }
+}
diff --git a/examples/declarative/flickr/flickr.qml b/examples/declarative/flickr/flickr.qml
new file mode 100644
index 0000000000..a222b41341
--- /dev/null
+++ b/examples/declarative/flickr/flickr.qml
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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"
+
+Item {
+ id: screen; width: 320; height: 480
+ property bool inGridView : false
+
+ Rectangle {
+ id: background
+ anchors.fill: parent; color: "#343434";
+
+ Image { source: "content/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
+ ParticleSystem {
+ id: bgParticles
+ startTime: 16000
+ }
+ ImageParticle {
+ particles: ["trail"]
+ source: "content/images/particle.png"
+ color: "#1A1A6F"
+ alpha: 0.1
+ colorVariation: 0.01
+ blueVariation: 0.8
+ system: bgParticles
+ }
+ Emitter {
+ particle: "drops"
+ width: parent.width
+ emitRate: 0.5
+ lifeSpan: 20000
+ speed: PointDirection{
+ y: {screen.height/18}
+ }
+ system: bgParticles
+ }
+ FollowEmitter {
+ follow: "drops"
+ particle: "trail"
+ emitRatePerParticle: 18
+ size: 32
+ endSize: 0
+ sizeVariation: 4
+ lifeSpan: 1200
+ system: bgParticles
+ anchors.fill: parent
+ emitWidth: 16
+ emitHeight: 16
+ emitShape: EllipseShape{}
+ }
+
+ VisualDataModel{
+ id: vdm
+ delegate: UnifiedDelegate{}
+ model: RssModel { id: rssModel }
+ }
+
+ Item {
+ id: views
+ width: parent.width
+ anchors.top: titleBar.bottom; anchors.bottom: toolBar.top
+
+ GridView {
+ id: photoGridView; model: vdm.parts.grid
+ cacheBuffer: 1000
+ cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height
+ }
+
+ StreamView{
+ id: photoStreamView
+ model: vdm.parts.stream
+ width: parent.width; height: parent.height
+ }
+
+ states: State {
+ name: "GridView"; when: screen.inGridView == true
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+
+ ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height }
+
+ Item { id: foreground; anchors.fill: parent }
+ }
+
+ TitleBar { id: titleBar; width: parent.width; height: 40; opacity: 0.9 }
+
+ ToolBar {
+ id: toolBar
+ height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9
+ button1Label: "Update"; button2Label: "View mode"
+ onButton1Clicked: rssModel.reload()
+ onButton2Clicked: if (screen.inGridView == true) screen.inGridView = false; else screen.inGridView = true
+ }
+
+ Connections {
+ target: imageDetails
+ onClosed: {
+ if (background.state == "DetailedView") {
+ background.state = '';
+ imageDetails.photoUrl = "";
+ }
+ }
+ }
+
+ states: State {
+ name: "DetailedView"
+ PropertyChanges { target: views; x: -parent.width }
+ PropertyChanges { target: toolBar; button1Label: "View..." }
+ PropertyChanges {
+ target: toolBar
+ onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state=''
+ }
+ PropertyChanges { target: toolBar; button2Label: "Back" }
+ PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+
+ }
+}
diff --git a/examples/declarative/flickr/flickr.qmlproject b/examples/declarative/flickr/flickr.qmlproject
new file mode 100644
index 0000000000..d4909f8685
--- /dev/null
+++ b/examples/declarative/flickr/flickr.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/declarative/minehunt/MinehuntCore/Explosion.qml b/examples/declarative/minehunt/MinehuntCore/Explosion.qml
new file mode 100644
index 0000000000..a5f3f1bc31
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/Explosion.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+import Qt.labs.particles 1.0
+
+Item {
+ property bool explode : false
+
+ Particles {
+ id: particles
+ width: 40
+ height: 40
+ lifeSpan: 1000
+ lifeSpanDeviation: 0
+ source: "pics/star.png"
+ count: 0
+ angle: 270
+ angleDeviation: 360
+ velocity: 100
+ velocityDeviation: 20
+ z: 100
+ }
+ states: State { name: "exploding"; when: explode
+ StateChangeScript {script: particles.burst(200); }
+ }
+
+}
diff --git a/examples/declarative/minehunt/MinehuntCore/Tile.qml b/examples/declarative/minehunt/MinehuntCore/Tile.qml
new file mode 100644
index 0000000000..90247f8575
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/Tile.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Flipable {
+ id: flipable
+ property int angle: 0
+
+ width: 40; height: 40
+ transform: Rotation { origin.x: 20; origin.y: 20; axis.x: 1; axis.z: 0; angle: flipable.angle }
+
+ front: Image {
+ source: "pics/front.png"; width: 40; height: 40
+
+ Image {
+ anchors.centerIn: parent
+ source: "pics/flag.png"; opacity: modelData.hasFlag
+
+ Behavior on opacity { NumberAnimation {} }
+ }
+ }
+
+ back: Image {
+ source: "pics/back.png"
+ width: 40; height: 40
+
+ Text {
+ anchors.centerIn: parent
+ text: modelData.hint; color: "white"; font.bold: true
+ opacity: !modelData.hasMine && modelData.hint > 0
+ }
+
+ Image {
+ anchors.centerIn: parent
+ source: "pics/bomb.png"; opacity: modelData.hasMine
+ }
+
+ Explosion { id: expl }
+ }
+
+ states: State {
+ name: "back"; when: modelData.flipped
+ PropertyChanges { target: flipable; angle: 180 }
+ }
+
+ property real pauseDur: 250
+ transitions: Transition {
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ var ret = Math.abs(flipable.x - field.clickx)
+ + Math.abs(flipable.y - field.clicky);
+ if (modelData.hasMine && modelData.flipped)
+ pauseDur = ret * 3
+ else
+ pauseDur = ret
+ }
+ }
+ PauseAnimation {
+ duration: pauseDur
+ }
+ RotationAnimation { easing.type: Easing.InOutQuad }
+ ScriptAction { script: if (modelData.hasMine && modelData.flipped) { expl.explode = true } }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ field.clickx = flipable.x
+ field.clicky = flipable.y
+ var row = Math.floor(index / 9)
+ var col = index - (Math.floor(index / 9) * 9)
+ if (mouse.button == undefined || mouse.button == Qt.RightButton) {
+ flag(row, col)
+ } else {
+ flip(row, col)
+ }
+ }
+ onPressAndHold: {
+ field.clickx = flipable.x
+ field.clicky = flipable.y
+ var row = Math.floor(index / 9)
+ var col = index - (Math.floor(index / 9) * 9)
+ flag(row, col)
+ }
+ }
+}
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/back.png b/examples/declarative/minehunt/MinehuntCore/pics/back.png
new file mode 100644
index 0000000000..f6b3f0b4d7
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/back.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/background.png b/examples/declarative/minehunt/MinehuntCore/pics/background.png
new file mode 100644
index 0000000000..3734a27744
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/background.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/bomb-color.png b/examples/declarative/minehunt/MinehuntCore/pics/bomb-color.png
new file mode 100644
index 0000000000..61ad0a928f
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/bomb-color.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/bomb.png b/examples/declarative/minehunt/MinehuntCore/pics/bomb.png
new file mode 100644
index 0000000000..a992575518
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/bomb.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/face-sad.png b/examples/declarative/minehunt/MinehuntCore/pics/face-sad.png
new file mode 100644
index 0000000000..cf00aafe1f
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/face-sad.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.png b/examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.png
new file mode 100644
index 0000000000..f9c2335df5
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/face-smile.png b/examples/declarative/minehunt/MinehuntCore/pics/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/face-smile.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/flag-color.png b/examples/declarative/minehunt/MinehuntCore/pics/flag-color.png
new file mode 100644
index 0000000000..aadad0f11a
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/flag-color.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/flag.png b/examples/declarative/minehunt/MinehuntCore/pics/flag.png
new file mode 100644
index 0000000000..39cde4df82
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/flag.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/front.png b/examples/declarative/minehunt/MinehuntCore/pics/front.png
new file mode 100644
index 0000000000..834331bd49
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/front.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/quit.png b/examples/declarative/minehunt/MinehuntCore/pics/quit.png
new file mode 100644
index 0000000000..b822057d4e
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/quit.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/pics/star.png b/examples/declarative/minehunt/MinehuntCore/pics/star.png
new file mode 100644
index 0000000000..3772359188
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/pics/star.png
Binary files differ
diff --git a/examples/declarative/minehunt/MinehuntCore/qmldir b/examples/declarative/minehunt/MinehuntCore/qmldir
new file mode 100644
index 0000000000..81980e09a6
--- /dev/null
+++ b/examples/declarative/minehunt/MinehuntCore/qmldir
@@ -0,0 +1,2 @@
+Explosion 1.0 Explosion.qml
+Tile 1.0 Tile.qml
diff --git a/examples/declarative/minehunt/README b/examples/declarative/minehunt/README
new file mode 100644
index 0000000000..3849ca5fbf
--- /dev/null
+++ b/examples/declarative/minehunt/README
@@ -0,0 +1,6 @@
+Minehunt has to be compiled to run.
+
+To compile the C++ part, do 'qmake && make'.
+To run, simply run the executable.
+To deploy on a device, do 'make sis'.
+
diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp
new file mode 100644
index 0000000000..9e7ab5f120
--- /dev/null
+++ b/examples/declarative/minehunt/main.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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$
+**
+****************************************************************************/
+
+#include <QtGui/QApplication>
+#include <QtDeclarative/QDeclarativeView>
+#include <QtDeclarative/QDeclarativeContext>
+#include <QtDeclarative/QDeclarativeEngine>
+
+#include "minehunt.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QDeclarativeView canvas;
+
+ qmlRegisterType<TileData>();
+ MinehuntGame* game = new MinehuntGame();
+
+#ifdef Q_OS_SYMBIAN
+ canvas.setResizeMode(QDeclarativeView::SizeRootObjectToView);
+#endif
+ canvas.engine()->rootContext()->setContextObject(game);
+ canvas.setSource(QString("qrc:minehunt.qml"));
+ QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit()));
+
+#ifdef Q_OS_SYMBIAN
+ canvas.showFullScreen();
+#else
+ canvas.setGeometry(QRect(100, 100, 450, 450));
+ canvas.show();
+#endif
+ return app.exec();
+}
diff --git a/examples/declarative/minehunt/minehunt.cpp b/examples/declarative/minehunt/minehunt.cpp
new file mode 100644
index 0000000000..c95f234ab3
--- /dev/null
+++ b/examples/declarative/minehunt/minehunt.cpp
@@ -0,0 +1,221 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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$
+**
+****************************************************************************/
+
+#include <stdlib.h>
+#include <QTime>
+#include <QTimer>
+
+#include "minehunt.h"
+
+void tilesPropAppend(QDeclarativeListProperty<TileData>* prop, TileData* value)
+{
+ Q_UNUSED(prop);
+ Q_UNUSED(value);
+ return; //Append not supported
+}
+
+int tilesPropCount(QDeclarativeListProperty<TileData>* prop)
+{
+ return static_cast<QList<TileData*>*>(prop->data)->count();
+}
+
+TileData* tilesPropAt(QDeclarativeListProperty<TileData>* prop, int index)
+{
+ return static_cast<QList<TileData*>*>(prop->data)->at(index);
+}
+
+QDeclarativeListProperty<TileData> MinehuntGame::tiles(){
+ return QDeclarativeListProperty<TileData>(this, &_tiles, &tilesPropAppend,
+ &tilesPropCount, &tilesPropAt, 0);
+}
+
+MinehuntGame::MinehuntGame()
+: numCols(9), numRows(9), playing(true), won(false)
+{
+ setObjectName("mainObject");
+ srand(QTime(0,0,0).secsTo(QTime::currentTime()));
+
+ //initialize array
+ for(int ii = 0; ii < numRows * numCols; ++ii) {
+ _tiles << new TileData;
+ }
+ reset();
+
+}
+
+void MinehuntGame::setBoard()
+{
+ foreach(TileData* t, _tiles){
+ t->setHasMine(false);
+ t->setHint(-1);
+ }
+ //place mines
+ int mines = nMines;
+ remaining = numRows*numCols-mines;
+ while ( mines ) {
+ int col = int((double(rand()) / double(RAND_MAX)) * numCols);
+ int row = int((double(rand()) / double(RAND_MAX)) * numRows);
+
+ TileData* t = tile( row, col );
+
+ if (t && !t->hasMine()) {
+ t->setHasMine( true );
+ mines--;
+ }
+ }
+
+ //set hints
+ for (int r = 0; r < numRows; r++)
+ for (int c = 0; c < numCols; c++) {
+ TileData* t = tile(r, c);
+ if (t && !t->hasMine()) {
+ int hint = getHint(r,c);
+ t->setHint(hint);
+ }
+ }
+
+ setPlaying(true);
+}
+
+void MinehuntGame::reset()
+{
+ foreach(TileData* t, _tiles){
+ t->unflip();
+ t->setHasFlag(false);
+ }
+ nMines = 12;
+ nFlags = 0;
+ emit numMinesChanged();
+ emit numFlagsChanged();
+ setPlaying(false);
+ QTimer::singleShot(600,this, SLOT(setBoard()));
+}
+
+int MinehuntGame::getHint(int row, int col)
+{
+ int hint = 0;
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData* t = tile(r, c);
+ if (t && t->hasMine())
+ hint++;
+ }
+ return hint;
+}
+
+bool MinehuntGame::flip(int row, int col)
+{
+ if(!playing)
+ return false;
+
+ TileData *t = tile(row, col);
+ if (!t || t->hasFlag())
+ return false;
+
+ if(t->flipped()){
+ int flags = 0;
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData *nearT = tile(r, c);
+ if(!nearT || nearT == t)
+ continue;
+ if(nearT->hasFlag())
+ flags++;
+ }
+ if(!t->hint() || t->hint() != flags)
+ return false;
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData *nearT = tile(r, c);
+ if (nearT && !nearT->flipped() && !nearT->hasFlag()) {
+ flip( r, c );
+ }
+ }
+ return true;
+ }
+
+ t->flip();
+
+ if (t->hint() == 0) {
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData* t = tile(r, c);
+ if (t && !t->flipped()) {
+ flip( r, c );
+ }
+ }
+ }
+
+ if(t->hasMine()){
+ for (int r = 0; r < numRows; r++)//Flip all other mines
+ for (int c = 0; c < numCols; c++) {
+ TileData* t = tile(r, c);
+ if (t && t->hasMine()) {
+ flip(r, c);
+ }
+ }
+ won = false;
+ hasWonChanged();
+ setPlaying(false);
+ return true;
+ }
+
+ remaining--;
+ if(!remaining){
+ won = true;
+ hasWonChanged();
+ setPlaying(false);
+ return true;
+ }
+ return true;
+}
+
+bool MinehuntGame::flag(int row, int col)
+{
+ TileData *t = tile(row, col);
+ if(!t || !playing || t->flipped())
+ return false;
+
+ t->setHasFlag(!t->hasFlag());
+ nFlags += (t->hasFlag()?1:-1);
+ emit numFlagsChanged();
+ return true;
+}
diff --git a/examples/declarative/minehunt/minehunt.h b/examples/declarative/minehunt/minehunt.h
new file mode 100644
index 0000000000..d4a318dab9
--- /dev/null
+++ b/examples/declarative/minehunt/minehunt.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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$
+**
+****************************************************************************/
+
+
+#include <qdeclarative.h>
+
+class TileData : public QObject
+{
+ Q_OBJECT
+public:
+ TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {}
+
+ Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged)
+ bool hasFlag() const { return _hasFlag; }
+
+ Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged)
+ bool hasMine() const { return _hasMine; }
+
+ Q_PROPERTY(int hint READ hint NOTIFY hintChanged)
+ int hint() const { return _hint; }
+
+ Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged())
+ bool flipped() const { return _flipped; }
+
+ void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();}
+ void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();}
+ void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); }
+ void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); }
+ void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); }
+
+signals:
+ void flippedChanged();
+ void hasFlagChanged();
+ void hintChanged();
+ void hasMineChanged();
+
+private:
+ bool _hasFlag;
+ bool _hasMine;
+ int _hint;
+ bool _flipped;
+};
+
+class MinehuntGame : public QObject
+{
+ Q_OBJECT
+public:
+ MinehuntGame();
+
+ Q_PROPERTY(QDeclarativeListProperty<TileData> tiles READ tiles CONSTANT)
+ QDeclarativeListProperty<TileData> tiles();
+
+ Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
+ bool isPlaying() {return playing;}
+
+ Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged)
+ bool hasWon() {return won;}
+
+ Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged)
+ int numMines() const{return nMines;}
+
+ Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged)
+ int numFlags() const{return nFlags;}
+
+public slots:
+ Q_INVOKABLE bool flip(int row, int col);
+ Q_INVOKABLE bool flag(int row, int col);
+ void setBoard();
+ void reset();
+
+signals:
+ void isPlayingChanged();
+ void hasWonChanged();
+ void numMinesChanged();
+ void numFlagsChanged();
+
+private:
+ bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; }
+ TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; }
+ int getHint(int row, int col);
+ void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();}
+
+ QList<TileData *> _tiles;
+ int numCols;
+ int numRows;
+ bool playing;
+ bool won;
+ int remaining;
+ int nMines;
+ int nFlags;
+};
diff --git a/examples/declarative/minehunt/minehunt.pro b/examples/declarative/minehunt/minehunt.pro
new file mode 100644
index 0000000000..a0220f2dc7
--- /dev/null
+++ b/examples/declarative/minehunt/minehunt.pro
@@ -0,0 +1,23 @@
+TEMPLATE = app
+TARGET = minehunt
+QT += declarative
+
+# Input
+HEADERS += minehunt.h
+SOURCES += main.cpp minehunt.cpp
+RESOURCES = minehunt.qrc
+
+sources.files = minehunt.qml minehunt.pro MinehuntCore
+sources.path = $$[QT_INSTALL_DEMOS]/qtdeclarative/declarative/minehunt
+target.path = $$[QT_INSTALL_DEMOS]/qtdeclarative/declarative/minehunt
+
+INSTALLS = sources target
+
+symbian:{
+ TARGET.EPOCALLOWDLLDATA = 1
+ TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
+ CONFIG += qt_demo
+ qmlminehuntfiles.files = MinehuntCore minehunt.qml
+ DEPLOYMENT += qmlminehuntfiles
+}
+
diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml
new file mode 100644
index 0000000000..2129350625
--- /dev/null
+++ b/examples/declarative/minehunt/minehunt.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+import "MinehuntCore" 1.0
+
+Item {
+ id: field
+ property int clickx: 0
+ property int clicky: 0
+
+ width: 450; height: 450
+
+ Image { source: "MinehuntCore/pics/background.png"; anchors.fill: parent; fillMode: Image.Tile }
+
+ Grid {
+ anchors.horizontalCenter: parent.horizontalCenter
+ columns: 9; spacing: 1
+
+ Repeater {
+ id: repeater
+ model: tiles
+ delegate: Tile {}
+ }
+ }
+
+ Row {
+ id: gamedata
+ x: 20; spacing: 20
+ anchors.bottom: field.bottom; anchors.bottomMargin: 15
+
+ Image {
+ source: "MinehuntCore/pics/quit.png"
+ scale: quitMouse.pressed ? 0.8 : 1.0
+ smooth: quitMouse.pressed
+ y: 10
+ MouseArea {
+ id: quitMouse
+ anchors.fill: parent
+ anchors.margins: -20
+ onClicked: Qt.quit()
+ }
+ }
+ Column {
+ spacing: 2
+ Image { source: "MinehuntCore/pics/bomb-color.png" }
+ Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numMines }
+ }
+
+ Column {
+ spacing: 2
+ Image { source: "MinehuntCore/pics/flag-color.png" }
+ Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numFlags }
+ }
+ }
+
+ Image {
+ anchors.bottom: field.bottom; anchors.bottomMargin: 15
+ anchors.right: field.right; anchors.rightMargin: 20
+ source: isPlaying ? 'MinehuntCore/pics/face-smile.png' :
+ hasWon ? 'MinehuntCore/pics/face-smile-big.png': 'MinehuntCore/pics/face-sad.png'
+
+ MouseArea { anchors.fill: parent; onPressed: reset() }
+ }
+ Text {
+ anchors.centerIn: parent; width: parent.width - 20
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: Text.WordWrap
+ text: "Minehunt demo has to be compiled to run.\n\nPlease see README."
+ color: "white"; font.bold: true; font.pixelSize: 14
+ visible: tiles == undefined
+ }
+
+}
diff --git a/examples/declarative/minehunt/minehunt.qmlproject b/examples/declarative/minehunt/minehunt.qmlproject
new file mode 100644
index 0000000000..d4909f8685
--- /dev/null
+++ b/examples/declarative/minehunt/minehunt.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/declarative/minehunt/minehunt.qrc b/examples/declarative/minehunt/minehunt.qrc
new file mode 100644
index 0000000000..fa8e27d383
--- /dev/null
+++ b/examples/declarative/minehunt/minehunt.qrc
@@ -0,0 +1,20 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>minehunt.qml</file>
+ <file>MinehuntCore/Explosion.qml</file>
+ <file>MinehuntCore/Tile.qml</file>
+ <file>MinehuntCore/qmldir</file>
+ <file>MinehuntCore/pics/background.png</file>
+ <file>MinehuntCore/pics/back.png</file>
+ <file>MinehuntCore/pics/bomb-color.png</file>
+ <file>MinehuntCore/pics/bomb.png</file>
+ <file>MinehuntCore/pics/face-sad.png</file>
+ <file>MinehuntCore/pics/face-smile-big.png</file>
+ <file>MinehuntCore/pics/face-smile.png</file>
+ <file>MinehuntCore/pics/flag-color.png</file>
+ <file>MinehuntCore/pics/flag.png</file>
+ <file>MinehuntCore/pics/front.png</file>
+ <file>MinehuntCore/pics/quit.png</file>
+ <file>MinehuntCore/pics/star.png</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml
new file mode 100644
index 0000000000..61005382da
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Component {
+ id: albumDelegate
+ Package {
+
+ Item {
+ Package.name: 'browser'
+ GridView {
+ id: photosGridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height - 21
+ x: 0; y: 21; cellWidth: 160; cellHeight: 153; interactive: false
+ onCurrentIndexChanged: photosListView.positionViewAtIndex(currentIndex, ListView.Contain)
+ }
+ }
+
+ Item {
+ Package.name: 'fullscreen'
+ ListView {
+ id: photosListView; model: visualModel.parts.list; orientation: Qt.Horizontal
+ width: mainWindow.width; height: mainWindow.height; interactive: false
+ onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain)
+ highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem
+ }
+ }
+
+ Item {
+ Package.name: 'album'
+ id: albumWrapper; width: 210; height: 220
+
+ VisualDataModel {
+ id: visualModel; delegate: PhotoDelegate { }
+ model: RssModel { id: rssModel; tags: tag }
+ }
+
+ BusyIndicator {
+ id: busyIndicator
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ on: rssModel.status != XmlListModel.Ready
+ }
+
+ PathView {
+ id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5
+ visible: !busyIndicator.visible
+ anchors.centerIn: parent; anchors.verticalCenterOffset: -30
+ path: Path {
+ PathAttribute { name: 'z'; value: 9999.0 }
+ PathLine { x: 1; y: 1 }
+ PathAttribute { name: 'z'; value: 0.0 }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid'
+ }
+
+ Tag {
+ anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 }
+ frontLabel: tag; backLabel: qsTr("Remove"); flipped: mainWindow.editMode
+ onTagChanged: rssModel.tags = tag
+ onBackClicked: if (mainWindow.editMode) photosModel.remove(index);
+ }
+
+ states: [
+ State {
+ name: 'inGrid'
+ PropertyChanges { target: photosGridView; interactive: true }
+ PropertyChanges { target: albumsShade; opacity: 1 }
+ PropertyChanges { target: backButton; onClicked: albumWrapper.state = ''; y: 6 }
+ },
+ State {
+ name: 'fullscreen'; extend: 'inGrid'
+ PropertyChanges { target: photosGridView; interactive: false }
+ PropertyChanges { target: photosListView; interactive: true }
+ PropertyChanges { target: photosShade; opacity: 1 }
+ PropertyChanges { target: backButton; y: -backButton.height - 8 }
+ }
+ ]
+
+ GridView.onAdd: NumberAnimation {
+ target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: Easing.OutQuad
+ }
+ GridView.onRemove: SequentialAnimation {
+ PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true }
+ NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuad }
+ PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false }
+ }
+
+ transitions: [
+ Transition {
+ from: '*'; to: 'inGrid'
+ SequentialAnimation {
+ NumberAnimation { properties: 'opacity'; duration: 250 }
+ PauseAnimation { duration: 350 }
+ NumberAnimation { target: backButton; properties: "y"; duration: 200; easing.type: Easing.OutQuad }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: '*'
+ NumberAnimation { properties: "y,opacity"; easing.type: Easing.OutQuad; duration: 300 }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml
new file mode 100644
index 0000000000..14eb6439c0
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Image {
+ id: container
+ property bool on: false
+
+ source: "images/busy.png"; visible: container.on
+ NumberAnimation on rotation { running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 }
+}
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/Button.qml b/examples/declarative/photoviewer/PhotoViewerCore/Button.qml
new file mode 100644
index 0000000000..481bcc5a55
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/Button.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Item {
+ id: container
+
+ property alias label: labelText.text
+ property color tint: "transparent"
+ signal clicked
+
+ width: labelText.width + 70 ; height: labelText.height + 18
+
+ BorderImage {
+ anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
+ source: 'images/box-shadow.png'; smooth: true
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+
+ Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true }
+
+ Rectangle {
+ anchors.fill: container; color: container.tint; visible: container.tint != ""
+ opacity: 0.25; smooth: true
+ }
+
+ Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent; smooth: true }
+
+ MouseArea {
+ anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
+ onClicked: container.clicked()
+ }
+}
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml
new file mode 100644
index 0000000000..9c47310ebd
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Item {
+ id: container
+
+ property string label
+ signal clicked
+ signal labelChanged(string label)
+
+ width: textInput.width + 70 ; height: textInput.height + 18
+
+ BorderImage {
+ anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
+ source: 'images/box-shadow.png'; smooth: true
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+
+ Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true }
+
+ TextInput {
+ id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true
+ Keys.onReturnPressed: {
+ container.labelChanged(textInput.text)
+ container.focus = true
+ }
+ Keys.onEnterPressed: {
+ container.labelChanged(textInput.text)
+ container.focus = true
+ }
+ Keys.onEscapePressed: {
+ textInput.text = container.label
+ container.focus = true
+ }
+ }
+
+ Rectangle {
+ anchors.fill: container; border.color: "steelblue"; border.width: 4
+ color: "transparent"; visible: textInput.focus; smooth: true
+ }
+
+ MouseArea {
+ anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
+ onClicked: { textInput.forceActiveFocus(); textInput.openSoftwareInputPanel(); }
+ }
+}
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml
new file mode 100644
index 0000000000..4c1692cb08
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.1
+import "script/script.js" as Script
+
+Package {
+ Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z }
+ Item { id: listItem; Package.name: 'list'; width: mainWindow.width + 40; height: 153 }
+ Item { id: gridItem; Package.name: 'grid'; width: 160; height: 153 }
+
+ Item {
+ width: 160; height: 153
+
+ Item {
+ id: photoWrapper
+
+ property double randomAngle: Math.random() * (2 * 6 + 1) - 6
+ property double randomAngle2: Math.random() * (2 * 6 + 1) - 6
+
+ x: 0; y: 0; width: 140; height: 133
+ z: stackItem.PathView.z; rotation: photoWrapper.randomAngle
+
+ BorderImage {
+ anchors {
+ fill: originalImage.status == Image.Ready ? border : placeHolder
+ leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8
+ }
+ source: 'images/box-shadow.png'; smooth: true
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+ Rectangle {
+ id: placeHolder
+
+ property int w: Script.getWidth(content)
+ property int h: Script.getHeight(content)
+ property double s: Script.calculateScale(w, h, photoWrapper.width)
+
+ color: 'white'; anchors.centerIn: parent; smooth: true
+ width: w * s; height: h * s; visible: originalImage.status != Image.Ready
+ Rectangle {
+ color: "#878787"; smooth: true
+ anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 3; rightMargin: 3 }
+ }
+ }
+ Rectangle {
+ id: border; color: 'white'; anchors.centerIn: parent; smooth: true
+ width: originalImage.paintedWidth + 6; height: originalImage.paintedHeight + 6
+ visible: !placeHolder.visible
+ }
+ BusyIndicator { anchors.centerIn: parent; on: originalImage.status != Image.Ready }
+ Image {
+ id: originalImage; smooth: true; source: "http://" + Script.getImagePath(content); cache: false
+ fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
+ }
+ Image {
+ id: hqImage; smooth: true; source: ""; visible: false; cache: false
+ fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
+ }
+ Binding {
+ target: mainWindow; property: "downloadProgress"; value: hqImage.progress
+ when: listItem.ListView.isCurrentItem
+ }
+ Binding {
+ target: mainWindow; property: "imageLoading"
+ value: (hqImage.status == Image.Loading) ? 1 : 0; when: listItem.ListView.isCurrentItem
+ }
+ MouseArea {
+ width: originalImage.paintedWidth; height: originalImage.paintedHeight; anchors.centerIn: originalImage
+ onClicked: {
+ if (albumWrapper.state == 'inGrid') {
+ gridItem.GridView.view.currentIndex = index;
+ albumWrapper.state = 'fullscreen'
+ } else {
+ gridItem.GridView.view.currentIndex = index;
+ albumWrapper.state = 'inGrid'
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: 'stacked'; when: albumWrapper.state == ''
+ ParentChange { target: photoWrapper; parent: stackItem; x: 10; y: 10 }
+ PropertyChanges { target: photoWrapper; opacity: stackItem.PathView.onPath ? 1.0 : 0.0 }
+ },
+ State {
+ name: 'inGrid'; when: albumWrapper.state == 'inGrid'
+ ParentChange { target: photoWrapper; parent: gridItem; x: 10; y: 10; rotation: photoWrapper.randomAngle2 }
+ },
+ State {
+ name: 'fullscreen'; when: albumWrapper.state == 'fullscreen'
+ ParentChange {
+ target: photoWrapper; parent: listItem; x: 0; y: 0; rotation: 0
+ width: mainWindow.width; height: mainWindow.height
+ }
+ PropertyChanges { target: border; opacity: 0 }
+ PropertyChanges { target: hqImage; source: listItem.ListView.isCurrentItem ? hq : ""; visible: true }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: 'stacked'; to: 'inGrid'
+ SequentialAnimation {
+ PauseAnimation { duration: 10 * index }
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ target: photoWrapper; properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart'
+ }
+ }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: 'stacked'
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation { properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: 'fullscreen'
+ SequentialAnimation {
+ PauseAnimation { duration: gridItem.GridView.isCurrentItem ? 0 : 600 }
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ targets: [ photoWrapper, border ]
+ properties: 'x,y,width,height,opacity,rotation'
+ duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart'
+ }
+ }
+ }
+ },
+ Transition {
+ from: 'fullscreen'; to: 'inGrid'
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ targets: [ photoWrapper, border ]
+ properties: 'x,y,width,height,rotation,opacity'
+ duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart'
+ }
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml b/examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml
new file mode 100644
index 0000000000..805eac208e
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Item {
+ id: container
+
+ property real progress: 0
+
+ Behavior on opacity { NumberAnimation { duration: 600 } }
+
+ Rectangle { anchors.fill: parent; color: "black"; opacity: 0.5 }
+
+ Rectangle {
+ id: fill; color: "white"; height: container.height
+ width: container.width * container.progress
+ }
+}
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml b/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml
new file mode 100644
index 0000000000..9f6c004952
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+XmlListModel {
+ property string tags : ""
+
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")
+ query: "/feed/entry"
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "content"; query: "content/string()" }
+ XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" }
+}
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/Tag.qml b/examples/declarative/photoviewer/PhotoViewerCore/Tag.qml
new file mode 100644
index 0000000000..486a28d960
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/Tag.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Flipable {
+ id: flipable
+
+ property alias frontLabel: frontButton.label
+ property alias backLabel: backButton.label
+
+ property int angle: 0
+ property int randomAngle: Math.random() * (2 * 6 + 1) - 6
+ property bool flipped: false
+
+ signal frontClicked
+ signal backClicked
+ signal tagChanged(string tag)
+
+ front: EditableButton {
+ id: frontButton; rotation: flipable.randomAngle
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ onClicked: flipable.frontClicked()
+ onLabelChanged: flipable.tagChanged(label)
+ }
+
+ back: Button {
+ id: backButton; tint: "red"; rotation: flipable.randomAngle
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ onClicked: flipable.backClicked()
+ }
+
+ transform: Rotation {
+ origin.x: flipable.width / 2; origin.y: flipable.height / 2
+ axis.x: 0; axis.y: 1; axis.z: 0
+ angle: flipable.angle
+ }
+
+ states: State {
+ name: "back"; when: flipable.flipped
+ PropertyChanges { target: flipable; angle: 180 }
+ }
+
+ transitions: Transition {
+ ParallelAnimation {
+ NumberAnimation { properties: "angle"; duration: 400 }
+ SequentialAnimation {
+ NumberAnimation { target: flipable; property: "scale"; to: 0.8; duration: 200 }
+ NumberAnimation { target: flipable; property: "scale"; to: 1.0; duration: 200 }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png b/examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png
new file mode 100644
index 0000000000..431af8545d
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png
Binary files differ
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/images/busy.png b/examples/declarative/photoviewer/PhotoViewerCore/images/busy.png
new file mode 100644
index 0000000000..664c2b1491
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/images/busy.png
Binary files differ
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.png b/examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.png
new file mode 100644
index 0000000000..1847ab528d
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.png
Binary files differ
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/qmldir b/examples/declarative/photoviewer/PhotoViewerCore/qmldir
new file mode 100644
index 0000000000..d3c247f21a
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/qmldir
@@ -0,0 +1,8 @@
+AlbumDelegate AlbumDelegate.qml
+PhotoDelegate PhotoDelegate.qml
+ProgressBar ProgressBar.qml
+RssModel RssModel.qml
+BusyIndicator BusyIndicator.qml
+EditableButton EditableButton.qml
+Button Button.qml
+Tag Tag.qml
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/script/script.js b/examples/declarative/photoviewer/PhotoViewerCore/script/script.js
new file mode 100644
index 0000000000..e8ef93a847
--- /dev/null
+++ b/examples/declarative/photoviewer/PhotoViewerCore/script/script.js
@@ -0,0 +1,27 @@
+.pragma library
+
+function getWidth(string) {
+ return (string.match(/width=\"([0-9]+)\"/))[1]
+}
+
+function getHeight(string) {
+ return (string.match(/height=\"([0-9]+)\"/))[1]
+}
+
+function getImagePath(string) {
+ var pattern = /src=\"http:\/\/(\S+)\"/
+ return (string.match(pattern))[1]
+}
+
+function calculateScale(width, height, cellSize) {
+ var widthScale = (cellSize * 1.0) / width
+ var heightScale = (cellSize * 1.0) / height
+ var scale = 0
+
+ if (widthScale <= heightScale) {
+ scale = widthScale;
+ } else if (heightScale < widthScale) {
+ scale = heightScale;
+ }
+ return scale;
+}
diff --git a/examples/declarative/photoviewer/i18n/base.ts b/examples/declarative/photoviewer/i18n/base.ts
new file mode 100644
index 0000000000..1accfd2f90
--- /dev/null
+++ b/examples/declarative/photoviewer/i18n/base.ts
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name>AlbumDelegate</name>
+ <message>
+ <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="59"/>
+ <source>Remove</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>photoviewer</name>
+ <message>
+ <location filename="../photoviewer.qml" line="30"/>
+ <source>Add</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="39"/>
+ <source>Edit</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="52"/>
+ <source>Back</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/declarative/photoviewer/i18n/qml_fr.qm b/examples/declarative/photoviewer/i18n/qml_fr.qm
new file mode 100644
index 0000000000..c24fcbc46c
--- /dev/null
+++ b/examples/declarative/photoviewer/i18n/qml_fr.qm
Binary files differ
diff --git a/examples/declarative/photoviewer/i18n/qml_fr.ts b/examples/declarative/photoviewer/i18n/qml_fr.ts
new file mode 100644
index 0000000000..9f892db616
--- /dev/null
+++ b/examples/declarative/photoviewer/i18n/qml_fr.ts
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="fr_FR">
+<context>
+ <name>AlbumDelegate</name>
+ <message>
+ <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="59"/>
+ <source>Remove</source>
+ <translation>Supprimer</translation>
+ </message>
+</context>
+<context>
+ <name>photoviewer</name>
+ <message>
+ <location filename="../photoviewer.qml" line="30"/>
+ <source>Add</source>
+ <translation>Ajouter</translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="39"/>
+ <source>Edit</source>
+ <translation>Éditer</translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="52"/>
+ <source>Back</source>
+ <translation>Retour</translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/declarative/photoviewer/photoviewer.qml b/examples/declarative/photoviewer/photoviewer.qml
new file mode 100644
index 0000000000..d2eaa56c1a
--- /dev/null
+++ b/examples/declarative/photoviewer/photoviewer.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+import "PhotoViewerCore"
+
+Rectangle {
+ id: mainWindow
+
+ property real downloadProgress: 0
+ property bool imageLoading: false
+ property bool editMode: false
+
+ width: 800; height: 480; color: "#d5d6d8"
+
+ ListModel {
+ id: photosModel
+ ListElement { tag: "Flowers" }
+ ListElement { tag: "Wildlife" }
+ ListElement { tag: "Prague" }
+ }
+
+ VisualDataModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} }
+
+ GridView {
+ id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220
+ model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0
+ }
+
+ Column {
+ spacing: 20; anchors { bottom: parent.bottom; right: parent.right; rightMargin: 20; bottomMargin: 20 }
+ Button {
+ id: newButton; label: qsTr("Add"); rotation: 3
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {
+ mainWindow.editMode = false
+ photosModel.append( { tag: "" } )
+ albumView.positionViewAtIndex(albumView.count - 1, GridView.Contain)
+ }
+ }
+ Button {
+ id: deleteButton; label: qsTr("Edit"); rotation: -2;
+ onClicked: mainWindow.editMode = !mainWindow.editMode
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Button {
+ id: quitButton; label: qsTr("Quit"); rotation: -2;
+ onClicked: Qt.quit()
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+
+ Rectangle {
+ id: albumsShade; color: mainWindow.color
+ width: parent.width; height: parent.height; opacity: 0.0
+ }
+
+ ListView { anchors.fill: parent; model: albumVisualModel.parts.browser; interactive: false }
+
+ Button { id: backButton; label: qsTr("Back"); rotation: 3; x: parent.width - backButton.width - 6; y: -backButton.height - 8 }
+
+ Rectangle { id: photosShade; color: 'black'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 }
+
+ ListView { anchors.fill: parent; model: albumVisualModel.parts.fullscreen; interactive: false }
+
+ Item { id: foreground; anchors.fill: parent }
+
+ ProgressBar {
+ progress: mainWindow.downloadProgress; width: parent.width; height: 4
+ anchors.bottom: parent.bottom; opacity: mainWindow.imageLoading; visible: opacity != 0.0
+ }
+}
diff --git a/examples/declarative/photoviewer/photoviewer.qmlproject b/examples/declarative/photoviewer/photoviewer.qmlproject
new file mode 100644
index 0000000000..d4909f8685
--- /dev/null
+++ b/examples/declarative/photoviewer/photoviewer.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/declarative/plasmapatrol/PlasmaPatrol.qmlproject b/examples/declarative/plasmapatrol/PlasmaPatrol.qmlproject
new file mode 100644
index 0000000000..53f5ecb8d2
--- /dev/null
+++ b/examples/declarative/plasmapatrol/PlasmaPatrol.qmlproject
@@ -0,0 +1,18 @@
+/* File generated by QtCreator */
+
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ "../exampleplugin" ]
+}
diff --git a/examples/declarative/plasmapatrol/TODO b/examples/declarative/plasmapatrol/TODO
new file mode 100644
index 0000000000..ef9d21a73d
--- /dev/null
+++ b/examples/declarative/plasmapatrol/TODO
@@ -0,0 +1,10 @@
+Realistic Tasks:
+Particle explosions on ship death.
+Better help text (both content and styled a little nicer).
+Hardpoint help showing them firing across the screen.
+Endless Demo Mode
+
+Nice-but-i-doubt-it-will-get-done Tasks:
+Particle Text for the winner.
+Particle-based buttons.
+Single player mode that is challenges (known opponents) to master the game with and earn achievements (in addition to 'skirmish').
diff --git a/examples/declarative/plasmapatrol/content/BlasterHardpoint.qml b/examples/declarative/plasmapatrol/content/BlasterHardpoint.qml
new file mode 100644
index 0000000000..1242a85149
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/BlasterHardpoint.qml
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property variant target: {"y": -90, "x":12}
+ property Item targetObj: container
+ property Item hardpoint: container
+ property ParticleSystem system
+ property int blasts: 16
+ property int bonusBlasts: 12
+ property bool show: true
+
+ width: 24
+ height: 24
+ Emitter{
+ id: visualization
+ particle: "blaster"
+ system: container.system
+ emitting: show
+ anchors.fill: parent
+ shape: EllipseShape{}
+ speed: TargetedDirection{ targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true}
+ lifeSpan: 1000
+ emitRate: 64
+
+ size: 24
+ sizeVariation: 24
+ endSize: 0
+ }
+
+ property int blastsLeft: 0
+ function fireAt(targetArg, container){
+ target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2);
+ targetObj = targetArg;
+ hardpoint = container;
+ blastsLeft = blasts;
+ rofTimer.repeat = true;
+ rofTimer.start();
+ }
+ Timer{
+ id: rofTimer
+ interval: 30;//Has to be greater than 1 frame or they stack up
+ running: false
+ repeat: false
+ onTriggered:{
+ if(targetObj.hp <= 0)
+ return;
+ //TODO: calculate hit and damage at target, which must be a Ship
+ var hit;
+ if(blastsLeft >= bonusBlasts)
+ hit = Math.random() > targetObj.dodge;
+ else
+ hit = false; //purely aesthetic shots, because the damage isn't that fine grained
+ if(hit == true){
+ switch(targetObj.shipType){
+ case 1: hardpoint.damageDealt += 4; break;
+ case 2: hardpoint.damageDealt += 5; break;
+ case 3: hardpoint.damageDealt += 1; break;
+ default: hardpoint.damageDealt += 100;
+ }
+ }
+ blastVector.targetX = target.x;
+ blastVector.targetY = target.y;
+ if(!hit){//TODO: Actual targetVariation
+ blastVector.targetX += (128 * Math.random() - 64);
+ blastVector.targetY += (128 * Math.random() - 64);
+ }
+ emitter.burst(1);
+ blastsLeft--;
+ if(!blastsLeft)
+ rofTimer.repeat = false;
+ }
+ }
+ Emitter{
+ id: emitter
+ particle: "blaster"
+ emitting: false
+ system: container.system
+ anchors.centerIn: parent
+
+ lifeSpan: 1000
+ emitRate: 16
+ emitCap: blasts
+ size: 24
+ endSize:16
+ sizeVariation: 8
+ speed: TargetedDirection{
+ id: blastVector
+ targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true
+ }
+ }
+}
diff --git a/examples/declarative/plasmapatrol/content/Button.qml b/examples/declarative/plasmapatrol/content/Button.qml
new file mode 100644
index 0000000000..0d810e3b75
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/Button.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+//TODO: Add particles to this component too
+Rectangle{
+ id: container
+ property alias text: txt.text
+ signal clicked
+ //color: "lightsteelblue"
+ gradient: Gradient{
+ GradientStop{ position: 0.0; color: "lightsteelblue" }
+ GradientStop{ position: 1.0; color: "steelblue" }
+ }
+ height: 64
+ radius: 16
+ width: 128
+ Text{
+ id: txt
+ anchors.centerIn: parent
+ font.pixelSize: 24
+ color: "white"
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: container.clicked()
+ }
+}
diff --git a/examples/declarative/plasmapatrol/content/CannonHardpoint.qml b/examples/declarative/plasmapatrol/content/CannonHardpoint.qml
new file mode 100644
index 0000000000..b7572ef5c4
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/CannonHardpoint.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property variant target: {"y": -90, "x":12}
+ property ParticleSystem system
+ property bool show: true
+
+ width: 24
+ height: 24
+ Emitter{
+ id: visualization
+ particle: "cannon"
+ emitting: container.show
+ system: container.system
+ anchors.centerIn: parent
+ lifeSpan: 2000
+ emitRate: 1
+
+ size: 4
+ endSize: 0
+ }
+
+ function fireAt(targetArg, hardpoint){
+ target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2);
+ if(container.hp <= 0 || targetArg.hp <= 0)
+ return;
+ //TODO: calculate hit and damage at target, which must be a Ship
+ var hit = Math.random() > targetArg.dodge
+ if(hit){
+ switch(targetArg.shipType){
+ case 1: hardpoint.damageDealt += 8; break;
+ case 2: hardpoint.damageDealt += 10; break;
+ case 3: hardpoint.damageDealt += 16; break;
+ default: hardpoint.damageDealt += 1000;
+ }
+ }
+ emitter.burst(1);
+ }
+ Emitter{
+ id: emitter
+ particle: "cannon"
+ emitting: false
+ system: container.system
+ anchors.centerIn: parent
+
+ lifeSpan: 1000
+ emitRate: 1
+ size: 8
+ endSize: 4
+ speed: TargetedDirection{
+ id: blastVector
+ targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true
+ }
+ }
+}
diff --git a/examples/declarative/plasmapatrol/content/ChoiceBox.qml b/examples/declarative/plasmapatrol/content/ChoiceBox.qml
new file mode 100644
index 0000000000..1e64a76225
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/ChoiceBox.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item{
+ id: container
+ width: 360
+ height: 160
+ property ParticleSystem system
+ Ship{
+ id: nully
+ system: system
+ }
+ property Item target: nully
+ /*
+ Component.onCompleted:{
+ container.target.shipType = 1
+ container.target.gunType = 1
+ }
+ */
+ Row{
+ anchors.horizontalCenter: parent.horizontalCenter
+ height: parent.height
+ spacing: 8
+ Button{
+ width: 80
+ height: 80
+ anchors.verticalCenter: parent.verticalCenter
+ text: "Cycle\nShip"
+ onClicked: {
+ var nextVal = container.target.shipType;
+ if(nextVal == 3)
+ nextVal = 1;
+ else
+ nextVal++;
+ container.target.shipType = nextVal;
+ }
+ }
+ Item{
+ width: 128
+ height: 128
+ anchors.verticalCenter: parent.verticalCenter
+ Ship{
+ hp: 20
+ anchors.centerIn: parent
+ shipType: container.target.shipType
+ gunType: container.target.gunType
+ system: container.system
+ }
+ }
+ Button{
+ width: 80
+ height: 80
+ anchors.verticalCenter: parent.verticalCenter
+ text: "Cycle\nGun"
+ onClicked: {
+ var nextVal = container.target.gunType;
+ if(nextVal == 3)
+ nextVal = 1;
+ else
+ nextVal++;
+ container.target.gunType = nextVal;
+ }
+ }
+ }
+}
diff --git a/examples/declarative/plasmapatrol/content/Cruiser.qml b/examples/declarative/plasmapatrol/content/Cruiser.qml
new file mode 100644
index 0000000000..a844fa1bb8
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/Cruiser.qml
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property int maxHP: 100
+ property int hp: maxHP
+ property real initialDodge: 0.01
+ property real dodge: initialDodge
+ onHpChanged: if(hp <= 0) target = container;
+ property ParticleSystem system//TODO: Ship abstraction
+ property Item target: container
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ width: 128
+ height: 128
+ Emitter{
+ //TODO: Cooler would be an 'orbiting' affector
+ //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles
+ system: container.system
+ particle: container.shipParticle
+ anchors.centerIn: parent
+ width: 64
+ height: 64
+ shape: EllipseShape{}
+
+ emitRate: hp > 0 ? hp * 1 + 20 : 0
+ lifeSpan: 2400
+ emitCap: (maxHP * 1 + 20)*2.4
+
+ size: 48
+ sizeVariation: 16
+ endSize: 16
+
+ speed: AngledDirection{angleVariation:360; magnitudeVariation: 32}
+ }
+ Emitter{
+ system: container.system
+ particle: "cruiserArmor"
+ anchors.fill: parent
+ shape: EllipseShape{ fill: false }
+ emitting: hp>0
+
+ emitRate: 16
+ lifeSpan: 2000
+
+ size: 48
+ sizeVariation: 24
+
+ SpriteGoal{
+ id: destructor
+ system: container.system
+ active: container.hp <=0
+ anchors.fill: parent
+ particles: ["cruiserArmor"]
+ goalState: "death"
+// jump: true
+ onceOff: true
+ }
+ }
+
+ Timer{
+ id: fireControl
+ property int next: Math.floor(Math.random() * 3) + 1
+ interval: 800
+ running: root.readySetGo
+ repeat: true
+ onTriggered:{
+ if(next == 1){
+ gun1.fireAt(container.target);
+ next = Math.floor(Math.random() * 3) + 1;
+ }else if(next == 2){
+ gun2.fireAt(container.target);
+ next = Math.floor(Math.random() * 3) + 1;
+ }else if(next == 3){
+ gun3.fireAt(container.target);
+ next = Math.floor(Math.random() * 3) + 1;
+ }
+ }
+ }
+
+ Hardpoint{//TODO: Hardpoint abstraction
+ x: 112 - 12 - 8*2
+ y: 128 - 12 - 12*2
+ id: gun1
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+ Hardpoint{
+ x: 64 - 12
+ y: 0 - 12 + 12*2
+ id: gun2
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+ Hardpoint{
+ x: 16 - 12 + 8*2
+ y: 128 - 12 - 12*2
+ id: gun3
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+}
diff --git a/examples/declarative/plasmapatrol/content/Frigate.qml b/examples/declarative/plasmapatrol/content/Frigate.qml
new file mode 100644
index 0000000000..d31405250e
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/Frigate.qml
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property int maxHP: 100
+ property int hp: maxHP
+ property real initialDodge: 0.2
+ property real dodge: initialDodge
+ onHpChanged: if(hp <= 0) target = container;
+ property ParticleSystem system//TODO: Ship abstraction
+ property Item target: container
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ width: 128
+ height: 128
+ Emitter{
+ system: container.system
+ particle: "frigateShield"
+ anchors.centerIn: parent
+ size: 92
+ emitRate: 1
+ lifeSpan: 4800
+ emitting: hp > 0
+ }
+ Emitter{
+ system: container.system
+ particle: container.shipParticle
+ anchors.centerIn: parent
+ width: 64
+ height: 16
+ shape: EllipseShape{}
+
+ size: 16
+ sizeVariation: 8
+ endSize: 8
+ emitRate: hp > 0 ? hp * 1 + 20 : 0
+ lifeSpan: 1200
+ emitCap: (maxHP * 1 + 20)*2
+ }
+ Timer{
+ id: fireControl
+ property int next: Math.floor(Math.random() * 2) + 1
+ interval: 800
+ running: root.readySetGo
+ repeat: true
+ onTriggered:{
+ if(next == 1){
+ gun1.fireAt(container.target);
+ next = Math.floor(Math.random() * 2) + 1;
+ }else if(next == 2){
+ gun2.fireAt(container.target);
+ next = Math.floor(Math.random() * 2) + 1;
+ }
+ }
+ }
+
+ Hardpoint{
+ x: 128 - 32 - 12
+ y: 64 - 12
+ id: gun1
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+ Hardpoint{
+ x: 0 + 32 - 12
+ y: 64 - 12
+ id: gun2
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+}
diff --git a/examples/declarative/plasmapatrol/content/Hardpoint.qml b/examples/declarative/plasmapatrol/content/Hardpoint.qml
new file mode 100644
index 0000000000..3d4edb38f8
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/Hardpoint.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ //ReflectiveProperties
+ //TransferredProperties
+ property variant target: {"y": -90, "x":12}
+ property ParticleSystem system
+ property bool show: true
+ property int hardpointType: 0 //default is pea shooter - always bad.
+
+ property Item targetObj: null
+ property int damageDealt: 0
+ onDamageDealtChanged: dealDamageTimer.start();
+ Timer{
+ id: dealDamageTimer
+ interval: 16
+ running: false
+ repeat: false
+ onTriggered: {targetObj.hp -= damageDealt; damageDealt = 0;}
+ }
+ width: 24
+ height: 24
+ function fireAt(targetArg){//Each implement own
+ if(targetArg != null){
+ hardpointLoader.item.fireAt(targetArg, container);
+ targetObj = targetArg;
+ }
+ }
+ Loader{
+ id: hardpointLoader
+ sourceComponent: {switch(hardpointType){
+ case 1: laserComponent; break;
+ case 2: blasterComponent; break;
+ case 3: cannonComponent; break;
+ default: emptyComponent;
+ }}
+ }
+ Component{
+ id: laserComponent
+ LaserHardpoint{
+ target: container.target
+ system: container.system
+ show: container.show
+ }
+ }
+ Component{
+ id: blasterComponent
+ BlasterHardpoint{
+ target: container.target
+ system: container.system
+ show: container.show
+ }
+ }
+ Component{
+ id: cannonComponent
+ CannonHardpoint{
+ target: container.target
+ system: container.system
+ show: container.show
+ }
+ }
+ Component{
+ id: emptyComponent
+ Item {
+ function fireAt(obj){
+ console.log("Firing null weapon. It hurts.");
+ }
+ }
+ }
+}
diff --git a/examples/declarative/plasmapatrol/content/HelpScreens.qml b/examples/declarative/plasmapatrol/content/HelpScreens.qml
new file mode 100644
index 0000000000..7e4fb9f1c9
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/HelpScreens.qml
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+SequentialLoader {
+ id: hLdr
+ signal exitDesired
+ Component.onCompleted: advance();
+ ParticleSystem{ id: helpSystem }
+ PlasmaPatrolParticles{ sys: helpSystem }
+ pages: [
+ Component{Item{
+ id: story
+ Text{
+ color: "white"
+ text: "Story"
+ font.pixelSize: 48
+ }
+ /*
+ Flickable{
+ y: 60
+ width: 360
+ height: 500
+ contentHeight: txt1.height
+ contentWidth: 360//TODO: Less magic numbers?
+ */
+ Text{
+ id: txt1
+ color: "white"
+ y: 60
+ font.pixelSize: 18
+ text: "
+In a remote nebula, a race of energy beings formed and lived prosperous lives for millenia. Until the schism - when they became constantly at each other's energy-throats. War soon followed, crippling both sides, until a truce was formed. But while governments knew the desparate need for peace, the soldiers in the ion-field were still filled with rampant bloodlust. On the border, patrols are constantly engaging in minor skirmishes whenever they cross paths.
+
+You must select one such patrol unit for the border, heading into an inevitable skirmish, in Plasma Patrol: the game of energy being spaceship combat!
+ "
+ width: 360
+ wrapMode: Text.WordWrap
+ }
+ // }
+ Button{
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Next"
+ onClicked: hLdr.advance();
+ }
+ Button{
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }},
+ Component{Item{
+ id: ships
+ Text{
+ color: "white"
+ text: "Vessels"
+ font.pixelSize: 48
+ }
+ Column{
+ spacing: 16
+ y: 60
+ Row{
+ height: 128
+ Sloop{
+ system: helpSystem
+ }
+ Text{
+ text: "The nimble sloop"
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row{
+ height: 128
+ Frigate{
+ system: helpSystem
+ }
+ Text{
+ text: "The versitile shield frigate"
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row{
+ height: 128
+ Cruiser{
+ system: helpSystem
+ }
+ Text{
+ text: "The armored cruiser"
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ }
+ Button{
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Next"
+ onClicked: hLdr.advance();
+ }
+ Button{
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }},
+ Component{Item{
+ id: guns
+ Text{
+ color: "white"
+ text: "Hardpoints"
+ font.pixelSize: 48
+ }
+ Column{
+ spacing: 16
+ y: 60
+ Row{
+ height: 128
+ LaserHardpoint{
+ system: helpSystem
+ }
+ Text{
+ text: "The laser hardpoint almost always hits the target, even the nimble sloop, but loses much of its potency against the frigate's shields"
+ width: 332
+ wrapMode: Text.WordWrap
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row{
+ height: 128
+ BlasterHardpoint{
+ system: helpSystem
+ }
+ Text{
+ text: "The blaster passes right through the frigate's shields but loses much of its impact against the armor of the cruiser"
+ width: 332
+ wrapMode: Text.WordWrap
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row{
+ height: 128
+ CannonHardpoint{
+ system: helpSystem
+ }
+ Text{
+ text: "The cannon has poor accuracy, often missing the nimble sloop, but can punch right through the armor of the cruiser"
+ width: 332
+ wrapMode: Text.WordWrap
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ }
+ Button{
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Next"
+ onClicked: hLdr.advance();
+ }
+ Button{
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }},
+ Component{Item{
+ id: strategy
+ Text{
+ color: "white"
+ text: "Strategy"
+ font.pixelSize: 48
+ }
+ Flickable{
+ y: 60
+ width: 360
+ height: 500
+ contentHeight: txt1.height
+ contentWidth: 360//TODO: Less magic numbers?
+ Text{
+ id: txt1
+ color: "white"
+ font.pixelSize: 18
+ text: "
+Basic Strategy: Good luck, have fun - don't die.
+More to come after thorough playtesting.
+ "
+ width: 360
+ wrapMode: Text.WordWrap
+ }
+ }
+ Button{
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Story"
+ onClicked: {hLdr.at=0; hLdr.advance();}
+ }
+ Button{
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }}
+ ]
+}
diff --git a/examples/declarative/plasmapatrol/content/LaserHardpoint.qml b/examples/declarative/plasmapatrol/content/LaserHardpoint.qml
new file mode 100644
index 0000000000..e99424856c
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/LaserHardpoint.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property variant target: {"y": -90, "x":12}
+ property ParticleSystem system
+ property bool show: true
+
+ width: 24
+ height: 24
+ Emitter{
+ id: visualization
+ particle: "laser"
+ system: container.system
+ anchors.fill: parent
+ emitting: container.show
+ shape: EllipseShape{}
+ speed: TargetedDirection{ targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true }
+ lifeSpan: 1000
+ emitRate: 64
+
+ size: 24
+ sizeVariation: 8
+ endSize: 8
+ }
+
+ function fireAt(targetArg, hardpoint){
+ if(targetArg.hp <= 0)
+ return;
+ //TODO: calculate hit and damage at target, which must be a Ship
+ var offset = 0;
+ if(Math.random() < 0.99){
+ switch(targetArg.shipType){
+ case 1: hardpoint.damageDealt += 16; break;
+ case 2: hardpoint.damageDealt += 4; break;
+ case 3: hardpoint.damageDealt += 8; break;
+ default: hardpoint.damageDealt += 500; //Really effective against unregistered vessels
+ }
+ }else{//Misses with Lasers are really rare
+ offset = Math.random() * 100;
+ }
+ target = container.mapFromItem(targetArg, offset + targetArg.width/2, offset + targetArg.height/2);
+ emitter.pulse(0.10);
+ // console.log("Fire box: " + Math.min(container.width/2, target.x) + "," + Math.min(container.height/2, target.y) + " " + (Math.max(container.width/2, target.x) - Math.min(container.width/2, target.x)) + "," + (Math.max(container.height/2, target.y) - Math.min(container.height/2, target.y)));
+ }
+ Emitter{
+ id: emitter
+ particle: "laser"
+ emitting: false
+ system: container.system
+ x: Math.min(container.width/2, target.x);
+ width: Math.max(container.width/2, target.x) - x;
+ y: Math.min(container.height/2, target.y);
+ height: Math.max(container.height/2, target.y) - y;
+ shape: LineShape{
+ mirrored: (emitter.y < 0 || emitter.x < 0) && !(emitter.y < 0 && emitter.x < 0 )//I just want XOR
+ }
+
+ lifeSpan: 1000
+ emitRate: 8000
+ emitCap: 800
+ size: 16
+ endSize: 0
+
+ speed: PointDirection{xVariation: 4; yVariation: 4}
+ }
+}
diff --git a/examples/declarative/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/declarative/plasmapatrol/content/PlasmaPatrolParticles.qml
new file mode 100644
index 0000000000..b65686e59e
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/PlasmaPatrolParticles.qml
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item{
+ property ParticleSystem sys
+ ImageParticle{
+ system: sys
+ particles: ["default"]
+ source: "pics/blur-circle3.png"
+ color: "#003A3A3A"
+ colorVariation: 0.1
+ z: 0
+ }
+ ImageParticle{
+ system: sys
+ particles: ["redTeam"]
+ source: "pics/blur-circle3.png"
+ color: "#0028060A"
+ colorVariation: 0.1
+ z: 0
+ }
+ ImageParticle{
+ system: sys
+ particles: ["greenTeam"]
+ source: "pics/blur-circle3.png"
+ color: "#0006280A"
+ colorVariation: 0.1
+ z: 0
+ }
+ ImageParticle{
+ system: sys
+ particles: ["blaster"]
+ source: "pics/star2.png"
+ //color: "#0F282406"
+ color: "#0F484416"
+ colorVariation: 0.2
+ z: 2
+ }
+ ImageParticle{
+ system: sys
+ particles: ["laser"]
+ source: "pics/star3.png"
+ //color: "#00123F68"
+ color: "#00428FF8"
+ colorVariation: 0.2
+ z: 2
+ }
+ ImageParticle{
+ system: sys
+ particles: ["cannon"]
+ source: "pics/particle.png"
+ color: "#80FFAAFF"
+ colorVariation: 0.1
+ z: 2
+ }
+ ImageParticle{
+ system: sys
+ particles: ["cannonCore"]
+ source: "pics/particle.png"
+ color: "#00666666"
+ colorVariation: 0.8
+ z: 1
+ }
+ ImageParticle{
+ system: sys
+ particles: ["cannonWake"]
+ source: "pics/star.png"
+ color: "#00CCCCCC"
+ colorVariation: 0.2
+ z: 1
+ }
+ ImageParticle{
+ system: sys
+ particles: ["frigateShield"]
+ source: "pics/blur-circle2.png"
+ color: "#00000000"
+ colorVariation: 0.05
+ blueVariation: 0.5
+ greenVariation: 0.1
+ z: 3
+ }
+ ImageParticle{
+ system: sys
+ particles: ["cruiserArmor"]
+ z: 1
+ sprites:[Sprite{
+ id: spinState
+ name: "spinning"
+ source: "pics/meteor.png"
+ frames: 35
+ duration: 40
+ to: {"death":0, "spinning":1}
+ },Sprite{
+ name: "death"
+ source: "pics/meteor_explo.png"
+ frames: 22
+ duration: 40
+ to: {"null":1}
+ }, Sprite{
+ name: "null"
+ source: "pics/nullRock.png"
+ frames: 1
+ duration: 1000
+ }
+ ]
+ }
+ FollowEmitter{
+ system: sys
+ particle: "cannonWake"
+ follow: "cannon"
+ emitRatePerParticle: 64
+ lifeSpan: 600
+ speed: AngledDirection{ angleVariation: 360; magnitude: 48}
+ size: 16
+ endSize: 8
+ sizeVariation: 2
+ emitting: true
+ width: 1000//XXX: Terrible hack
+ height: 1000
+ }
+ FollowEmitter{
+ system: sys
+ particle: "cannonCore"
+ follow: "cannon"
+ emitRatePerParticle: 256
+ lifeSpan: 128
+ size: 24
+ endSize: 8
+ emitting: true
+ width: 1000//XXX: Terrible hack
+ height: 1000
+ }
+}
diff --git a/examples/declarative/plasmapatrol/content/SequentialLoader.qml b/examples/declarative/plasmapatrol/content/SequentialLoader.qml
new file mode 100644
index 0000000000..85a979b222
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/SequentialLoader.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Item{
+ id: container
+ //TODO: Somehow get particles into this?
+ property list<Component> pages
+ property Item cur: null
+ property int at: 0
+ function advance(){
+ if(cur != null)
+ cur.destroy();
+ cur = pages[at++].createObject(container);
+ }
+}
diff --git a/examples/declarative/plasmapatrol/content/Ship.qml b/examples/declarative/plasmapatrol/content/Ship.qml
new file mode 100644
index 0000000000..ce8fb6073f
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/Ship.qml
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: me
+ //Reflective Properties
+ width: shipLoader.width
+ height: shipLoader.height
+ //Transfered Properties
+ property int hp: 100//shipLoader.item.maxHP
+ property real dodge: shipLoader.item.initialDodge
+ property ParticleSystem system
+ property int targetIdx: 0
+ property Item target: targets[targetIdx] == undefined?null:targets[targetIdx]
+ Connections{
+ target: me.target
+ onHpChanged: if(me.target.hp<=0) me.targetIdx++;
+ }
+ property list<Item> targets
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ property int shipType: 0
+ Component{
+ id: sloopComp
+ Sloop{
+ system: me.system
+ target: me.target
+ shipParticle: me.shipParticle
+ gunType: me.gunType
+ hp: me.hp
+ dodge: me.dodge
+ }
+ }
+ Component{
+ id: frigateComp
+ Frigate{
+ system: me.system
+ target: me.target
+ shipParticle: me.shipParticle
+ gunType: me.gunType
+ hp: me.hp
+ dodge: me.dodge
+ }
+ }
+ Component{
+ id: cruiserComp
+ Cruiser{
+ system: me.system
+ target: me.target
+ shipParticle: me.shipParticle
+ gunType: me.gunType
+ hp: me.hp
+ dodge: me.dodge
+ }
+ }
+ Component{
+ id: dumbComp
+ Item{
+ property int maxHP: 0
+ property int initialDodge: 0
+ }
+ }
+ Loader{
+ id: shipLoader
+ sourceComponent:{ switch(shipType){
+ case 1: sloopComp; break;
+ case 2: frigateComp; break;
+ case 3: cruiserComp; break;
+ default: dumbComp;
+ }
+ }
+ }
+}
diff --git a/examples/declarative/plasmapatrol/content/Sloop.qml b/examples/declarative/plasmapatrol/content/Sloop.qml
new file mode 100644
index 0000000000..1a6f3a9620
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/Sloop.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property int maxHP: 100
+ property int hp: maxHP
+ property real initialDodge: 0.5
+ property real dodge: initialDodge
+ property int blinkInterval: 800
+ onHpChanged: if(hp <= 0) target = container;
+ property ParticleSystem system//TODO: Ship abstraction
+ property Item target: container
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ width: 128
+ height: 128
+ Emitter{
+ id: emitter
+ //TODO: Cooler would be an 'orbiting' affector
+ //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles
+ system: container.system
+ particle: container.shipParticle
+ shape: EllipseShape{}
+
+ emitRate: hp > 0 ? hp + 20 : 0
+ lifeSpan: blinkInterval
+ emitCap: (maxHP + 20)
+
+ acceleration: AngledDirection{angleVariation: 360; magnitude: 8}
+
+ size: 24
+ endSize: 4
+ sizeVariation: 8
+ width: 16
+ height: 16
+ x: 64
+ y: 64
+ Behavior on x{NumberAnimation{duration:blinkInterval}}
+ Behavior on y{NumberAnimation{duration:blinkInterval}}
+ Timer{
+ interval: blinkInterval
+ running: true
+ repeat: true
+ onTriggered: {
+ emitter.x = Math.random() * 48 + 32
+ emitter.y = Math.random() * 48 + 32
+ }
+ }
+ }
+ Hardpoint{
+ anchors.centerIn: parent
+ id: gun2
+ system: container.system
+ show: container.hp > 0
+ hardpointType: gunType
+ }
+ Timer{
+ id: fireControl
+ interval: 800
+ running: root.readySetGo
+ repeat: true
+ onTriggered:{
+ gun2.fireAt(container.target);
+ }
+ }
+
+}
diff --git a/examples/declarative/plasmapatrol/content/pics/TitleText.png b/examples/declarative/plasmapatrol/content/pics/TitleText.png
new file mode 100644
index 0000000000..dc3acebe39
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/pics/TitleText.png
Binary files differ
diff --git a/examples/declarative/plasmapatrol/content/pics/blur-circle2.png b/examples/declarative/plasmapatrol/content/pics/blur-circle2.png
new file mode 100644
index 0000000000..f7c9f3e98e
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/pics/blur-circle2.png
Binary files differ
diff --git a/examples/declarative/plasmapatrol/content/pics/blur-circle3.png b/examples/declarative/plasmapatrol/content/pics/blur-circle3.png
new file mode 100644
index 0000000000..dbc39cb16e
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/pics/blur-circle3.png
Binary files differ
diff --git a/examples/declarative/plasmapatrol/content/pics/finalfrontier.png b/examples/declarative/plasmapatrol/content/pics/finalfrontier.png
new file mode 100644
index 0000000000..2ba1815230
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/pics/finalfrontier.png
Binary files differ
diff --git a/examples/declarative/plasmapatrol/content/pics/meteor.png b/examples/declarative/plasmapatrol/content/pics/meteor.png
new file mode 100644
index 0000000000..e8c368aea7
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/pics/meteor.png
Binary files differ
diff --git a/examples/declarative/plasmapatrol/content/pics/meteor_explo.png b/examples/declarative/plasmapatrol/content/pics/meteor_explo.png
new file mode 100644
index 0000000000..4297245d49
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/pics/meteor_explo.png
Binary files differ
diff --git a/examples/declarative/plasmapatrol/content/pics/nullRock.png b/examples/declarative/plasmapatrol/content/pics/nullRock.png
new file mode 100644
index 0000000000..4076327a1a
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/pics/nullRock.png
Binary files differ
diff --git a/examples/declarative/plasmapatrol/content/pics/particle.png b/examples/declarative/plasmapatrol/content/pics/particle.png
new file mode 100644
index 0000000000..5c83896d22
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/pics/particle.png
Binary files differ
diff --git a/examples/declarative/plasmapatrol/content/pics/star.png b/examples/declarative/plasmapatrol/content/pics/star.png
new file mode 100644
index 0000000000..0d592cfa87
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/pics/star.png
Binary files differ
diff --git a/examples/declarative/plasmapatrol/content/pics/star2.png b/examples/declarative/plasmapatrol/content/pics/star2.png
new file mode 100644
index 0000000000..bb55c44788
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/pics/star2.png
Binary files differ
diff --git a/examples/declarative/plasmapatrol/content/pics/star3.png b/examples/declarative/plasmapatrol/content/pics/star3.png
new file mode 100644
index 0000000000..636a25f480
--- /dev/null
+++ b/examples/declarative/plasmapatrol/content/pics/star3.png
Binary files differ
diff --git a/examples/declarative/plasmapatrol/plasmapatrol.qml b/examples/declarative/plasmapatrol/plasmapatrol.qml
new file mode 100644
index 0000000000..dfc36ded01
--- /dev/null
+++ b/examples/declarative/plasmapatrol/plasmapatrol.qml
@@ -0,0 +1,386 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+
+Rectangle {
+ id: root
+ property bool readySetGo: false
+ //Debugging
+ property int hits: 0
+ property int misses: 0
+ property real ratio: hits/(misses?misses:1)
+ //Move to JS file?
+ property Ship redVar1: Ship{shipType: 1; gunType: 1}
+ property Ship redVar2: Ship{shipType: 1; gunType: 2}
+ property Ship redVar3: Ship{shipType: 1; gunType: 3}
+ property Ship greenVar1: Ship{shipType: 3; gunType: 1}
+ property Ship greenVar2: Ship{shipType: 2; gunType: 2}
+ property Ship greenVar3: Ship{shipType: 1; gunType: 3}
+ property string winner: "0"
+ property int players: 0
+ function aiSet(ship){
+ ship.gunType = Math.floor(Math.random() * 3) + 1
+ ship.shipType = Math.floor(Math.random() * 3) + 1
+ }
+
+ width: 360
+ height: 600
+ color: "black"
+ SequentialLoader{
+ anchors.fill: parent
+ //General Children
+ Image{
+ anchors.centerIn: parent
+ source: "content/pics/finalfrontier.png"
+ }
+ ParticleSystem{
+ id: particles
+ }
+ PlasmaPatrolParticles{ sys: particles; z: 100 }//Renders all particles on the one plane
+ //Component parts
+ id: pageControl
+ Component.onCompleted: advance();
+ pages:[
+ Component{Item{
+ id: menu
+ width: root.width
+ height: root.height
+ Column{
+ anchors.verticalCenter: parent.verticalCenter
+ width: parent.width
+ spacing: 8
+ Item{
+ id: title
+ width: root.width
+ height: 240
+ Emitter{
+ anchors.fill: parent
+ system: particles
+ emitting: true
+ particle: "default"
+ emitRate: 1200
+ lifeSpan: 1200
+ shape: MaskShape{source:"content/pics/TitleText.png"}
+ size: 16
+ endSize: 0
+ sizeVariation: 8
+ speed: AngledDirection{angleVariation:360; magnitudeVariation: 6}
+ }
+ }
+ Button{
+ text: "1P"
+ onClicked: {root.players = 1; pageControl.advance();}
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Button{
+ text: "2P"
+ onClicked: {root.players = 2; pageControl.advance();}
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Button{
+ text: "Demo"
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {root.players = 0;
+ aiSet(redVar1);
+ aiSet(redVar2);
+ aiSet(redVar3);
+ aiSet(greenVar1);
+ aiSet(greenVar2);
+ aiSet(greenVar3);
+ pageControl.at = 5;//TODO: Not a magic number
+ pageControl.advance();}
+ }
+ Button{
+ text: "Help"
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {
+ pageControl.at = 7;//TODO: Not a magic number
+ pageControl.advance();
+ }
+ }
+ Button{
+ text: "Quit"
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: Qt.quit();
+ }
+ }
+ }},
+ Component{Item{
+ id: p1Screen
+ z: 101
+ width: root.width
+ height: root.height
+ Rectangle{
+ anchors.fill: parent
+ color: "red"
+ }
+ Text{
+ anchors.centerIn: parent
+ color: "white"
+ font.pixelSize: 64
+ font.bold: true
+ text: "Player\n 1"
+ horizontalAlignment: Text.AlignHCenter
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: pageControl.advance()
+ }
+ }},
+ Component{Item{
+ id: p1Choices
+ z: 3
+ width: root.width
+ height: root.height
+ Rectangle{
+ color: "black"
+ anchors.fill: parent
+ }
+ Column{
+ spacing: 16
+ width: root.width
+ anchors.horizontalCenter: parent.horizontalCenter
+ ChoiceBox{
+ target: redVar1
+ system: particles
+ }
+ ChoiceBox{
+ target: redVar2
+ system: particles
+ }
+ ChoiceBox{
+ target: redVar3
+ system: particles
+ }
+ Button{
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "Next"
+ onClicked: {
+ if(root.players < 2){
+ aiSet(greenVar1);
+ aiSet(greenVar2);
+ aiSet(greenVar3);
+ pageControl.at = 5;//TODO: Not a magic number
+ }
+ pageControl.advance();
+ }
+ }
+ }
+ }},
+ Component{Item{
+ id: p2Screen
+ z: 101
+ width: root.width
+ height: root.height
+ Rectangle{
+ anchors.fill: parent
+ color: "green"
+ }
+ Text{
+ anchors.centerIn: parent
+ color: "white"
+ font.pixelSize: 64
+ font.bold: true
+ text: "Player\n 2"
+ horizontalAlignment: Text.AlignHCenter
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: pageControl.advance()
+ }
+ }},
+ Component{Item{
+ id: p2Choices
+ z: 1
+ width: root.width
+ height: root.height
+ Rectangle{
+ color: "black"
+ anchors.fill: parent
+ }
+ Column{
+ spacing: 16
+ width: root.width
+ anchors.horizontalCenter: parent.horizontalCenter
+ ChoiceBox{
+ target: greenVar1
+ system: particles
+ }
+ ChoiceBox{
+ target: greenVar2
+ system: particles
+ }
+ ChoiceBox{
+ target: greenVar3
+ system: particles
+ }
+ Button{
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "Next"
+ onClicked: pageControl.advance()
+ }
+ }
+ }},
+ Component{Item{
+ id: arena
+ width: root.width
+ height: root.height
+ z: 0
+ Component.onCompleted: root.readySetGo = true
+ Component.onDestruction: root.readySetGo = false
+ property bool victory: redShip3.hp <= 0 || greenShip3.hp <=0
+ onVictoryChanged: {
+ if(redShip3.hp <= 0){
+ if(greenShip3.hp <= 0){
+ root.winner = "1&2"
+ }else{
+ root.winner = "2"
+ }
+ }else{
+ root.winner = "1"
+ }
+ winTimer.start()
+ }
+ Timer{
+ id: winTimer
+ interval: 1200
+ repeat: false
+ running: false
+ onTriggered: pageControl.advance();
+ }
+ Ship{
+ id: redShip1
+ shipParticle: "redTeam"
+ system: particles
+ x: 180-64
+ y: 128
+ shipType: redVar1.shipType
+ gunType: redVar1.gunType
+ targets: [greenShip1, greenShip2, greenShip3]
+ }
+ Ship{
+ id: redShip2
+ shipParticle: "redTeam"
+ system: particles
+ x: 0
+ y: 0
+ shipType: redVar2.shipType
+ gunType: redVar2.gunType
+ targets: [greenShip1, greenShip2, greenShip3]
+ }
+ Ship{
+ id: redShip3
+ shipParticle: "redTeam"
+ system: particles
+ x: 360-128
+ y: 0
+ shipType: redVar3.shipType
+ gunType: redVar3.gunType
+ targets: [greenShip1, greenShip2, greenShip3]
+ }
+
+ Ship{
+ id: greenShip1
+ shipParticle: "greenTeam"
+ system: particles
+ x: 180-64
+ y: 600 - 128 - 128
+ shipType: greenVar1.shipType
+ gunType: greenVar1.gunType
+ targets: [redShip1, redShip2, redShip3]
+ }
+ Ship{
+ id: greenShip2
+ shipParticle: "greenTeam"
+ system: particles
+ x: 0
+ y: 600-128
+ shipType: greenVar2.shipType
+ gunType: greenVar2.gunType
+ targets: [redShip1, redShip2, redShip3]
+ }
+ Ship{
+ id: greenShip3
+ shipParticle: "greenTeam"
+ system: particles
+ x: 360 - 128
+ y: 600 - 128
+ shipType: greenVar3.shipType
+ gunType: greenVar3.gunType
+ targets: [redShip1, redShip2, redShip3]
+ }
+ }},
+ Component{Item{
+ id: winScreen
+ z: 101
+ width: root.width
+ height: root.height
+ /*
+ Rectangle{
+ anchors.fill: parent
+ color: "black"
+ }
+ */
+ Text{//TODO: Particle Text?
+ anchors.fill: parent
+ color: "white"
+ font.pixelSize: 64
+ font.bold: true
+ text: "Player " + root.winner + " wins!"
+ wrapMode: Text.WordWrap
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: {pageControl.at = 0; pageControl.advance();}
+ }
+ }},
+ Component{
+ HelpScreens{
+ onExitDesired: {pageControl.at = 0; pageControl.advance();}
+ }
+ }
+ ]
+ }
+}
diff --git a/examples/declarative/rssnews/content/BusyIndicator.qml b/examples/declarative/rssnews/content/BusyIndicator.qml
new file mode 100644
index 0000000000..3ee30d962b
--- /dev/null
+++ b/examples/declarative/rssnews/content/BusyIndicator.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Image {
+ id: container
+ property bool on: false
+
+ source: "images/busy.png"; visible: container.on
+
+ NumberAnimation on rotation {
+ running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200
+ }
+}
diff --git a/examples/declarative/rssnews/content/CategoryDelegate.qml b/examples/declarative/rssnews/content/CategoryDelegate.qml
new file mode 100644
index 0000000000..0ae9fbec13
--- /dev/null
+++ b/examples/declarative/rssnews/content/CategoryDelegate.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Item {
+ id: delegate
+
+ width: delegate.ListView.view.width; height: 60
+
+ Text {
+ text: name
+ color: delegate.ListView.isCurrentItem ? "white" : "black"
+ font { family: "Helvetica"; pixelSize: 16; bold: true }
+ anchors {
+ left: parent.left; leftMargin: 15
+ verticalCenter: parent.verticalCenter
+ }
+ }
+
+ BusyIndicator {
+ scale: 0.6
+ on: delegate.ListView.isCurrentItem && window.loading
+ anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter }
+ }
+
+ Rectangle {
+ width: delegate.width; height: 1; color: "#cccccc"
+ anchors.bottom: delegate.bottom
+ visible: delegate.ListView.isCurrentItem ? false : true
+ }
+ Rectangle {
+ width: delegate.width; height: 1; color: "white"
+ visible: delegate.ListView.isCurrentItem ? false : true
+ }
+
+ MouseArea {
+ anchors.fill: delegate
+ onClicked: {
+ delegate.ListView.view.currentIndex = index
+ window.currentFeed = feed
+ }
+ }
+}
diff --git a/examples/declarative/rssnews/content/NewsDelegate.qml b/examples/declarative/rssnews/content/NewsDelegate.qml
new file mode 100644
index 0000000000..061abb24fa
--- /dev/null
+++ b/examples/declarative/rssnews/content/NewsDelegate.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Item {
+ id: delegate
+ height: column.height + 40
+ width: delegate.ListView.view.width
+
+ Column {
+ id: column
+ x: 20; y: 20
+ width: parent.width - 40
+
+ Text {
+ id: titleText
+ text: title; width: parent.width; wrapMode: Text.WordWrap
+ font { bold: true; family: "Helvetica"; pointSize: 16 }
+ }
+
+ Text {
+ id: descriptionText
+ width: parent.width; text: description
+ wrapMode: Text.WordWrap; font.family: "Helvetica"
+ }
+ }
+
+ Rectangle {
+ width: parent.width; height: 1; color: "#cccccc"
+ anchors.bottom: parent.bottom
+ }
+}
diff --git a/examples/declarative/rssnews/content/RssFeeds.qml b/examples/declarative/rssnews/content/RssFeeds.qml
new file mode 100644
index 0000000000..09b1ad808c
--- /dev/null
+++ b/examples/declarative/rssnews/content/RssFeeds.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+ListModel {
+ id: rssFeeds
+
+ ListElement { name: "Top Stories"; feed: "rss.news.yahoo.com/rss/topstories" }
+ ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" }
+ ListElement { name: "Europe"; feed: "rss.news.yahoo.com/rss/europe" }
+ ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" }
+ ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" }
+ ListElement { name: "Politics"; feed: "rss.news.yahoo.com/rss/politics" }
+ ListElement { name: "Business"; feed: "rss.news.yahoo.com/rss/business" }
+ ListElement { name: "Technology"; feed: "rss.news.yahoo.com/rss/tech" }
+ ListElement { name: "Entertainment"; feed: "rss.news.yahoo.com/rss/entertainment" }
+ ListElement { name: "Health"; feed: "rss.news.yahoo.com/rss/health" }
+ ListElement { name: "Science"; feed: "rss.news.yahoo.com/rss/science" }
+ ListElement { name: "Sports"; feed: "rss.news.yahoo.com/rss/sports" }
+}
diff --git a/examples/declarative/rssnews/content/ScrollBar.qml b/examples/declarative/rssnews/content/ScrollBar.qml
new file mode 100644
index 0000000000..e54be7b6a8
--- /dev/null
+++ b/examples/declarative/rssnews/content/ScrollBar.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Item {
+ id: container
+
+ property variant scrollArea
+ property variant orientation: Qt.Vertical
+
+ opacity: 0
+
+ function position()
+ {
+ var ny = 0;
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+ if (ny > 2) return ny; else return 2;
+ }
+
+ function size()
+ {
+ var nh, ny;
+
+ if (container.orientation == Qt.Vertical)
+ nh = scrollArea.visibleArea.heightRatio * container.height;
+ else
+ nh = scrollArea.visibleArea.widthRatio * container.width;
+
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+
+ if (ny > 3) {
+ var t;
+ if (container.orientation == Qt.Vertical)
+ t = Math.ceil(container.height - 3 - ny);
+ else
+ t = Math.ceil(container.width - 3 - ny);
+ if (nh > t) return t; else return nh;
+ } else return nh + ny;
+ }
+
+ Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 }
+
+ BorderImage {
+ source: "images/scrollbar.png"
+ border { left: 1; right: 1; top: 1; bottom: 1 }
+ x: container.orientation == Qt.Vertical ? 2 : position()
+ width: container.orientation == Qt.Vertical ? container.width - 4 : size()
+ y: container.orientation == Qt.Vertical ? position() : 2
+ height: container.orientation == Qt.Vertical ? size() : container.height - 4
+ }
+
+ states: State {
+ name: "visible"
+ when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally
+ PropertyChanges { target: container; opacity: 1.0 }
+ }
+
+ transitions: Transition {
+ from: "visible"; to: ""
+ NumberAnimation { properties: "opacity"; duration: 600 }
+ }
+}
diff --git a/examples/declarative/rssnews/content/images/busy.png b/examples/declarative/rssnews/content/images/busy.png
new file mode 100644
index 0000000000..664c2b1491
--- /dev/null
+++ b/examples/declarative/rssnews/content/images/busy.png
Binary files differ
diff --git a/examples/declarative/rssnews/content/images/scrollbar.png b/examples/declarative/rssnews/content/images/scrollbar.png
new file mode 100644
index 0000000000..0228dcf9eb
--- /dev/null
+++ b/examples/declarative/rssnews/content/images/scrollbar.png
Binary files differ
diff --git a/examples/declarative/rssnews/rssnews.qml b/examples/declarative/rssnews/rssnews.qml
new file mode 100644
index 0000000000..b2057a9ed3
--- /dev/null
+++ b/examples/declarative/rssnews/rssnews.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+import "content"
+
+Rectangle {
+ id: window
+ width: 800; height: 480
+
+ property string currentFeed: "rss.news.yahoo.com/rss/topstories"
+ property bool loading: feedModel.status == XmlListModel.Loading
+
+ RssFeeds { id: rssFeeds }
+
+ XmlListModel {
+ id: feedModel
+ source: "http://" + window.currentFeed
+ query: "/rss/channel/item"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "link"; query: "link/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ }
+
+ Row {
+ Rectangle {
+ width: 220; height: window.height
+ color: "#efefef"
+
+ ListView {
+ focus: true
+ id: categories
+ anchors.fill: parent
+ model: rssFeeds
+ footer: quitButtonDelegate
+ delegate: CategoryDelegate {}
+ highlight: Rectangle { color: "steelblue" }
+ highlightMoveSpeed: 9999999
+ }
+ ScrollBar {
+ scrollArea: categories; height: categories.height; width: 8
+ anchors.right: categories.right
+ }
+ }
+ ListView {
+ id: list
+ width: window.width - 220; height: window.height
+ model: feedModel
+ delegate: NewsDelegate {}
+ }
+ }
+ Component {
+ id: quitButtonDelegate
+ Item {
+ width: categories.width; height: 60
+ Text {
+ text: "Quit"
+ font { family: "Helvetica"; pixelSize: 16; bold: true }
+ anchors {
+ left: parent.left; leftMargin: 15
+ verticalCenter: parent.verticalCenter
+ }
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+ }
+ ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right }
+ Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" }
+}
diff --git a/examples/declarative/rssnews/rssnews.qmlproject b/examples/declarative/rssnews/rssnews.qmlproject
new file mode 100644
index 0000000000..d4909f8685
--- /dev/null
+++ b/examples/declarative/rssnews/rssnews.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/declarative/samegame/SamegameCore/BoomBlock.qml b/examples/declarative/samegame/SamegameCore/BoomBlock.qml
new file mode 100644
index 0000000000..2d8fdba2c9
--- /dev/null
+++ b/examples/declarative/samegame/SamegameCore/BoomBlock.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+
+ Image {
+ id: img
+ source: {
+ if(type == 0){
+ "pics/redStone.png";
+ } else if(type == 1) {
+ "pics/blueStone.png";
+ } else {
+ "pics/greenStone.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.fill: parent
+ }
+ Emitter {
+ id: particles
+ system: particleSystem
+ particle: {
+ if(type == 0){
+ "red";
+ } else if (type == 1) {
+ "blue";
+ } else {
+ "green";
+ }
+ }
+ anchors.fill: parent
+
+ speed: TargetedDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60}
+ shape: EllipseShape{fill:true}
+ emitting: false;
+ lifeSpan: 700; lifeSpanVariation: 100
+ emitRate: 1000
+ emitCap: 100 //only fires 0.1s bursts (still 2x old number, ImageParticle wants less than 16000 max though)
+ size: 28
+ endSize: 14
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.pulse(0.1); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/examples/declarative/samegame/SamegameCore/Button.qml b/examples/declarative/samegame/SamegameCore/Button.qml
new file mode 100644
index 0000000000..be9ad62dfd
--- /dev/null
+++ b/examples/declarative/samegame/SamegameCore/Button.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 20
+ smooth: true
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ radius: 8
+ color: activePalette.button
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText; font.pixelSize: 24
+ }
+}
diff --git a/examples/declarative/samegame/SamegameCore/Dialog.qml b/examples/declarative/samegame/SamegameCore/Dialog.qml
new file mode 100644
index 0000000000..aea6ac7dda
--- /dev/null
+++ b/examples/declarative/samegame/SamegameCore/Dialog.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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
+
+Rectangle {
+ id: page
+
+ property Item text: dialogText
+ property bool open: false
+
+ signal closed
+ signal opened
+ function forceClose() {
+ if(!open)
+ return; //already closed
+ page.open = false;
+ page.closed();
+ page.opacity = 0;
+ }
+
+ function show(txt) {
+ page.open = true;
+ page.opened();
+ dialogText.text = txt;
+ page.opacity = 1;
+ }
+
+ width: dialogText.width + 20; height: dialogText.height + 20
+ color: "white"
+ border.width: 1
+ opacity: 0
+ visible: opacity > 0
+ Behavior on opacity {
+ NumberAnimation { duration: 1000 }
+ }
+
+ Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" }
+
+ MouseArea { anchors.fill: parent; onClicked: forceClose(); }
+}
+
diff --git a/examples/declarative/samegame/SamegameCore/pics/background.png b/examples/declarative/samegame/SamegameCore/pics/background.png
new file mode 100644
index 0000000000..3734a27744
--- /dev/null
+++ b/examples/declarative/samegame/SamegameCore/pics/background.png
Binary files differ
diff --git a/examples/declarative/samegame/SamegameCore/pics/blueStone.png b/examples/declarative/samegame/SamegameCore/pics/blueStone.png
new file mode 100644
index 0000000000..20e43c75b6
--- /dev/null
+++ b/examples/declarative/samegame/SamegameCore/pics/blueStone.png
Binary files differ
diff --git a/examples/declarative/samegame/SamegameCore/pics/greenStone.png b/examples/declarative/samegame/SamegameCore/pics/greenStone.png
new file mode 100644
index 0000000000..b568a1900c
--- /dev/null
+++ b/examples/declarative/samegame/SamegameCore/pics/greenStone.png
Binary files differ
diff --git a/examples/declarative/samegame/SamegameCore/pics/particle.png b/examples/declarative/samegame/SamegameCore/pics/particle.png
new file mode 100644
index 0000000000..5c83896d22
--- /dev/null
+++ b/examples/declarative/samegame/SamegameCore/pics/particle.png
Binary files differ
diff --git a/examples/declarative/samegame/SamegameCore/pics/redStone.png b/examples/declarative/samegame/SamegameCore/pics/redStone.png
new file mode 100644
index 0000000000..36b09a2686
--- /dev/null
+++ b/examples/declarative/samegame/SamegameCore/pics/redStone.png
Binary files differ
diff --git a/examples/declarative/samegame/SamegameCore/pics/yellowStone.png b/examples/declarative/samegame/SamegameCore/pics/yellowStone.png
new file mode 100644
index 0000000000..b1ce76212c
--- /dev/null
+++ b/examples/declarative/samegame/SamegameCore/pics/yellowStone.png
Binary files differ
diff --git a/examples/declarative/samegame/SamegameCore/qmldir b/examples/declarative/samegame/SamegameCore/qmldir
new file mode 100644
index 0000000000..e17b1f5d2b
--- /dev/null
+++ b/examples/declarative/samegame/SamegameCore/qmldir
@@ -0,0 +1,3 @@
+BoomBlock BoomBlock.qml
+Button Button.qml
+Dialog Dialog.qml
diff --git a/examples/declarative/samegame/SamegameCore/samegame.js b/examples/declarative/samegame/SamegameCore/samegame.js
new file mode 100755
index 0000000000..4c5cbe5bb3
--- /dev/null
+++ b/examples/declarative/samegame/SamegameCore/samegame.js
@@ -0,0 +1,288 @@
+/* This script file handles the game logic */
+
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn*maxRow;
+var board = new Array(maxIndex);
+var blockSrc = "BoomBlock.qml";
+var scoresURL = "";
+var gameDuration;
+var component = Qt.createComponent(blockSrc);
+var highScoreBar = 0;
+
+// Index function used instead of a 2D array
+function index(column, row)
+{
+ return column + row * maxColumn;
+}
+
+function timeStr(msecs)
+{
+ var secs = Math.floor(msecs/1000);
+ var m = Math.floor(secs/60);
+ var ret = "" + m + "m " + (secs%60) + "s";
+ return ret;
+}
+
+function startNewGame()
+{
+ // Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ }
+
+ // Calculate board size
+ maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ // Close dialogs
+ nameInputDialog.forceClose();
+ dialog.forceClose();
+
+ // Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+ gameDuration = new Date();
+}
+
+var fillFound; // Set after a floodFill call to the number of blocks found
+var floodBoard; // Set to 1 if the floodFill reaches off that node
+
+// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
+function handleClick(x,y)
+{
+ var column = Math.floor(x/gameCanvas.blockSize);
+ var row = Math.floor(y/gameCanvas.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ // If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column,row, -1);
+ if (fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+
+function floodFill(column,row,type)
+{
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column,row)].type;
+
+ // Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; // Can't remove single blocks
+ board[index(column, row)].dying = true;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown()
+{
+ // Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column,row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y = (row + fallDist) * gameCanvas.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ // Fall to the left
+ fallDist = 0;
+ for (column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (row = 0; row < maxRow; row++) {
+ obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x = (column - fallDist) * gameCanvas.blockSize;
+ board[index(column - fallDist,row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+function victoryCheck()
+{
+ // Awards bonuses for no blocks left
+ var deservesBonus = true;
+ for (var column = maxColumn - 1; column >= 0; column--)
+ if (board[index(column, maxRow - 1)] != null)
+ deservesBonus = false;
+ if (deservesBonus)
+ gameCanvas.score += 500;
+ // Checks for game over
+ if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) {
+ gameDuration = new Date() - gameDuration;
+ if(gameCanvas.score > highScoreBar){
+ nameInputDialog.show("You won! Please enter your name: ");
+ nameInputDialog.initialWidth = nameInputDialog.text.width + 20;
+ if (nameInputDialog.name == "")
+ nameInputDialog.width = nameInputDialog.initialWidth;
+ nameInputDialog.text.opacity = 0; // Just a spacer
+ }else{
+ dialog.show("You won!");
+ }
+ }
+}
+
+// Only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type)
+{
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ return floodMoveCheck(column + 1, row, myType) ||
+ floodMoveCheck(column, row - 1, board[index(column, row)].type);
+}
+
+function createBlock(column,row)
+{
+ // Note that we don't wait for the component to become ready. This will
+ // only work if the block QML is a local file. Otherwise the component will
+ // not be ready immediately. There is a statusChanged signal on the
+ // component you could use if you want to wait to load remote files.
+ if(component.status == Component.Ready){
+ var dynamicObject = component.createObject(gameCanvas,
+ {"type": Math.floor(Math.random() * 3),
+ "x": column*gameCanvas.blockSize,
+ "width": gameCanvas.blockSize,
+ "height": gameCanvas.blockSize});
+ if(dynamicObject == null){
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.y = row*gameCanvas.blockSize;
+ dynamicObject.spawned = true;
+
+ board[index(column,row)] = dynamicObject;
+ }else{
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+function initHighScoreBar()
+{
+ if(scoresURL != "")
+ return true;//don't query remote scores
+ var db = openDatabaseSync(
+ "SameGameScores",
+ "1.0",
+ "Local SameGame High Scores",
+ 100
+ );
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ // Only show results for the current grid size
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'
+ + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10');
+ if(rs.rows.length < 10)
+ highScoreBar = 0;
+ else
+ highScoreBar = rs.rows.item(rs.rows.length - 1).score;
+ }
+ );
+}
+
+function saveHighScore(name)
+{
+ if (scoresURL != "")
+ sendHighScore(name);
+ // Offline storage
+ var db = openDatabaseSync(
+ "SameGameScores",
+ "1.0",
+ "Local SameGame High Scores",
+ 100
+ );
+ var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
+ var data = [
+ name,
+ gameCanvas.score,
+ maxColumn + "x" + maxRow,
+ Math.floor(gameDuration / 1000)
+ ];
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ tx.executeSql(dataStr, data);
+
+ // Only show results for the current grid size
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'
+ + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10');
+ var r = "\nHIGH SCORES for this grid size\n\n"
+ for (var i = 0; i < rs.rows.length; i++) {
+ r += (i+1) + ". " + rs.rows.item(i).name + ' got '
+ + rs.rows.item(i).score + ' points in '
+ + rs.rows.item(i).time + ' seconds.\n';
+ }
+ if(rs.rows.length == 10)
+ highScoreBar = rs.rows.item(9).score;
+ dialog.show(r);
+ }
+ );
+}
+
+function sendHighScore(name)
+{
+ var postman = new XMLHttpRequest()
+ var postData = "name=" + name + "&score=" + gameCanvas.score
+ + "&gridSize=" + maxColumn + "x" + maxRow
+ + "&time=" + Math.floor(gameDuration / 1000);
+ postman.open("POST", scoresURL, true);
+ postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ postman.onreadystatechange = function() {
+ if (postman.readyState == postman.DONE) {
+ dialog.show("Your score has been uploaded.");
+ }
+ }
+ postman.send(postData);
+}
diff --git a/examples/declarative/samegame/highscores/README b/examples/declarative/samegame/highscores/README
new file mode 100644
index 0000000000..eaa00fae37
--- /dev/null
+++ b/examples/declarative/samegame/highscores/README
@@ -0,0 +1 @@
+The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it.
diff --git a/examples/declarative/samegame/highscores/score_data.xml b/examples/declarative/samegame/highscores/score_data.xml
new file mode 100755
index 0000000000..c3fd90d9cf
--- /dev/null
+++ b/examples/declarative/samegame/highscores/score_data.xml
@@ -0,0 +1,2 @@
+<record><score>1000000</score><name>Alan the Tester</name><gridSize>0x0</gridSize><seconds>0</seconds></record>
+<record><score>6213</score><name>Alan</name><gridSize>12x17</gridSize><seconds>51</seconds></record>
diff --git a/examples/declarative/samegame/highscores/score_style.xsl b/examples/declarative/samegame/highscores/score_style.xsl
new file mode 100755
index 0000000000..670354c965
--- /dev/null
+++ b/examples/declarative/samegame/highscores/score_style.xsl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/">
+ <html>
+ <head><title>SameGame High Scores</title></head>
+ <body>
+ <h2>SameGame High Scores</h2>
+ <table border="1">
+ <tr bgcolor="lightsteelblue">
+ <th>Name</th>
+ <th>Score</th>
+ <th>Grid Size</th>
+ <th>Time, s</th>
+ </tr>
+ <xsl:for-each select="records/record">
+ <xsl:sort select="score" data-type="number" order="descending"/>
+ <tr>
+ <td><xsl:value-of select="name"/></td>
+ <td><xsl:value-of select="score"/></td>
+ <td><xsl:value-of select="gridSize"/></td>
+ <td><xsl:value-of select="seconds"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/examples/declarative/samegame/highscores/scores.php b/examples/declarative/samegame/highscores/scores.php
new file mode 100755
index 0000000000..3cceb2d738
--- /dev/null
+++ b/examples/declarative/samegame/highscores/scores.php
@@ -0,0 +1,34 @@
+<?php
+ $score = $_POST["score"];
+ echo "<html>";
+ echo "<head><title>SameGame High Scores</title></head><body>";
+ if($score > 0){#Sending in a new high score
+ $name = $_POST["name"];
+ $grid = $_POST["gridSize"];
+ $time = $_POST["time"];
+ if($name == "")
+ $name = "Anonymous";
+ //if($grid != "10x10"){
+ //Need a standard, so as to reject others?
+ //}
+ $file = fopen("score_data.xml", "a"); #It's XML. Happy?
+ $ret = fwrite($file, "<record><score>". $score . "</score><name>"
+ . $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
+ . $time . "</seconds></record>\n");
+ echo "Your score has been recorded. Thanks for playing!";
+ if($ret == False)
+ echo "<br/> There was an error though, so don't expect to see that score again.";
+ }else{#Read high score list
+ #Now uses XSLT to display. So just print the file. With XML cruft added.
+ #Note that firefox at least won't apply the XSLT on a php file. So redirecting
+ $file = fopen("scores.xml", "w");
+ $ret = fwrite($file, '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"
+ . '<?xml-stylesheet type="text/xsl" href="score_style.xsl"?>' . "\n"
+ . "<records>\n" . file_get_contents("score_data.xml") . "</records>\n");
+ if($ret == False)
+ echo "There was an internal error. Sorry.";
+ else
+ echo '<script type="text/javascript">window.location.replace("scores.xml")</script>';
+ }
+ echo "</body></html>";
+?>
diff --git a/examples/declarative/samegame/samegame.qml b/examples/declarative/samegame/samegame.qml
new file mode 100644
index 0000000000..0daf72de58
--- /dev/null
+++ b/examples/declarative/samegame/samegame.qml
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 "SamegameCore"
+import "SamegameCore/samegame.js" as Logic
+
+Rectangle {
+ id: screen
+ width: 360; height: 640
+ property bool inAnotherDemo: false //Samegame often is just plonked straight into other demos
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "SamegameCore/pics/background.png"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+ Item {
+ id: gameCanvas
+ property int score: 0
+ property int blockSize: 40
+
+ z: 20; anchors.centerIn: parent
+ width: parent.width - (parent.width % blockSize);
+ height: parent.height - (parent.height % blockSize);
+
+ MouseArea {
+ anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y);
+ }
+ }
+ Item{
+ ParticleSystem{ id: particleSystem; }
+ ImageParticle {
+ system: particleSystem
+ particles: ["red"]
+ color: Qt.darker("red");//Actually want desaturated...
+ source: "SamegameCore/pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ system: particleSystem
+ particles: ["green"]
+ color: Qt.darker("green");//Actually want desaturated...
+ source: "SamegameCore/pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ system: particleSystem
+ particles: ["blue"]
+ color: Qt.darker("blue");//Actually want desaturated...
+ source: "SamegameCore/pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ id: aboveGameCanvas
+ anchors.fill: gameCanvas
+ z: gameCanvas.z + 1
+ }
+ }
+
+ Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
+
+ Dialog {
+ id: nameInputDialog
+
+ property int initialWidth: 0
+ property alias name: nameInputText.text
+
+ anchors.centerIn: parent
+ z: 22;
+
+ Behavior on width {
+ NumberAnimation {}
+ enabled: nameInputDialog.initialWidth != 0
+ }
+
+ onClosed: {
+ if (nameInputText.text != "")
+ Logic.saveHighScore(nameInputText.text);
+ }
+ Text {
+ id: dialogText
+ anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter }
+ text: "You won! Please enter your name: "
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (nameInputText.text == "")
+ nameInputText.openSoftwareInputPanel();
+ else
+ nameInputDialog.forceClose();
+ }
+ }
+
+ TextInput {
+ id: nameInputText
+ anchors { verticalCenter: parent.verticalCenter; left: dialogText.right }
+ focus: visible
+ autoScroll: false
+ maximumLength: 24
+ onTextChanged: {
+ var newWidth = nameInputText.width + dialogText.width + 40;
+ if ( (newWidth > nameInputDialog.width && newWidth < screen.width)
+ || (nameInputDialog.width > nameInputDialog.initialWidth) )
+ nameInputDialog.width = newWidth;
+ }
+ onAccepted: {
+ nameInputDialog.forceClose();
+ }
+ }
+ }
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 58
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ id: newGameButton
+ anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: Logic.startNewGame()
+ }
+
+ Button {
+ visible: !inAnotherDemo
+ text: "Quit"
+ anchors { left: newGameButton.right; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ onClicked: Qt.quit();
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; rightMargin: 3; verticalCenter: parent.verticalCenter }
+ text: "Score: " + gameCanvas.score
+ font.bold: true
+ font.pixelSize: 24
+ color: activePalette.windowText
+ }
+ }
+}
diff --git a/examples/declarative/samegame/samegame.qmlproject b/examples/declarative/samegame/samegame.qmlproject
new file mode 100644
index 0000000000..d4909f8685
--- /dev/null
+++ b/examples/declarative/samegame/samegame.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/declarative/shadereffects/Slider.qml b/examples/declarative/shadereffects/Slider.qml
new file mode 100644
index 0000000000..e31335d984
--- /dev/null
+++ b/examples/declarative/shadereffects/Slider.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ property real value: bar.x / (foo.width - bar.width)
+ Item {
+ id: foo
+ width: parent.width - 4
+ height: 6
+ anchors.centerIn: parent
+
+ Rectangle {
+ height: parent.height
+ anchors.left: parent.left
+ anchors.right: bar.horizontalCenter
+ color: "blue"
+ radius: 3
+ }
+ Rectangle {
+ height: parent.height
+ anchors.left: bar.horizontalCenter
+ anchors.right: parent.right
+ color: "gray"
+ radius: 3
+ }
+ Rectangle {
+ anchors.fill: parent
+ color: "transparent"
+ radius: 3
+ border.width: 2
+ border.color: "black"
+ }
+
+ Rectangle {
+ id: bar
+ y: -7
+ width: 20
+ height: 20
+ radius: 15
+ color: "white"
+ border.width: 2
+ border.color: "black"
+ MouseArea {
+ anchors.fill: parent
+ drag.target: parent
+ drag.axis: Drag.XAxis
+ drag.minimumX: 0
+ drag.maximumX: foo.width - parent.width
+ }
+ }
+ }
+}
+
diff --git a/examples/declarative/shadereffects/face-smile.png b/examples/declarative/shadereffects/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/declarative/shadereffects/face-smile.png
Binary files differ
diff --git a/examples/declarative/shadereffects/qt-logo.png b/examples/declarative/shadereffects/qt-logo.png
new file mode 100644
index 0000000000..7d3e97eb36
--- /dev/null
+++ b/examples/declarative/shadereffects/qt-logo.png
Binary files differ
diff --git a/examples/declarative/shadereffects/shader-demo.qml b/examples/declarative/shadereffects/shader-demo.qml
new file mode 100644
index 0000000000..1226064a5d
--- /dev/null
+++ b/examples/declarative/shadereffects/shader-demo.qml
@@ -0,0 +1,295 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ width: 640
+ height: 360
+ source: "../snake/content/pics/background.png"
+
+ ShaderEffectSource {
+ id: theSource
+ sourceItem: theItem
+ smooth: true
+ }
+
+ function saturate(x) {
+ return Math.min(Math.max(x, 0), 1)
+ }
+
+ function sliderToColor(x) {
+ return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)),
+ saturate(Math.min(6 * x, 4 - 6 * x)),
+ saturate(Math.min(6 * x - 2, 6 - 6 * x)))
+ }
+
+ Grid {
+ anchors.centerIn: parent
+ columns: 3
+
+ Item {
+ id: theItem
+ width: 180
+ height: 180
+ ListView {
+ anchors.centerIn: parent
+ width: 160
+ height: 140
+ clip: true
+ snapMode: ListView.SnapOneItem
+ model: VisualItemModel {
+ Text {
+ width: 160
+ height: 140
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 120
+ font.family: "Times"
+ color: "blue"
+ text: "Qt"
+ }
+ Image {
+ width: 160
+ height: 140
+ source: "qt-logo.png"
+ smooth: true
+ }
+ Image {
+ width: 160
+ height: 140
+ source: "face-smile.png"
+ smooth: true
+ }
+ }
+ }
+ }
+ ShaderEffectItem {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property real amplitude: 0.04 * wobbleSlider.value
+ property real frequency: 20
+ property real time: 0
+ NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
+ fragmentShader:
+ "uniform highp float amplitude;" +
+ "uniform highp float frequency;" +
+ "uniform highp float time;" +
+ "uniform sampler2D source;" +
+ "varying highp vec2 qt_TexCoord0;" +
+ "void main() {" +
+ " highp vec2 p = sin(time + frequency * qt_TexCoord0);" +
+ " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x));" +
+ "}"
+ Slider {
+ id: wobbleSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffectItem {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property variant shadow: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffectItem {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(0.0, 1.0 / height)
+ property variant source: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffectItem {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(1.0 / width, 0.0)
+ property variant source: theSource
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor = 0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta);
+ }"
+ }
+ }
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor = 0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta);
+ }"
+ }
+ }
+ property real angle: 0
+ property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle))
+ NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 }
+ property variant delta: Qt.size(offset.x / width, offset.y / height)
+ property real darkness: shadowSlider.value
+ fragmentShader: "
+ uniform highp vec2 offset;
+ uniform sampler2D source;
+ uniform sampler2D shadow;
+ uniform highp float darkness;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 fg = texture2D(source, qt_TexCoord0);
+ lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta);
+ gl_FragColor = fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a);
+ }"
+ Slider {
+ id: shadowSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffectItem {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property variant delta: Qt.size(0.5 / width, 0.5 / height)
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ uniform highp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta);
+ lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y));
+ lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y));
+ lowp vec4 br = texture2D(source, qt_TexCoord0 + delta);
+ lowp vec4 gx = (tl + bl) - (tr + br);
+ lowp vec4 gy = (tl + tr) - (bl + br);
+ gl_FragColor.xyz = vec3(0.);
+ gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity;
+ }"
+ }
+ ShaderEffectItem {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property color tint: sliderToColor(colorizeSlider.value)
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform lowp vec4 tint;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 c = texture2D(source, qt_TexCoord0);
+ lowp float lo = min(min(c.x, c.y), c.z);
+ lowp float hi = max(max(c.x, c.y), c.z);
+ gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w);
+ }"
+ Slider {
+ id: colorizeSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffectItem {
+ width: 180
+ height: 180
+ mesh: GridMesh { resolution: Qt.size(10, 10) }
+ property variant source: theSource
+ property real bend: 0
+ property real minimize: 0
+ property real side: genieSlider.value
+ SequentialAnimation on bend {
+ loops: Animation.Infinite
+ NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1600 }
+ NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1000 }
+ }
+ SequentialAnimation on minimize {
+ loops: Animation.Infinite
+ PauseAnimation { duration: 300 }
+ NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1300 }
+ }
+ vertexShader: "
+ uniform highp mat4 qt_ModelViewProjectionMatrix;
+ uniform highp float bend;
+ uniform highp float minimize;
+ uniform highp float side;
+ uniform highp float width;
+ uniform highp float height;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ qt_TexCoord0 = qt_MultiTexCoord0;
+ highp vec4 pos = qt_Vertex;
+ pos.y = mix(qt_Vertex.y, height, minimize);
+ highp float t = pos.y / height;
+ t = (3. - 2. * t) * t * t;
+ pos.x = mix(qt_Vertex.x, side * width, t * bend);
+ gl_Position = qt_ModelViewProjectionMatrix * pos;
+ }"
+ Slider {
+ id: genieSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ }
+}
diff --git a/examples/declarative/snake/content/Button.qml b/examples/declarative/snake/content/Button.qml
new file mode 100644
index 0000000000..d8a3363d6d
--- /dev/null
+++ b/examples/declarative/snake/content/Button.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Rectangle {
+ id: container
+
+ signal clicked
+ property string text: "Button"
+
+ color: activePalette.button; smooth: true
+ width: txtItem.width + 20; height: txtItem.height + 6
+ border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+
+ gradient: Gradient {
+ GradientStop {
+ id: topGrad; position: 0.0
+ color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ }
+}
diff --git a/examples/declarative/snake/content/Cookie.qml b/examples/declarative/snake/content/Cookie.qml
new file mode 100644
index 0000000000..29b56f9e88
--- /dev/null
+++ b/examples/declarative/snake/content/Cookie.qml
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+import Qt.labs.particles 1.0
+
+Item {
+ id: root
+ property bool dying: false
+ property int row;
+ property int column;
+ x: margin + column * gridSize
+ y: margin + row * gridSize
+
+ width: gridSize
+ height: gridSize
+ property int value : 1;
+
+ Image {
+ id: img
+ anchors.fill: parent
+ source: "pics/cookie.png"
+ opacity: 0
+ Text {
+ font.bold: true
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: value
+ }
+ }
+
+
+ Particles { id: particles
+ width:1; height:1; anchors.centerIn: parent;
+ emissionRate: 0;
+ lifeSpan: 700; lifeSpanDeviation: 600;
+ angle: 0; angleDeviation: 360;
+ velocity: 100; velocityDeviation:30;
+ source: "pics/yellowStar.png";
+ }
+
+ states: [
+ State{ name: "AliveState"; when: dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+ State{ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ }
+ ]
+ transitions: [
+ Transition {
+ NumberAnimation { target: img; property: "opacity"; duration: 100 }
+ }
+ ]
+}
diff --git a/examples/declarative/snake/content/HighScoreModel.qml b/examples/declarative/snake/content/HighScoreModel.qml
new file mode 100644
index 0000000000..91b2185ffc
--- /dev/null
+++ b/examples/declarative/snake/content/HighScoreModel.qml
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+// Models a high score table.
+//
+// Use this component like this:
+//
+// HighScoreModel {
+// id: highScores
+// game: "MyCoolGame"
+// }
+//
+// Then use either use the top-score properties:
+//
+// Text { text: "HI: " + highScores.topScore }
+//
+// or, use the model in a view:
+//
+// ListView {
+// model: highScore
+// delegate: Component {
+// ... player ... score ...
+// }
+// }
+//
+// Add new scores via:
+//
+// saveScore(newScore)
+//
+// or:
+//
+// savePlayerScore(playerName,newScore)
+//
+// The best maxScore scores added by this method will be retained in an SQL database,
+// and presented in the model and in the topScore/topPlayer properties.
+//
+
+ListModel {
+ id: model
+ property string game: ""
+ property int topScore: 0
+ property string topPlayer: ""
+ property int maxScores: 10
+
+ function __db()
+ {
+ return openDatabaseSync("HighScoreModel", "1.0", "Generic High Score Functionality for QML", 1000000);
+ }
+ function __ensureTables(tx)
+ {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS HighScores(game TEXT, score INT, player TEXT)', []);
+ }
+
+ function fillModel() {
+ __db().transaction(
+ function(tx) {
+ __ensureTables(tx);
+ var rs = tx.executeSql("SELECT score,player FROM HighScores WHERE game=? ORDER BY score DESC", [game]);
+ model.clear();
+ if (rs.rows.length > 0) {
+ topScore = rs.rows.item(0).score
+ topPlayer = rs.rows.item(0).player
+ for (var i=0; i<rs.rows.length; ++i) {
+ if (i < maxScores)
+ model.append(rs.rows.item(i))
+ }
+ if (rs.rows.length > maxScores)
+ tx.executeSql("DELETE FROM HighScores WHERE game=? AND score <= ?",
+ [game, rs.rows.item(maxScores).score]);
+ }
+ }
+ )
+ }
+
+ function savePlayerScore(player,score) {
+ __db().transaction(
+ function(tx) {
+ __ensureTables(tx);
+ tx.executeSql("INSERT INTO HighScores VALUES(?,?,?)", [game,score,player]);
+ fillModel();
+ }
+ )
+ }
+
+ function saveScore(score) {
+ savePlayerScore("player",score);
+ }
+
+ function clearScores() {
+ __db().transaction(
+ function(tx) {
+ tx.executeSql("DELETE FROM HighScores WHERE game=?", [game]);
+ fillModel();
+ }
+ )
+ }
+
+ Component.onCompleted: { fillModel() }
+}
diff --git a/examples/declarative/snake/content/Link.qml b/examples/declarative/snake/content/Link.qml
new file mode 100644
index 0000000000..ff67ad749e
--- /dev/null
+++ b/examples/declarative/snake/content/Link.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+import Qt.labs.particles 1.0
+
+Item { id:link
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property int row: 0
+ property int column: 0
+ property int rotation;
+
+ width: 40;
+ height: 40
+
+ x: margin - 3 + gridSize * column
+ y: margin - 3 + gridSize * row
+ Behavior on x { NumberAnimation { duration: spawned ? heartbeatInterval : 0} }
+ Behavior on y { NumberAnimation { duration: spawned ? heartbeatInterval : 0 } }
+
+
+ Item {
+ id: img
+ anchors.fill: parent
+ Image {
+ source: {
+ if(type == 1) {
+ "pics/blueStone.png";
+ } else if (type == 2) {
+ "pics/head.png";
+ } else {
+ "pics/redStone.png";
+ }
+ }
+
+ transform: Rotation {
+ id: actualImageRotation
+ origin.x: width/2; origin.y: height/2;
+ angle: rotation * 90
+ Behavior on angle {
+ RotationAnimation{
+ direction: RotationAnimation.Shortest
+ duration: spawned ? 200 : 0
+ }
+ }
+ }
+ }
+
+ Image {
+ source: "pics/stoneShadow.png"
+ }
+
+ opacity: 0
+ }
+
+
+ Particles { id: particles
+ width:1; height:1; anchors.centerIn: parent;
+ emissionRate: 0;
+ lifeSpan: 700; lifeSpanDeviation: 600;
+ angle: 0; angleDeviation: 360;
+ velocity: 100; velocityDeviation:30;
+ source: {
+ if(type == 1){
+ "pics/blueStar.png";
+ } else {
+ "pics/redStar.png";
+ }
+ }
+ }
+
+ states: [
+ State{ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+ State{ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ NumberAnimation { target: img; property: "opacity"; duration: 200 }
+ }
+ ]
+
+}
diff --git a/examples/declarative/snake/content/Skull.qml b/examples/declarative/snake/content/Skull.qml
new file mode 100644
index 0000000000..4f48145f84
--- /dev/null
+++ b/examples/declarative/snake/content/Skull.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Image {
+ property bool spawned: false
+ property int row;
+ property int column;
+ property int verticalMovement;
+ property int horizontalMovement;
+
+ x: margin + column * gridSize + 2
+ y: margin + row * gridSize - 3
+ Behavior on x { NumberAnimation { duration: spawned ? halfbeatInterval : 0} }
+ Behavior on y { NumberAnimation { duration: spawned ? halfbeatInterval : 0 } }
+
+ opacity: spawned ? 1 : 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+
+ source: "pics/skull.png"
+ width: 24
+ height: 40
+}
diff --git a/examples/declarative/snake/content/pics/README b/examples/declarative/snake/content/pics/README
new file mode 100644
index 0000000000..0215132caa
--- /dev/null
+++ b/examples/declarative/snake/content/pics/README
@@ -0,0 +1 @@
+snake.jpg: This image is based on the picture "Eastern Green Mamba.jpg" from the free media databse Wikimedia Commons and is published under the terms of the GNU Free Documentation License. The original picture was taken by Danleo.
diff --git a/examples/declarative/snake/content/pics/background.png b/examples/declarative/snake/content/pics/background.png
new file mode 100644
index 0000000000..72dffaa843
--- /dev/null
+++ b/examples/declarative/snake/content/pics/background.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/blueStar.png b/examples/declarative/snake/content/pics/blueStar.png
new file mode 100644
index 0000000000..ba7acabd26
--- /dev/null
+++ b/examples/declarative/snake/content/pics/blueStar.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/blueStone.png b/examples/declarative/snake/content/pics/blueStone.png
new file mode 100644
index 0000000000..356affdd95
--- /dev/null
+++ b/examples/declarative/snake/content/pics/blueStone.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/cookie.png b/examples/declarative/snake/content/pics/cookie.png
new file mode 100644
index 0000000000..aec2957f34
--- /dev/null
+++ b/examples/declarative/snake/content/pics/cookie.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/eyes.svg b/examples/declarative/snake/content/pics/eyes.svg
new file mode 100644
index 0000000000..1078692725
--- /dev/null
+++ b/examples/declarative/snake/content/pics/eyes.svg
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ width="40"
+ height="40"
+ version="1.0"
+ sodipodi:docname="eyes.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="/home/ettrich/dev/research/qml-validate/snake/pics/eyes.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs5">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective9" />
+ </defs>
+ <sodipodi:namedview
+ inkscape:window-height="838"
+ inkscape:window-width="907"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ showgrid="false"
+ inkscape:zoom="12.35"
+ inkscape:cx="20"
+ inkscape:cy="20"
+ inkscape:window-x="117"
+ inkscape:window-y="45"
+ inkscape:current-layer="svg2" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2384"
+ sodipodi:cx="18.056681"
+ sodipodi:cy="9.5141697"
+ sodipodi:rx="7.1255059"
+ sodipodi:ry="11.295547"
+ d="M 25.182187,9.5141697 A 7.1255059,11.295547 0 1 1 10.931175,9.5141697 A 7.1255059,11.295547 0 1 1 25.182187,9.5141697 z"
+ transform="matrix(1.0089865,0,0,0.5462656,-4.9233835,3.3301401)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path3158"
+ sodipodi:cx="18.056681"
+ sodipodi:cy="9.5141697"
+ sodipodi:rx="7.1255059"
+ sodipodi:ry="11.295547"
+ d="M 25.182187,9.5141697 A 7.1255059,11.295547 0 1 1 10.931175,9.5141697 A 7.1255059,11.295547 0 1 1 25.182187,9.5141697 z"
+ transform="matrix(1.0089865,0,0,0.5462656,9.6190931,3.3522563)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#000000;fill-opacity:1"
+ id="path3182"
+ sodipodi:cx="16.275303"
+ sodipodi:cy="12.307693"
+ sodipodi:rx="2.2672064"
+ sodipodi:ry="3.4008098"
+ d="M 18.542509,12.307693 A 2.2672064,3.4008098 0 0 1 14.008446,12.367372"
+ sodipodi:start="0"
+ sodipodi:end="3.1240432"
+ transform="translate(11.65992,-9.740891)"
+ sodipodi:open="true" />
+ <rect
+ style="fill:#000000;fill-opacity:0"
+ id="rect2382"
+ width="40"
+ height="40"
+ x="0"
+ y="-7.1054274e-15"
+ inkscape:export-filename="/home/ettrich/dev/research/qml-validate/snake/pics/eyes.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#000000;fill-opacity:1"
+ id="path2383"
+ sodipodi:cx="16.275303"
+ sodipodi:cy="12.307693"
+ sodipodi:rx="2.2672064"
+ sodipodi:ry="3.4008098"
+ d="M 18.542509,12.307693 A 2.2672064,3.4008098 0 0 1 14.008446,12.367372"
+ sodipodi:start="0"
+ sodipodi:end="3.1240432"
+ transform="translate(-3.3200119,-9.821862)"
+ sodipodi:open="true" />
+</svg>
diff --git a/examples/declarative/snake/content/pics/head.png b/examples/declarative/snake/content/pics/head.png
new file mode 100644
index 0000000000..550e002687
--- /dev/null
+++ b/examples/declarative/snake/content/pics/head.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/head.svg b/examples/declarative/snake/content/pics/head.svg
new file mode 100644
index 0000000000..3bf0bd2feb
--- /dev/null
+++ b/examples/declarative/snake/content/pics/head.svg
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ width="40"
+ height="40"
+ version="1.0"
+ sodipodi:docname="head.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="/home/ettrich/dev/research/qml-validate/snake/pics/head.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs5">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective9" />
+ <inkscape:perspective
+ id="perspective2444"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <sodipodi:namedview
+ inkscape:window-height="838"
+ inkscape:window-width="907"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ showgrid="false"
+ inkscape:zoom="12.35"
+ inkscape:cx="20"
+ inkscape:cy="20"
+ inkscape:window-x="117"
+ inkscape:window-y="45"
+ inkscape:current-layer="svg2" />
+ <image
+ y="0.21862352"
+ x="-0.048582077"
+ id="image2446"
+ height="40"
+ width="40"
+ sodipodi:absref="/home/ettrich/dev/research/qml-validate/snake/pics/redStone.png"
+ xlink:href="redStone.png" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2384"
+ sodipodi:cx="18.056681"
+ sodipodi:cy="9.5141697"
+ sodipodi:rx="7.1255059"
+ sodipodi:ry="11.295547"
+ d="M 25.182187,9.5141697 A 7.1255059,11.295547 0 1 1 10.931175,9.5141697 A 7.1255059,11.295547 0 1 1 25.182187,9.5141697 z"
+ transform="matrix(1.0089865,0,0,0.5462656,-4.9233835,3.3301401)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path3158"
+ sodipodi:cx="18.056681"
+ sodipodi:cy="9.5141697"
+ sodipodi:rx="7.1255059"
+ sodipodi:ry="11.295547"
+ d="M 25.182187,9.5141697 A 7.1255059,11.295547 0 1 1 10.931175,9.5141697 A 7.1255059,11.295547 0 1 1 25.182187,9.5141697 z"
+ transform="matrix(1.0089865,0,0,0.5462656,9.6190931,3.3522563)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#000000;fill-opacity:1"
+ id="path3182"
+ sodipodi:cx="16.275303"
+ sodipodi:cy="12.307693"
+ sodipodi:rx="2.2672064"
+ sodipodi:ry="3.4008098"
+ d="M 18.542509,12.307693 A 2.2672064,3.4008098 0 0 1 14.008446,12.367372"
+ sodipodi:start="0"
+ sodipodi:end="3.1240432"
+ transform="translate(11.65992,-9.740891)"
+ sodipodi:open="true" />
+ <rect
+ style="fill:#000000;fill-opacity:0"
+ id="rect2382"
+ width="40"
+ height="40"
+ x="0"
+ y="-7.1054274e-15"
+ inkscape:export-filename="/home/ettrich/dev/research/qml-validate/snake/pics/eyes.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#000000;fill-opacity:1"
+ id="path2383"
+ sodipodi:cx="16.275303"
+ sodipodi:cy="12.307693"
+ sodipodi:rx="2.2672064"
+ sodipodi:ry="3.4008098"
+ d="M 18.542509,12.307693 A 2.2672064,3.4008098 0 0 1 14.008446,12.367372"
+ sodipodi:start="0"
+ sodipodi:end="3.1240432"
+ transform="translate(-3.3200119,-9.821862)"
+ sodipodi:open="true" />
+</svg>
diff --git a/examples/declarative/snake/content/pics/pause.png b/examples/declarative/snake/content/pics/pause.png
new file mode 100644
index 0000000000..056d97dd17
--- /dev/null
+++ b/examples/declarative/snake/content/pics/pause.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/redStar.png b/examples/declarative/snake/content/pics/redStar.png
new file mode 100644
index 0000000000..cd06854719
--- /dev/null
+++ b/examples/declarative/snake/content/pics/redStar.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/redStone.png b/examples/declarative/snake/content/pics/redStone.png
new file mode 100644
index 0000000000..9bb7fe4277
--- /dev/null
+++ b/examples/declarative/snake/content/pics/redStone.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/skull.png b/examples/declarative/snake/content/pics/skull.png
new file mode 100644
index 0000000000..63186167bd
--- /dev/null
+++ b/examples/declarative/snake/content/pics/skull.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/snake.jpg b/examples/declarative/snake/content/pics/snake.jpg
new file mode 100644
index 0000000000..e91a784f71
--- /dev/null
+++ b/examples/declarative/snake/content/pics/snake.jpg
Binary files differ
diff --git a/examples/declarative/snake/content/pics/star.png b/examples/declarative/snake/content/pics/star.png
new file mode 100644
index 0000000000..defbde53ca
--- /dev/null
+++ b/examples/declarative/snake/content/pics/star.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/stoneShadow.png b/examples/declarative/snake/content/pics/stoneShadow.png
new file mode 100644
index 0000000000..1bd56afd04
--- /dev/null
+++ b/examples/declarative/snake/content/pics/stoneShadow.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/yellowStar.png b/examples/declarative/snake/content/pics/yellowStar.png
new file mode 100644
index 0000000000..52fb9c4b78
--- /dev/null
+++ b/examples/declarative/snake/content/pics/yellowStar.png
Binary files differ
diff --git a/examples/declarative/snake/content/pics/yellowStone.png b/examples/declarative/snake/content/pics/yellowStone.png
new file mode 100644
index 0000000000..c56124a895
--- /dev/null
+++ b/examples/declarative/snake/content/pics/yellowStone.png
Binary files differ
diff --git a/examples/declarative/snake/content/snake.js b/examples/declarative/snake/content/snake.js
new file mode 100644
index 0000000000..837b82addd
--- /dev/null
+++ b/examples/declarative/snake/content/snake.js
@@ -0,0 +1,316 @@
+
+var snake = new Array;
+var board = new Array;
+var links = new Array;
+var scheduledDirections = new Array;
+var numRows = 1;
+var numColumns = 1;
+var linkComponent = Qt.createComponent("content/Link.qml"); // XXX should resolve relative to script, not component
+var cookieComponent = Qt.createComponent("content/Cookie.qml");
+var cookie;
+var linksToGrow = 0;
+var linksToDie = 0;
+var waitForCookie = 0;
+var growType = 0;
+var skullMovementsBeforeDirectionChange = 0;
+
+
+function rand(n)
+{
+ return (Math.floor(Math.random() * n));
+}
+
+function scheduleDirection(dir)
+{
+ if (state == "starting") {
+ direction = dir;
+ headDirection = direction;
+ head.rotation = headDirection;
+ } else if (state == "running"){
+ direction = dir;
+ if(scheduledDirections[scheduledDirections.length-1]!=direction)
+ scheduledDirections.push(direction);
+ }
+}
+
+function startNewGame()
+{
+ if (state == "starting") {
+ return;
+ }
+
+ if (activeGame) {
+ endGame();
+ startNewGameTimer.running = true;
+ return;
+ }
+
+ state = "starting";
+
+ numRows = numRowsAvailable;
+ numColumns = numColumnsAvailable;
+ board = new Array(numRows * numColumns);
+ snake = new Array;
+ scheduledDirections = new Array;
+ growType = 0;
+
+ skull.z = numRows * numColumns + 1;
+
+ for (var i = 0; i < numRows * numColumns; ++i) {
+ if (i < links.length) {
+ var link = links[i];
+ link.spawned = false;
+ link.dying = false;
+ } else {
+ if(linkComponent.status != Component.Ready) {
+ if(linkComponent.status == Component.Error)
+ console.log(linkComponent.errorString());
+ else
+ console.log("Still loading linkComponent");
+ continue;//TODO: Better error handling?
+ }
+ var link = linkComponent.createObject(playfield);
+ link.z = numRows * numColumns + 1 - i;
+ link.type = i == 0 ? 2 : 0;
+ link.spawned = false;
+ link.dying = false;
+ links.push(link);
+ }
+ }
+
+ head = links[0];
+ snake.push(head);
+ head.row = numRows/2 -1;
+ head.column = numColumns/2 -1;
+ head.spawned = true;
+
+ linksToGrow = 5;
+ linksToDie = 0;
+ waitForCookie = 5;
+ score = 0;
+ startHeartbeatTimer.running = true;
+}
+
+function endGame()
+{
+ activeGame = false;
+ for(var i in snake)
+ snake[i].dying = true;
+ if (cookie) {
+ cookie.dying = true;
+ cookie = 0;
+ }
+ lastScore = score;
+ highScores.saveScore(lastScore);
+ state = "";
+}
+
+function move() {
+
+ if (!head)
+ return;
+
+ var dir = direction;
+
+ if (scheduledDirections.length) {
+ dir = scheduledDirections.shift();
+ }
+
+ if (state == "starting") {
+ var turn = (dir - headDirection);
+ head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
+ headDirection = dir;
+ return;
+ }
+
+ var row = head.row;
+ var column = head.column;
+
+ if (dir == 0) {
+ row = row - 1;
+ } else if (dir == 1) {
+ column = column + 1
+ } else if (dir == 2) {
+ row = row + 1;
+ } else if (dir == 3) {
+ column = column - 1;
+ }
+
+ //validate the new position
+ if (row < 0 || row >= numRows
+ || column < 0 || column >= numColumns
+ || (row == skull.row && column == skull.column)
+ || !isFree(row, column)) {
+ var turn = (dir - headDirection);
+ head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
+ headDirection = dir;
+ endGame();
+ return;
+ }
+
+ var newLink;
+ if (linksToGrow > 0) {
+ --linksToGrow;
+ newLink = links[snake.length];
+ newLink.spawned = false;
+ newLink.rotation = snake[snake.length-1].rotation;
+ newLink.type = growType;
+ newLink.dying = false;
+ snake.push(newLink);
+ } else {
+ var lastLink = snake[snake.length-1];
+ board[lastLink.row * numColumns + lastLink.column] = undefined;
+ }
+
+ if (waitForCookie > 0) {
+ if (--waitForCookie == 0)
+ createCookie(cookie? (cookie.value+1) : 1);
+ }
+
+ for (var i = snake.length-1; i > 0; --i) {
+ snake[i].row = snake[i-1].row;
+ snake[i].column = snake[i-1].column;
+ snake[i].rotation = snake[i-1].rotation;
+ }
+
+ if (newLink) {
+ newLink.spawned = true;
+ }
+
+ // move the head
+ head.row = row;
+ head.column = column;
+ board[row * numColumns + column] = head;
+
+ var turn = (dir - headDirection);
+ head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
+ headDirection = dir;
+
+ var value = testCookie(row, column);
+ if (value > 0) {
+ linksToGrow += value;
+ score += value;
+ }
+}
+
+function isFree(row, column)
+{
+ return board[row * numColumns + column] == undefined;
+}
+
+function isHead(row, column)
+{
+ return head.column == column && head.row == row;
+}
+
+function testCookie(row, column)
+{
+ if (cookie && !cookie.dying && cookie.row == row && cookie.column == column) {
+ var value = cookie.value;
+ waitForCookie = value;
+ growType = snake[snake.length-1].type == 1 ? 0 : 1;
+ cookie.dying = true;
+ cookie.z = numRows * numColumns + 2;
+ return value;
+ }
+ return 0;
+}
+
+function moveSkull()
+{
+
+ if (linksToDie > 0) {
+ --linksToDie;
+ var link = snake.pop();
+ link.dying = true;
+ board[link.row * numColumns + link.column] = undefined;
+ if (score > 0)
+ --score;
+ if (snake.length == 0) {
+ endGame();
+ return;
+ }
+ }
+
+ var row = skull.row;
+ var column = skull.column;
+ if (isHead(row, column)) {
+ endGame();
+ return;
+ }
+ row += skull.verticalMovement;
+ column += skull.horizontalMovement;
+
+ var attempts = 4;
+
+ while (skullMovementsBeforeDirectionChange == 0 || row < 0 || row >= numRows
+ || column < 0 || column >= numColumns
+ || (!isFree(row, column) && !isHead(row, column))) {
+ var d = rand(8);
+ skull.verticalMovement = 0;
+ skull.horizontalMovement = 0;
+ skullMovementsBeforeDirectionChange = rand(20)+1;
+ if (d == 0) {
+ skull.verticalMovement = -1
+ } else if (d == 1) {
+ skull.horizontalMovement = -1;
+ } else if (d == 2) {
+ skull.verticalMovement = 1
+ } else if (d == 3){
+ skull.horizontalMovement = 1;
+ } else if (cookie) {
+ var rd = cookie.row - skull.row;
+ var rc = cookie.column - skull.column;
+ if (Math.abs(rd) > Math.abs(rc)) {
+ skull.verticalMovement = rd > 0 ? 1 : -1;
+ skullMovementsBeforeDirectionChange = Math.abs(rd);
+ } else {
+ skull.horizontalMovement= rc > 0 ? 1 : -1;
+ skullMovementsBeforeDirectionChange = Math.abs(rc);
+ }
+ }
+ row = skull.row + skull.verticalMovement;
+ column = skull.column + skull.horizontalMovement;
+ if (--attempts == 0)
+ return;
+ }
+
+ skull.row = row;
+ skull.column = column;
+ --skullMovementsBeforeDirectionChange;
+ var value = testCookie(row, column);
+ if (value > 0)
+ linksToDie += value/2;
+
+ if (isHead(row, column))
+ endGame();
+}
+
+function createCookie(value) {
+ if (numRows * numColumns - snake.length < 10)
+ return;
+
+ var column = rand(numColumns);
+ var row = rand(numRows);
+ while (!isFree(row, column)) {
+ column++;
+ if (column == numColumns) {
+ column = 0;
+ row++;
+ if (row == numRows)
+ row = 0;
+ }
+ }
+
+ if(cookieComponent.status != Component.Ready) {
+ if(cookieComponent.status == Component.Error)
+ console.log(cookieComponent.errorString());
+ else
+ console.log("Still loading cookieComponent");
+ return;//TODO: Better error handling?
+ }
+ cookie = cookieComponent.createObject(head.parent);
+ cookie.value = value;
+ cookie.row = row;
+ cookie.column = column;
+}
diff --git a/examples/declarative/snake/snake.qml b/examples/declarative/snake/snake.qml
new file mode 100644
index 0000000000..edccd4c9df
--- /dev/null
+++ b/examples/declarative/snake/snake.qml
@@ -0,0 +1,272 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+import "content" as Content
+import "content/snake.js" as Logic
+
+Rectangle {
+ id: screen;
+ SystemPalette { id: activePalette }
+ color: activePalette.window
+ property bool activeGame: false
+
+ property int gridSize : 34
+ property int margin: 4
+ property int numRowsAvailable: Math.floor((height-32-2*margin)/gridSize)
+ property int numColumnsAvailable: Math.floor((width-2*margin)/gridSize)
+
+ property int lastScore : 0
+
+ property int score: 0;
+ property int heartbeatInterval: 200
+ property int halfbeatInterval: 160
+
+ width: 480
+ height: 750
+
+ property int direction
+ property int headDirection
+
+ property variant head;
+
+ Content.HighScoreModel {
+ id: highScores
+ game: "Snake"
+ }
+
+ Timer {
+ id: heartbeat;
+ interval: heartbeatInterval;
+ running: activeGame && runtime.isActiveWindow
+ repeat: true
+ onTriggered: { Logic.move() }
+ }
+ Timer {
+ id: halfbeat;
+ interval: halfbeatInterval;
+ repeat: true
+ running: heartbeat.running
+ onTriggered: { Logic.moveSkull() }
+ }
+ Timer {
+ id: startNewGameTimer;
+ interval: 700;
+ onTriggered: { Logic.startNewGame(); }
+ }
+
+ Timer {
+ id: startHeartbeatTimer;
+ interval: 1000 ;
+ onTriggered: { state = "running"; activeGame = true; }
+ }
+
+ Image{
+ id: pauseDialog
+ z: 1
+ source: "content/pics/pause.png"
+ anchors.centerIn: parent;
+ //opacity is deliberately not animated
+ opacity: activeGame && !Qt.application.active
+ }
+
+ Image {
+
+ Image {
+ id: title
+ source: "content/pics/snake.jpg"
+ fillMode: Image.PreserveAspectCrop
+ anchors.fill: parent
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+
+ Column {
+ spacing: 140
+ anchors.verticalCenter: parent.verticalCenter;
+ anchors.left: parent.left;
+ anchors.right: parent.right;
+
+ Text {
+ color: "white"
+ font.pointSize: 48
+ font.italic: true;
+ font.bold: true;
+ text: "Snake"
+ anchors.horizontalCenter: parent.horizontalCenter;
+ }
+
+ Text {
+ color: "white"
+ font.pointSize: 24
+ anchors.horizontalCenter: parent.horizontalCenter;
+ //horizontalAlignment: Text.AlignHCenter
+ text: "Last Score:\t" + lastScore + "\nHighscore:\t" + highScores.topScore;
+ }
+ }
+ }
+
+ source: "content/pics/background.png"
+ fillMode: Image.PreserveAspectCrop
+
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: toolbar.top
+
+ Rectangle {
+ id: playfield
+ border.width: 1
+ border.color: "white"
+ color: "transparent"
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: (screen.height - 32 - height)/2;
+ width: numColumnsAvailable * gridSize + 2*margin
+ height: numRowsAvailable * gridSize + 2*margin
+
+
+ Content.Skull {
+ id: skull
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ if (screen.state == "") {
+ Logic.startNewGame();
+ return;
+ }
+ if (direction == 0 || direction == 2)
+ Logic.scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3);
+ else
+ Logic.scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0);
+ }
+ }
+ }
+
+ }
+
+ Rectangle {
+ id: progressBar
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ color: "transparent"
+ border.width: 2
+ border.color: "#221edd"
+ x: 50
+ y: 50
+ width: 200
+ height: 30
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: 40
+
+ Rectangle {
+ id: progressIndicator
+ color: "#221edd";
+ width: 0;
+ height: 30;
+ }
+ }
+
+ Rectangle {
+ id: toolbar
+ color: activePalette.window
+ height: 32; width: parent.width
+ anchors.bottom: screen.bottom
+
+ Content.Button {
+ id: btnA; text: "New Game"; onClicked: Logic.startNewGame();
+ anchors.left: parent.left; anchors.leftMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Content.Button {
+ text: "Quit"
+ anchors { left: btnA.right; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ onClicked: Qt.quit();
+ }
+
+ Text {
+ color: activePalette.text
+ text: "Score: " + score; font.bold: true
+ anchors.right: parent.right; anchors.rightMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+
+ focus: true
+ Keys.onSpacePressed: Logic.startNewGame();
+ Keys.onLeftPressed: if (state == "starting" || direction != 1) Logic.scheduleDirection(3);
+ Keys.onRightPressed: if (state == "starting" || direction != 3) Logic.scheduleDirection(1);
+ Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0);
+ Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2);
+
+ states: [
+ State {
+ name: "starting"
+ PropertyChanges {target: progressIndicator; width: 200}
+ PropertyChanges {target: title; opacity: 0}
+ PropertyChanges {target: progressBar; opacity: 1}
+ },
+ State {
+ name: "running"
+ PropertyChanges {target: progressIndicator; width: 200}
+ PropertyChanges {target: title; opacity: 0}
+ PropertyChanges {target: skull; row: 0; column: 0; }
+ PropertyChanges {target: skull; spawned: 1}
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "*"
+ to: "starting"
+ NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 }
+ NumberAnimation { property: "opacity"; duration: 200 }
+ },
+ Transition {
+ to: "starting"
+ NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 }
+ NumberAnimation { property: "opacity"; duration: 200 }
+ }
+ ]
+
+}
diff --git a/examples/declarative/snake/snake.qmlproject b/examples/declarative/snake/snake.qmlproject
new file mode 100644
index 0000000000..d4909f8685
--- /dev/null
+++ b/examples/declarative/snake/snake.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/declarative/twitter/TwitterCore/Button.qml b/examples/declarative/twitter/TwitterCore/Button.qml
new file mode 100644
index 0000000000..34ca181527
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/Button.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Item {
+ id: container
+
+ signal clicked
+
+ property string text
+ property bool keyUsing: false
+
+ BorderImage {
+ id: buttonImage
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ BorderImage {
+ id: pressed
+ opacity: 0
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ MouseArea {
+ id: mouseRegion
+ anchors.fill: buttonImage
+ onClicked: { container.clicked(); }
+ }
+ Text {
+ id: btnText
+ color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";}
+ anchors.centerIn: buttonImage; font.bold: true
+ text: container.text; style: Text.Raised; styleColor: "black"
+ font.pixelSize: 12
+ }
+ states: [
+ State {
+ name: "Pressed"
+ when: mouseRegion.pressed == true
+ PropertyChanges { target: pressed; opacity: 1 }
+ },
+ State {
+ name: "Focused"
+ when: container.activeFocus == true
+ PropertyChanges { target: btnText; color: "#FFFFFF" }
+ }
+ ]
+ transitions: Transition {
+ ColorAnimation { target: btnText; }
+ }
+}
diff --git a/examples/declarative/twitter/TwitterCore/FatDelegate.qml b/examples/declarative/twitter/TwitterCore/FatDelegate.qml
new file mode 100644
index 0000000000..1fe289159c
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/FatDelegate.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Component {
+ id: listDelegate
+ Item {
+ id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 60){txt.height+10}else{60} //50+5+5
+ function handleLink(link){
+ if(link.slice(0,3) == 'app'){
+ screen.setUser(link.slice(7));
+ }else if(link.slice(0,4) == 'http'){
+ Qt.openUrlExternally(link);
+ }
+ }
+ function addTags(str){
+ var ret = str.replace(/@[a-zA-Z0-9_]+/g, '<a href="app://$&">$&</a>');//click to jump to user?
+ var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '<a href="$&">$&</a>');//surrounds http links with html link tags
+ return ret2;
+ }
+
+ // Strip away paranthesis
+ function userName(str) {
+ var user = str.replace(/\([\S|\s]*\)/gi, "");
+ return user.trim();
+ }
+
+ Item {
+ id: moveMe; height: parent.height
+ Rectangle {
+ id: blackRect
+ color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1
+ }
+ Item {
+ id: image; x: 6; width: 48; height: 48; smooth: true
+ anchors.verticalCenter: parent.verticalCenter
+
+ Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready }
+ Image {
+ id: realImage;
+ source: userImage; x: 1; y: 1;
+ width:48; height:48; opacity:0 ;
+ onStatusChanged: {
+ if(status==Image.Ready)
+ image.state="loaded"
+ }
+ }
+ states: State {
+ name: "loaded";
+ PropertyChanges { target: realImage ; opacity:1 }
+ }
+ transitions: Transition { NumberAnimation { target: realImage; property: "opacity"; duration: 200 } }
+
+ }
+ Text { id:txt; y:4; x: 56
+ text: '<html><style type="text/css">a:link {color:"#aaccaa"}; a:visited {color:"#336633"}</style>'
+ + '<a href="app://@'+userName(name)+'"><b>'+userName(name) + "</b></a> from " +source
+ + "<br /><b>" + statusText + "</b></html>";
+ textFormat: Qt.RichText
+ color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap
+ anchors.left: image.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6
+ onLinkActivated: wrapper.handleLink(link)
+ }
+ }
+ }
+}
diff --git a/examples/declarative/twitter/TwitterCore/Input.qml b/examples/declarative/twitter/TwitterCore/Input.qml
new file mode 100644
index 0000000000..96fafb6bd2
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/Input.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+FocusScope {
+ id:container
+ width: 220
+ height: 28
+ BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
+ signal accepted
+ property alias text: input.text
+ property alias item:input
+ TextInput{
+ id: input
+ width: parent.width - 12
+ anchors.centerIn: parent
+ maximumLength:21
+ font.pixelSize: 16;
+ font.bold: true
+ color: "#151515"; selectionColor: "mediumseagreen"
+ focus: true
+ onAccepted:{container.accepted()}
+ text: ""
+ selectByMouse: true
+ }
+}
diff --git a/examples/declarative/twitter/TwitterCore/Loading.qml b/examples/declarative/twitter/TwitterCore/Loading.qml
new file mode 100644
index 0000000000..e0c4fa03eb
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/Loading.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Image {
+ id: loading; source: "images/loading.png"
+ NumberAnimation on rotation {
+ from: 0; to: 360; running: loading.visible == true; loops: Animation.Infinite; duration: 900
+ }
+}
diff --git a/examples/declarative/twitter/TwitterCore/MultiTitleBar.qml b/examples/declarative/twitter/TwitterCore/MultiTitleBar.qml
new file mode 100644
index 0000000000..6933d485c0
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/MultiTitleBar.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Item {
+ TitleBar { id: titleBar; width: parent.width; height: 60;
+ y: -80
+ untaggedString: "Latest tweets from everyone"
+ taggedString: "Latest tweets from "
+ }
+ states: [
+ State {
+ name: "search"; when: screen.state!="search"
+ PropertyChanges { target: titleBar; y: 0 }
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } }
+ ]
+}
+
diff --git a/examples/declarative/twitter/TwitterCore/RssModel.qml b/examples/declarative/twitter/TwitterCore/RssModel.qml
new file mode 100644
index 0000000000..696ae9d24d
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/RssModel.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Item { id: wrapper
+ property variant model: xmlModel
+ property string from : ""
+ property string to : ""
+ property string phrase : ""
+
+ property string mode : "everyone"
+ property int status: xmlModel.status
+ function reload() { xmlModel.reload(); }
+ XmlListModel {
+ id: xmlModel
+
+ source: (from=="" && to=="" && phrase=="") ? "" :
+ 'http://search.twitter.com/search.atom?from='+from+"&to="+to+"&phrase="+phrase
+
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " +
+ "declare namespace twitter=\"http://api.twitter.com/\";";
+
+ query: "/feed/entry"
+
+ XmlRole { name: "statusText"; query: "content/string()" }
+ XmlRole { name: "timestamp"; query: "published/string()" }
+ XmlRole { name: "source"; query: "twitter:source/string()" }
+ XmlRole { name: "name"; query: "author/name/string()" }
+ XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" }
+
+ }
+ Binding {
+ property: "mode"
+ target: wrapper
+ value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}}
+ }
+}
diff --git a/examples/declarative/twitter/TwitterCore/SearchView.qml b/examples/declarative/twitter/TwitterCore/SearchView.qml
new file mode 100644
index 0000000000..6e099ae1c7
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/SearchView.qml
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+FocusScope {
+ id: wrapper
+ Column {
+ anchors.centerIn: parent
+ spacing: 20
+ Column{
+ spacing: 4
+ Text {
+ text: "Posted by:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: fromIn
+ KeyNavigation.backtab: searchbutton
+ KeyNavigation.tab:toIn
+ onAccepted:searchbutton.doSearch();
+ focus: true
+ }
+ Text {
+ text: "In reply to:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: toIn
+ KeyNavigation.backtab: fromIn
+ KeyNavigation.tab:phraseIn
+ onAccepted:searchbutton.doSearch();
+ }
+ Text {
+ text: "Search phrase:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: phraseIn
+ KeyNavigation.backtab: toIn
+ KeyNavigation.tab:searchbutton
+ onAccepted:searchbutton.doSearch();
+ text: "Qt Quick"
+ }
+ }
+ Button {
+ width: 100
+ height: 32
+ id: searchbutton
+ keyUsing: true;
+ opacity: 1
+ text: "Search"
+ KeyNavigation.tab: fromIn
+ Keys.onReturnPressed: searchbutton.doSearch();
+ Keys.onEnterPressed: searchbutton.doSearch();
+ Keys.onSelectPressed: searchbutton.doSearch();
+ Keys.onSpacePressed: searchbutton.doSearch();
+ onClicked: searchbutton.doSearch();
+
+ function doSearch() {
+ // Search ! allowed
+ if (wrapper.state=="invalidinput")
+ return;
+
+ rssModel.from=fromIn.text;
+ rssModel.to= toIn.text;
+ rssModel.phrase = phraseIn.text;
+ screen.focus = true;
+ screen.state = ""
+ }
+ }
+ }
+ states:
+ State {
+ name: "invalidinput"
+ when: fromIn.text=="" && toIn.text=="" && phraseIn.text==""
+ PropertyChanges { target: searchbutton ; opacity: 0.6 ; }
+ }
+ transitions:
+ Transition {
+ NumberAnimation { target: searchbutton; property: "opacity"; duration: 200 }
+ }
+}
diff --git a/examples/declarative/twitter/TwitterCore/TitleBar.qml b/examples/declarative/twitter/TwitterCore/TitleBar.qml
new file mode 100644
index 0000000000..1a2f5d5855
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/TitleBar.qml
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Item {
+ id: titleBar
+ property string untaggedString: "Uploads from everyone"
+ property string taggedString: "Recent uploads tagged "
+
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+
+ Item {
+ id: container
+ width: (parent.width * 2) - 55 ; height: parent.height
+
+ function accept() {
+ titleBar.state = ""
+ background.state = ""
+ rssModel.tags = editor.text
+ }
+
+ Item {
+ id:imageBox
+ x: 6; width: 0; height: 50; smooth: true
+ anchors.verticalCenter: parent.verticalCenter
+
+ UserModel { user: rssModel.from; id: userModel }
+ Component {
+ id: imgDelegate;
+ Item {
+ id:imageitem
+ visible:true
+ Loading { width:48; height:48; visible: realImage.status != Image.Ready }
+ Image { id: realImage; source: image; width:48; height:48; opacity:0; }
+ states:
+ State {
+ name: "loaded"
+ when: (realImage.status == Image.Ready)
+ PropertyChanges { target: realImage; opacity:1 }
+ }
+ transitions: Transition {
+ NumberAnimation { target: realImage; property: "opacity"; duration: 200 }
+ }
+ }
+ }
+ ListView { id:view; model: userModel.model; x:1; y:1; delegate: imgDelegate }
+ states:
+ State {
+ when: !userModel.user==""
+ PropertyChanges { target: imageBox; width: 50; }
+ }
+ transitions:
+ Transition {
+ NumberAnimation { target: imageBox; property: "width"; duration: 200 }
+ }
+ }
+
+ Image {
+ id: quitButton
+ x: 5
+ anchors.verticalCenter: parent.verticalCenter
+ source: "images/quit.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+
+ Text {
+ id: categoryText
+ anchors {
+ left: quitButton.right; right: parent.right; leftMargin: 10; rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ elide: Text.ElideLeft
+ text: (rssModel.from=="" ? untaggedString : taggedString + rssModel.from)
+ font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black"
+ font.pixelSize: 12
+ }
+ }
+
+ states: State {
+ name: "Tags"
+ PropertyChanges { target: container; x: -tagButton.x + 5 }
+ PropertyChanges { target: editor; focus: true }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad }
+ }
+}
diff --git a/examples/declarative/twitter/TwitterCore/ToolBar.qml b/examples/declarative/twitter/TwitterCore/ToolBar.qml
new file mode 100644
index 0000000000..b277517332
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/ToolBar.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+Item {
+ id: toolbar
+
+ property alias button1Label: button1.text
+ property alias button2Label: button2.text
+ signal button1Clicked
+ signal button2Clicked
+ focus:true
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+ Button {
+ id: button1
+ anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32
+ onClicked: toolbar.button1Clicked()
+ focus:true
+ }
+ Button {
+ id: button2
+ anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32
+ onClicked: toolbar.button2Clicked()
+ }
+}
diff --git a/examples/declarative/twitter/TwitterCore/UserModel.qml b/examples/declarative/twitter/TwitterCore/UserModel.qml
new file mode 100644
index 0000000000..b87a083eae
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/UserModel.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+
+//This "model" gets the user information about the searched user. Mainly for the icon.
+
+Item { id: wrapper
+ property variant model: xmlModel
+ property string user : ""
+ property int status: xmlModel.status
+ function reload() { xmlModel.reload(); }
+ XmlListModel {
+ id: xmlModel
+
+ source: user!= "" ? "http://twitter.com/users/show.xml?screen_name="+user : ""
+ query: "/user"
+
+ XmlRole { name: "name"; query: "name/string()" }
+ XmlRole { name: "screenName"; query: "screen_name/string()" }
+ XmlRole { name: "image"; query: "profile_image_url/string()" }
+ XmlRole { name: "location"; query: "location/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ XmlRole { name: "followers"; query: "followers_count/string()" }
+ //TODO: Could also get the user's color scheme, timezone and a few other things
+ }
+}
diff --git a/examples/declarative/twitter/TwitterCore/images/gloss.png b/examples/declarative/twitter/TwitterCore/images/gloss.png
new file mode 100644
index 0000000000..5d370cd93d
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/images/gloss.png
Binary files differ
diff --git a/examples/declarative/twitter/TwitterCore/images/lineedit.png b/examples/declarative/twitter/TwitterCore/images/lineedit.png
new file mode 100644
index 0000000000..2cc38dc35b
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/images/lineedit.png
Binary files differ
diff --git a/examples/declarative/twitter/TwitterCore/images/lineedit.sci b/examples/declarative/twitter/TwitterCore/images/lineedit.sci
new file mode 100644
index 0000000000..054bff78be
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/images/lineedit.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 10
+border.bottom: 10
+border.right: 10
+source: lineedit.png
diff --git a/examples/declarative/twitter/TwitterCore/images/loading.png b/examples/declarative/twitter/TwitterCore/images/loading.png
new file mode 100644
index 0000000000..47a1589c5d
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/images/loading.png
Binary files differ
diff --git a/examples/declarative/twitter/TwitterCore/images/quit.png b/examples/declarative/twitter/TwitterCore/images/quit.png
new file mode 100644
index 0000000000..5bda1b6e0d
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/images/quit.png
Binary files differ
diff --git a/examples/declarative/twitter/TwitterCore/images/stripes.png b/examples/declarative/twitter/TwitterCore/images/stripes.png
new file mode 100644
index 0000000000..9f36727ea4
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/images/stripes.png
Binary files differ
diff --git a/examples/declarative/twitter/TwitterCore/images/titlebar.png b/examples/declarative/twitter/TwitterCore/images/titlebar.png
new file mode 100644
index 0000000000..51c90082d0
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/images/titlebar.png
Binary files differ
diff --git a/examples/declarative/twitter/TwitterCore/images/titlebar.sci b/examples/declarative/twitter/TwitterCore/images/titlebar.sci
new file mode 100644
index 0000000000..0418d94cd6
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/images/titlebar.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 12
+border.bottom: 12
+border.right: 10
+source: titlebar.png
diff --git a/examples/declarative/twitter/TwitterCore/images/toolbutton.png b/examples/declarative/twitter/TwitterCore/images/toolbutton.png
new file mode 100644
index 0000000000..11310013ee
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/images/toolbutton.png
Binary files differ
diff --git a/examples/declarative/twitter/TwitterCore/images/toolbutton.sci b/examples/declarative/twitter/TwitterCore/images/toolbutton.sci
new file mode 100644
index 0000000000..9e4f965307
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/images/toolbutton.sci
@@ -0,0 +1,5 @@
+border.left: 15
+border.top: 4
+border.bottom: 4
+border.right: 15
+source: toolbutton.png
diff --git a/examples/declarative/twitter/TwitterCore/qmldir b/examples/declarative/twitter/TwitterCore/qmldir
new file mode 100644
index 0000000000..84d85c2885
--- /dev/null
+++ b/examples/declarative/twitter/TwitterCore/qmldir
@@ -0,0 +1,10 @@
+SearchView 1.0 SearchView.qml
+Button 1.0 Button.qml
+Input 1.0 Input.qml
+FatDelegate 1.0 FatDelegate.qml
+Loading 1.0 Loading.qml
+MultiTitleBar 1.0 MultiTitleBar.qml
+TitleBar 1.0 TitleBar.qml
+RssModel 1.0 RssModel.qml
+UserModel 1.0 UserModel.qml
+ToolBar 1.0 ToolBar.qml
diff --git a/examples/declarative/twitter/twitter.qml b/examples/declarative/twitter/twitter.qml
new file mode 100644
index 0000000000..1700b5dcd1
--- /dev/null
+++ b/examples/declarative/twitter/twitter.qml
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative 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 1.0
+import "TwitterCore" 1.0 as Twitter
+
+Item {
+ id: screen; width: 320; height: 480
+ property bool userView : false
+ property variant tmpStr
+ function setUser(str){hack.running = true; tmpStr = str}
+ function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""}
+ state:"searchquery"
+ //Workaround for bug 260266
+ Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack }
+ Keys.onEscapePressed: screen.state="searchquery"
+ Keys.onBacktabPressed: screen.state="searchquery"
+ Rectangle {
+ id: background
+ anchors.fill: parent; color: "#343434";
+
+ state:"searchquery"
+ Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: screen.focus = false;
+ }
+
+ Twitter.RssModel { id: rssModel }
+ Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'}
+ Text {
+ width: 180
+ text: "Could not access twitter using this screen name and password pair.";
+ color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap
+ visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent
+ }
+
+ Item {
+ id: views
+ x: 2; width: parent.width - 4
+ y:60 //Below the title bars
+ height: parent.height - 100
+
+ Text {
+ id:title
+ text: "Search Twitter"
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black"
+ opacity:0
+ }
+
+ Twitter.SearchView{
+ id: searchView
+ anchors.verticalCenter: parent.verticalCenter
+ width: parent.width; height: parent.height-60;
+ x: -(screen.width * 1.5)
+ }
+
+ Twitter.FatDelegate { id: fatDelegate }
+ ListView {
+ id: mainView; model: rssModel.model; delegate: fatDelegate;
+ width: parent.width; height: parent.height; x: 0; cacheBuffer: 100;
+ }
+ }
+
+ Twitter.MultiTitleBar { id: titleBar; width: parent.width }
+ Twitter.ToolBar { id: toolBar; height: 40;
+ //anchors.bottom: parent.bottom;
+ //TODO: Use anchor changes instead of hard coding
+ y: screen.height - 40
+ width: parent.width; opacity: 0.9
+ button1Label: "New Search"
+ button2Label: "Update"
+ onButton1Clicked:
+ {
+ screen.state="searchquery"
+ }
+ onButton2Clicked: rssModel.reload();
+ }
+ }
+ states: [
+ State {
+ name: "searchquery";
+ PropertyChanges { target: searchView; x: 0; focus:true}
+ PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
+ PropertyChanges { target: titleBar; y: -80 }
+ PropertyChanges { target: toolBar; y: screen.height }
+ PropertyChanges { target: toolBar }
+ PropertyChanges { target: title; opacity:1}
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } }
+ ]
+}
diff --git a/examples/declarative/twitter/twitter.qmlproject b/examples/declarative/twitter/twitter.qmlproject
new file mode 100644
index 0000000000..d4909f8685
--- /dev/null
+++ b/examples/declarative/twitter/twitter.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}