From 9b5bb1b8b1acd1deb2ce653ab1a4095a0e503306 Mon Sep 17 00:00:00 2001 From: artoka Date: Thu, 17 Nov 2011 15:50:14 +0100 Subject: demos/declarative/minehunt example modifications Modified the example to use centralized qmlapplicationviewer, removed duplicate files and modified project files according to the changes. Merge-request: 2719 Reviewed-by: Casper van Donderen --- .../minehunt/MinehuntCore/Explosion.qml | 66 ----------- demos/declarative/minehunt/MinehuntCore/Tile.qml | 128 --------------------- .../minehunt/MinehuntCore/pics/back.png | Bin 558 -> 0 bytes .../minehunt/MinehuntCore/pics/background.png | Bin 313930 -> 0 bytes .../minehunt/MinehuntCore/pics/bomb-color.png | Bin 284 -> 0 bytes .../minehunt/MinehuntCore/pics/bomb.png | Bin 535 -> 0 bytes .../minehunt/MinehuntCore/pics/face-sad.png | Bin 14844 -> 0 bytes .../minehunt/MinehuntCore/pics/face-smile-big.png | Bin 13810 -> 0 bytes .../minehunt/MinehuntCore/pics/face-smile.png | Bin 15408 -> 0 bytes .../minehunt/MinehuntCore/pics/flag-color.png | Bin 219 -> 0 bytes .../minehunt/MinehuntCore/pics/flag.png | Bin 196 -> 0 bytes .../minehunt/MinehuntCore/pics/front.png | Bin 580 -> 0 bytes .../minehunt/MinehuntCore/pics/quit.png | Bin 583 -> 0 bytes .../minehunt/MinehuntCore/pics/star.png | Bin 2677 -> 0 bytes demos/declarative/minehunt/MinehuntCore/qmldir | 2 - demos/declarative/minehunt/main.cpp | 29 ++--- demos/declarative/minehunt/minehunt.pro | 49 ++++++-- demos/declarative/minehunt/minehunt.qml | 112 ------------------ demos/declarative/minehunt/minehunt.qmlproject | 6 +- .../qml/minehunt/MinehuntCore/Explosion.qml | 65 +++++++++++ .../minehunt/qml/minehunt/MinehuntCore/Tile.qml | 128 +++++++++++++++++++++ .../qml/minehunt/MinehuntCore/pics/back.png | Bin 0 -> 558 bytes .../qml/minehunt/MinehuntCore/pics/background.png | Bin 0 -> 313930 bytes .../qml/minehunt/MinehuntCore/pics/bomb-color.png | Bin 0 -> 284 bytes .../qml/minehunt/MinehuntCore/pics/bomb.png | Bin 0 -> 535 bytes .../qml/minehunt/MinehuntCore/pics/face-sad.png | Bin 0 -> 14844 bytes .../minehunt/MinehuntCore/pics/face-smile-big.png | Bin 0 -> 13810 bytes .../qml/minehunt/MinehuntCore/pics/face-smile.png | Bin 0 -> 15408 bytes .../qml/minehunt/MinehuntCore/pics/flag-color.png | Bin 0 -> 219 bytes .../qml/minehunt/MinehuntCore/pics/flag.png | Bin 0 -> 196 bytes .../qml/minehunt/MinehuntCore/pics/front.png | Bin 0 -> 580 bytes .../qml/minehunt/MinehuntCore/pics/quit.png | Bin 0 -> 583 bytes .../qml/minehunt/MinehuntCore/pics/star.png | Bin 0 -> 2677 bytes .../declarative/minehunt/qml/minehunt/minehunt.qml | 112 ++++++++++++++++++ 34 files changed, 355 insertions(+), 342 deletions(-) delete mode 100644 demos/declarative/minehunt/MinehuntCore/Explosion.qml delete mode 100644 demos/declarative/minehunt/MinehuntCore/Tile.qml delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/back.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/background.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/bomb-color.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/bomb.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/face-sad.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/face-smile-big.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/face-smile.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/flag-color.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/flag.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/front.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/quit.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/star.png delete mode 100644 demos/declarative/minehunt/MinehuntCore/qmldir delete mode 100644 demos/declarative/minehunt/minehunt.qml create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/Explosion.qml create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/Tile.qml create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/back.png create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/background.png create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/bomb-color.png create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/bomb.png create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-sad.png create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-smile-big.png create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-smile.png create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/flag-color.png create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/flag.png create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/front.png create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/quit.png create mode 100644 demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/star.png create mode 100644 demos/declarative/minehunt/qml/minehunt/minehunt.qml diff --git a/demos/declarative/minehunt/MinehuntCore/Explosion.qml b/demos/declarative/minehunt/MinehuntCore/Explosion.qml deleted file mode 100644 index a5f3f1b..0000000 --- a/demos/declarative/minehunt/MinehuntCore/Explosion.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** 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/demos/declarative/minehunt/MinehuntCore/Tile.qml b/demos/declarative/minehunt/MinehuntCore/Tile.qml deleted file mode 100644 index 90247f8..0000000 --- a/demos/declarative/minehunt/MinehuntCore/Tile.qml +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** 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/demos/declarative/minehunt/MinehuntCore/pics/back.png b/demos/declarative/minehunt/MinehuntCore/pics/back.png deleted file mode 100644 index f6b3f0b..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/back.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/background.png b/demos/declarative/minehunt/MinehuntCore/pics/background.png deleted file mode 100644 index 3734a27..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/background.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/bomb-color.png b/demos/declarative/minehunt/MinehuntCore/pics/bomb-color.png deleted file mode 100644 index 61ad0a9..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/bomb-color.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/bomb.png b/demos/declarative/minehunt/MinehuntCore/pics/bomb.png deleted file mode 100644 index a992575..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/bomb.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/face-sad.png b/demos/declarative/minehunt/MinehuntCore/pics/face-sad.png deleted file mode 100644 index cf00aaf..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/face-sad.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/face-smile-big.png b/demos/declarative/minehunt/MinehuntCore/pics/face-smile-big.png deleted file mode 100644 index f9c2335..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/face-smile-big.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/face-smile.png b/demos/declarative/minehunt/MinehuntCore/pics/face-smile.png deleted file mode 100644 index 3d66d72..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/face-smile.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/flag-color.png b/demos/declarative/minehunt/MinehuntCore/pics/flag-color.png deleted file mode 100644 index aadad0f..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/flag-color.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/flag.png b/demos/declarative/minehunt/MinehuntCore/pics/flag.png deleted file mode 100644 index 39cde4d..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/flag.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/front.png b/demos/declarative/minehunt/MinehuntCore/pics/front.png deleted file mode 100644 index 834331b..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/front.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/quit.png b/demos/declarative/minehunt/MinehuntCore/pics/quit.png deleted file mode 100644 index b822057..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/quit.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/star.png b/demos/declarative/minehunt/MinehuntCore/pics/star.png deleted file mode 100644 index 3772359..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/star.png and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/qmldir b/demos/declarative/minehunt/MinehuntCore/qmldir deleted file mode 100644 index 81980e0..0000000 --- a/demos/declarative/minehunt/MinehuntCore/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Explosion 1.0 Explosion.qml -Tile 1.0 Tile.qml diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp index 9e7ab5f..909de51 100644 --- a/demos/declarative/minehunt/main.cpp +++ b/demos/declarative/minehunt/main.cpp @@ -39,33 +39,24 @@ ** ****************************************************************************/ +#include "qmlapplicationviewer.h" +#include "minehunt.h" #include -#include #include #include -#include "minehunt.h" - int main(int argc, char *argv[]) { QApplication app(argc, argv); - QDeclarativeView canvas; - + QmlApplicationViewer viewer; + qmlRegisterType(); 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 + + viewer.engine()->rootContext()->setContextObject(game); + viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape); + viewer.setMainQmlFile(QLatin1String("qml/minehunt/minehunt.qml")); + viewer.showExpanded(); + return app.exec(); } diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro index d23bb05..4eed9c1 100644 --- a/demos/declarative/minehunt/minehunt.pro +++ b/demos/declarative/minehunt/minehunt.pro @@ -1,17 +1,20 @@ -TEMPLATE = app -TARGET = minehunt -QT += declarative +#TEMPLATE = app +# Add more folders to ship with the application, here +folder_01.source = qml/minehunt +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 -# Input -HEADERS += minehunt.h -SOURCES += main.cpp minehunt.cpp -RESOURCES = minehunt.qrc +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = -sources.files = minehunt.qml minehunt.pro MinehuntCore -sources.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt -target.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt +symbian:TARGET.UID3 = 0xE1CB8EBB -INSTALLS = sources target +# Smart Installer package's UID +# This UID is from the protected range and therefore the package will +# fail to install if self-signed. By default qmake uses the unprotected +# range value if unprotected UID is defined for the application and +# 0x2002CCCF value if protected UID is given to the application +#symbian:DEPLOYMENT.installer_header = 0x2002CCCF symbian:{ TARGET.EPOCALLOWDLLDATA = 1 @@ -20,4 +23,26 @@ symbian:{ qmlminehuntfiles.files = MinehuntCore minehunt.qml DEPLOYMENT += qmlminehuntfiles } - + +# Allow network access on Symbian +symbian:TARGET.CAPABILITY += NetworkServices + +# If your application uses the Qt Mobility libraries, uncomment the following +# lines and add the respective components to the MOBILITY variable. +# CONFIG += mobility +# MOBILITY += + +# Speed up launching on MeeGo/Harmattan when using applauncherd daemon +# CONFIG += qdeclarative-boostable + +# Add dependency to Symbian components +# CONFIG += qt-components + +# Input +HEADERS += minehunt.h +SOURCES += main.cpp minehunt.cpp +RESOURCES = minehunt.qrc + +# Please do not modify the following two lines. Required for deployment. +include(../../../examples/tools/qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml deleted file mode 100644 index 2129350..0000000 --- a/demos/declarative/minehunt/minehunt.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** 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/demos/declarative/minehunt/minehunt.qmlproject b/demos/declarative/minehunt/minehunt.qmlproject index d4909f8..1f8b659 100644 --- a/demos/declarative/minehunt/minehunt.qmlproject +++ b/demos/declarative/minehunt/minehunt.qmlproject @@ -3,13 +3,13 @@ import QmlProject 1.0 Project { /* Include .qml, .js, and image files from current directory and subdirectories */ QmlFiles { - directory: "." + directory: "qml/minehunt" } JavaScriptFiles { - directory: "." + directory: "qml/minehunt" } ImageFiles { - directory: "." + directory: "qml/minehunt" } /* List of plugin directories passed to QML runtime */ // importPaths: [ " ../exampleplugin " ] diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/Explosion.qml b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/Explosion.qml new file mode 100644 index 0000000..538d06b --- /dev/null +++ b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/Explosion.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 +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/demos/declarative/minehunt/qml/minehunt/MinehuntCore/Tile.qml b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/Tile.qml new file mode 100644 index 0000000..90247f8 --- /dev/null +++ b/demos/declarative/minehunt/qml/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/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/back.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/back.png new file mode 100644 index 0000000..f6b3f0b Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/back.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/background.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/background.png new file mode 100644 index 0000000..3734a27 Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/background.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/bomb-color.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/bomb-color.png new file mode 100644 index 0000000..61ad0a9 Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/bomb-color.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/bomb.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/bomb.png new file mode 100644 index 0000000..a992575 Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/bomb.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-sad.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-sad.png new file mode 100644 index 0000000..cf00aaf Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-sad.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-smile-big.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-smile-big.png new file mode 100644 index 0000000..f9c2335 Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-smile-big.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-smile.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-smile.png new file mode 100644 index 0000000..3d66d72 Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/face-smile.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/flag-color.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/flag-color.png new file mode 100644 index 0000000..aadad0f Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/flag-color.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/flag.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/flag.png new file mode 100644 index 0000000..39cde4d Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/flag.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/front.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/front.png new file mode 100644 index 0000000..834331b Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/front.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/quit.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/quit.png new file mode 100644 index 0000000..b822057 Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/quit.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/star.png b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/star.png new file mode 100644 index 0000000..3772359 Binary files /dev/null and b/demos/declarative/minehunt/qml/minehunt/MinehuntCore/pics/star.png differ diff --git a/demos/declarative/minehunt/qml/minehunt/minehunt.qml b/demos/declarative/minehunt/qml/minehunt/minehunt.qml new file mode 100644 index 0000000..c64f21d --- /dev/null +++ b/demos/declarative/minehunt/qml/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" + +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 + } + +} -- cgit v0.12