diff options
Diffstat (limited to 'demos')
224 files changed, 8674 insertions, 186 deletions
diff --git a/demos/browser/browsermainwindow.cpp b/demos/browser/browsermainwindow.cpp index ed36c25..8c2ed89 100644 --- a/demos/browser/browsermainwindow.cpp +++ b/demos/browser/browsermainwindow.cpp @@ -433,10 +433,8 @@ void BrowserMainWindow::setupMenu() QMenu *toolsMenu = menuBar()->addMenu(tr("&Tools")); toolsMenu->addAction(tr("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence(tr("Ctrl+K", "Web Search"))); -#ifndef Q_CC_MINGW a = toolsMenu->addAction(tr("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); a->setCheckable(true); -#endif QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); diff --git a/demos/declarative/calculator/Core/Button.qml b/demos/declarative/calculator/Core/Button.qml new file mode 100644 index 0000000..7b19feb --- /dev/null +++ b/demos/declarative/calculator/Core/Button.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/calculator/Core/Display.qml b/demos/declarative/calculator/Core/Display.qml new file mode 100644 index 0000000..53f74c9 --- /dev/null +++ b/demos/declarative/calculator/Core/Display.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/calculator/Core/calculator.js b/demos/declarative/calculator/Core/calculator.js new file mode 100644 index 0000000..51b3dd3 --- /dev/null +++ b/demos/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) + } else if (op == "C") { + display.text = "0" + } else if (op == "AC") { + curVal = 0 + memory = 0 + lastOp = "" + display.text ="0" + } + + if (op == rotateLeft) + main.state = 'rotated' + if (op == rotateRight) + main.state = '' +} + diff --git a/demos/declarative/calculator/Core/images/button-.png b/demos/declarative/calculator/Core/images/button-.png Binary files differnew file mode 100644 index 0000000..544e514 --- /dev/null +++ b/demos/declarative/calculator/Core/images/button-.png diff --git a/demos/declarative/calculator/Core/images/button-blue.png b/demos/declarative/calculator/Core/images/button-blue.png Binary files differnew file mode 100644 index 0000000..5f92de3 --- /dev/null +++ b/demos/declarative/calculator/Core/images/button-blue.png diff --git a/demos/declarative/calculator/Core/images/button-green.png b/demos/declarative/calculator/Core/images/button-green.png Binary files differnew file mode 100644 index 0000000..36c9391 --- /dev/null +++ b/demos/declarative/calculator/Core/images/button-green.png diff --git a/demos/declarative/calculator/Core/images/button-purple.png b/demos/declarative/calculator/Core/images/button-purple.png Binary files differnew file mode 100644 index 0000000..347cbbe --- /dev/null +++ b/demos/declarative/calculator/Core/images/button-purple.png diff --git a/demos/declarative/calculator/Core/images/button-red.png b/demos/declarative/calculator/Core/images/button-red.png Binary files differnew file mode 100644 index 0000000..3b33589 --- /dev/null +++ b/demos/declarative/calculator/Core/images/button-red.png diff --git a/demos/declarative/calculator/Core/images/display.png b/demos/declarative/calculator/Core/images/display.png Binary files differnew file mode 100644 index 0000000..9507f43 --- /dev/null +++ b/demos/declarative/calculator/Core/images/display.png diff --git a/demos/declarative/calculator/Core/qmldir b/demos/declarative/calculator/Core/qmldir new file mode 100644 index 0000000..a926b93 --- /dev/null +++ b/demos/declarative/calculator/Core/qmldir @@ -0,0 +1,2 @@ +Button Button.qml +Display Display.qml diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml new file mode 100644 index 0000000..3d36211 --- /dev/null +++ b/demos/declarative/calculator/calculator.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +import "Core" +import "Core/calculator.js" as CalcEngine + +Rectangle { + id: window + + width: 480; height: 360 + 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: (runtime.orientation == Orientation.Portrait) ? '' : 'rotated' + width: parent.width; height: parent.height; anchors.centerIn: parent + + Column { + id: box; spacing: 8 + + anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 } + + Row { + Display { id: display; width: box.width; 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 { + id: rotateButton + width: column.w; height: column.h; color: 'purple'; operation: rotateLeft + } + 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: 4; 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: 'rotated' + PropertyChanges { target: main; rotation: -90; width: window.height; height: window.width } + PropertyChanges { target: rotateButton; operation: rotateRight } + } + + transitions: Transition { + SequentialAnimation { + PropertyAction { target: rotateButton; property: "operation" } + NumberAnimation { properties: "rotation"; duration: 300; easing.type: Easing.InOutQuint } + NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } + } + } + } +} diff --git a/demos/declarative/calculator/calculator.qmlproject b/demos/declarative/calculator/calculator.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/demos/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/demos/declarative/declarative.pro b/demos/declarative/declarative.pro new file mode 100644 index 0000000..2963386 --- /dev/null +++ b/demos/declarative/declarative.pro @@ -0,0 +1,20 @@ +TEMPLATE = subdirs + +# These demos contain C++ and need to be compiled +SUBDIRS = \ + minehunt + +# These examples contain no C++ and can simply be copied +sources.files = \ + calculator \ + flickr \ + photoviewer \ + samegame \ + snake \ + twitter \ + rssnews \ + webbrowser + +sources.path = $$[QT_INSTALL_DEMOS]/declarative +INSTALLS += sources + diff --git a/demos/declarative/demos.qmlproject b/demos/declarative/demos.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/demos/declarative/demos.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/demos/declarative/flickr/common/Progress.qml b/demos/declarative/flickr/common/Progress.qml new file mode 100644 index 0000000..99e1a7b --- /dev/null +++ b/demos/declarative/flickr/common/Progress.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + 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" } + } + } + + Rectangle { + y: 2; height: parent.height-4; + x: 2; width: Math.max(parent.width * progress - 4, 0); + opacity: width < 1 ? 0 : 1; smooth: true + gradient: Gradient { + GradientStop { position: 0; color: "lightsteelblue" } + GradientStop { position: 1.0; color: "steelblue" } + } + radius: height/2 - 2 + } + + Text { + text: Math.round(progress * 100) + "%" + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + color: "white"; font.bold: true + } +} diff --git a/demos/declarative/flickr/common/RssModel.qml b/demos/declarative/flickr/common/RssModel.qml new file mode 100644 index 0000000..b4ea3ce --- /dev/null +++ b/demos/declarative/flickr/common/RssModel.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/flickr/common/ScrollBar.qml b/demos/declarative/flickr/common/ScrollBar.qml new file mode 100644 index 0000000..1574915 --- /dev/null +++ b/demos/declarative/flickr/common/ScrollBar.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/flickr/common/Slider.qml b/demos/declarative/flickr/common/Slider.qml new file mode 100644 index 0000000..4353f8d --- /dev/null +++ b/demos/declarative/flickr/common/Slider.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + id: slider; width: 400; height: 16 + + // value is read/write. + property real value + onValueChanged: { handle.x = 2 + (value - minimum) * slider.xMax / (maximum - minimum); } + property real maximum: 1 + property real minimum: 1 + property int xMax: slider.width - handle.width - 4 + + 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 + x: slider.width / 2 - handle.width / 2; 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 { + 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/demos/declarative/flickr/common/qmldir b/demos/declarative/flickr/common/qmldir new file mode 100644 index 0000000..adc2479 --- /dev/null +++ b/demos/declarative/flickr/common/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/demos/declarative/flickr/flickr-90.qml b/demos/declarative/flickr/flickr-90.qml new file mode 100644 index 0000000..3db44de --- /dev/null +++ b/demos/declarative/flickr/flickr-90.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + width: 480; height: 320 + + Loader { + y: 320; rotation: -90 + transformOrigin: Item.TopLeft + source: "flickr.qml" + } +} diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml new file mode 100644 index 0000000..48db476 --- /dev/null +++ b/demos/declarative/flickr/flickr.qml @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +import "common" as Common +import "mobile" as Mobile + +Item { + id: screen; width: 320; height: 480 + property bool inListView : false + + Rectangle { + id: background + anchors.fill: parent; color: "#343434"; + + Image { source: "mobile/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } + + Common.RssModel { id: rssModel } + + Item { + id: views + x: 2; width: parent.width - 4 + anchors.top: titleBar.bottom; anchors.bottom: toolBar.top + + Mobile.GridDelegate { id: gridDelegate } + GridView { + x: (width/4-79)/2; y: x + id: photoGridView; model: rssModel; delegate: gridDelegate; cacheBuffer: 100 + cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height - 1; z: 6 + } + + Mobile.ListDelegate { id: listDelegate } + ListView { + id: photoListView; model: rssModel; delegate: listDelegate; z: 6 + width: parent.width; height: parent.height; x: -(parent.width * 1.5); cacheBuffer: 100; + } + states: State { + name: "ListView"; when: screen.inListView == true + PropertyChanges { target: photoListView; x: 0 } + PropertyChanges { target: photoGridView; x: -(parent.width * 1.5) } + } + + transitions: Transition { + NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } + } + } + + Mobile.ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height; z:1 } + Mobile.TitleBar { id: titleBar; z: 5; width: parent.width; height: 40; opacity: 0.9 } + + Mobile.ToolBar { + id: toolBar; z: 5 + height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9 + button1Label: "Update"; button2Label: "View mode" + onButton1Clicked: rssModel.reload() + onButton2Clicked: if (screen.inListView == true) screen.inListView = false; else screen.inListView = 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: "More..." } + 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/demos/declarative/flickr/flickr.qmlproject b/demos/declarative/flickr/flickr.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/demos/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/demos/declarative/flickr/mobile/Button.qml b/demos/declarative/flickr/mobile/Button.qml new file mode 100644 index 0000000..93a6661 --- /dev/null +++ b/demos/declarative/flickr/mobile/Button.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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 + text: container.text; style: Text.Raised; styleColor: "black" + } + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed == true + PropertyChanges { target: pressed; opacity: 1 } + } + ] +} diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml new file mode 100644 index 0000000..cbb00a2 --- /dev/null +++ b/demos/declarative/flickr/mobile/GridDelegate.qml @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + + Component { + id: photoDelegate + Item { + id: wrapper; width: 79; height: 79 + + 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 + + Rectangle { height: 79; width: 79; id: blackRect; anchors.centerIn: parent; color: "black"; smooth: true } + Rectangle { + id: whiteRect; width: 77; height: 77; anchors.centerIn: parent; 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: wrapper; parent: imageDetails.frontContainer } + PropertyChanges { target: wrapper; x: 20; y: 60; z: 1000 } + PropertyChanges { target: background; state: "DetailedView" } + } + ] + transitions: [ + Transition { + from: "Show"; to: "Details" + ParentAnimation { + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + }, + Transition { + from: "Details"; to: "Show" + SequentialAnimation { + ParentAnimation { + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + PropertyAction { targets: wrapper; properties: "z" } + } + } + ] + } + MouseArea { anchors.fill: wrapper; onClicked: { photoClicked() } } + } + } diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml new file mode 100644 index 0000000..b1a7359 --- /dev/null +++ b/demos/declarative/flickr/mobile/ImageDetails.qml @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +import "../common" as Common + +Flipable { + id: container + + property variant 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 + + 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: 20 + right: parent.right; rightMargin: 20 + top: parent.top; topMargin: 180 + } + Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle } + Text { color: "white"; elide: Text.ElideRight; text: "<b>Size:</b> " + container.photoWidth + 'x' + container.photoHeight } + Text { color: "white"; elide: Text.ElideRight; text: "<b>Type:</b> " + container.photoType } + Text { color: "white"; elide: Text.ElideRight; text: "<b>Author:</b> " + container.photoAuthor } + Text { color: "white"; elide: Text.ElideRight; text: "<b>Published:</b> " + container.photoDate } + Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "<b>Tags:</b> " } + Text { color: "white"; elide: Text.ElideRight; text: container.photoTags } + } + } + + back: Item { + anchors.fill: container + + Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 } + + Common.Progress { + anchors.centerIn: parent; width: 200; height: 18 + progress: bigImage.progress; visible: bigImage.status != Image.Ready + } + + Flickable { + id: flickable; anchors.fill: parent; clip: true + contentWidth: imageContainer.width; contentHeight: imageContainer.height + + 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 (status == Image.Ready && width != 0) { + slider.minimum = Math.min(flickable.width / width, flickable.height / height); + prevScale = Math.min(slider.minimum, 1); + slider.value = prevScale; + } + } + } + } + } + + Text { + text: "Image Unavailable" + visible: bigImage.status == Image.Error + anchors.centerIn: parent; color: "white"; font.bold: true + } + + Common.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 } + } + + transitions: Transition { + SequentialAnimation { + PropertyAction { target: bigImage; property: "smooth"; value: false } + NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: 500 } + PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically } + } + } +} diff --git a/demos/declarative/flickr/mobile/ListDelegate.qml b/demos/declarative/flickr/mobile/ListDelegate.qml new file mode 100644 index 0000000..3dd2868 --- /dev/null +++ b/demos/declarative/flickr/mobile/ListDelegate.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" } + Text { text: photoAuthor; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" } + Text { text: photoDate; width: parent.width; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" } + } + } + } +} diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml new file mode 100644 index 0000000..da144d4 --- /dev/null +++ b/demos/declarative/flickr/mobile/TitleBar.qml @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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; 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.onEscapePressed: titleBar.state = "" + } + } + } + + states: State { + name: "Tags" + PropertyChanges { target: container; x: -tagButton.x + 5 } + PropertyChanges { target: tagButton; text: "OK" } + PropertyChanges { target: lineEdit; focus: true } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } + } +} diff --git a/demos/declarative/flickr/mobile/ToolBar.qml b/demos/declarative/flickr/mobile/ToolBar.qml new file mode 100644 index 0000000..b9cb915 --- /dev/null +++ b/demos/declarative/flickr/mobile/ToolBar.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + id: toolbar + + property alias button1Label: button1.text + property alias button2Label: button2.text + signal button1Clicked + signal button2Clicked + + 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() + } + + Button { + id: button2 + anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32 + onClicked: toolbar.button2Clicked() + } +} diff --git a/demos/declarative/flickr/mobile/images/gloss.png b/demos/declarative/flickr/mobile/images/gloss.png Binary files differnew file mode 100644 index 0000000..5d370cd --- /dev/null +++ b/demos/declarative/flickr/mobile/images/gloss.png diff --git a/demos/declarative/flickr/mobile/images/lineedit.png b/demos/declarative/flickr/mobile/images/lineedit.png Binary files differnew file mode 100644 index 0000000..2cc38dc --- /dev/null +++ b/demos/declarative/flickr/mobile/images/lineedit.png diff --git a/demos/declarative/flickr/mobile/images/lineedit.sci b/demos/declarative/flickr/mobile/images/lineedit.sci new file mode 100644 index 0000000..054bff7 --- /dev/null +++ b/demos/declarative/flickr/mobile/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/demos/declarative/flickr/mobile/images/quit.png b/demos/declarative/flickr/mobile/images/quit.png Binary files differnew file mode 100644 index 0000000..5bda1b6 --- /dev/null +++ b/demos/declarative/flickr/mobile/images/quit.png diff --git a/demos/declarative/flickr/mobile/images/stripes.png b/demos/declarative/flickr/mobile/images/stripes.png Binary files differnew file mode 100644 index 0000000..9f36727 --- /dev/null +++ b/demos/declarative/flickr/mobile/images/stripes.png diff --git a/demos/declarative/flickr/mobile/images/titlebar.png b/demos/declarative/flickr/mobile/images/titlebar.png Binary files differnew file mode 100644 index 0000000..51c9008 --- /dev/null +++ b/demos/declarative/flickr/mobile/images/titlebar.png diff --git a/demos/declarative/flickr/mobile/images/titlebar.sci b/demos/declarative/flickr/mobile/images/titlebar.sci new file mode 100644 index 0000000..0418d94 --- /dev/null +++ b/demos/declarative/flickr/mobile/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/demos/declarative/flickr/mobile/images/toolbutton.png b/demos/declarative/flickr/mobile/images/toolbutton.png Binary files differnew file mode 100644 index 0000000..1131001 --- /dev/null +++ b/demos/declarative/flickr/mobile/images/toolbutton.png diff --git a/demos/declarative/flickr/mobile/images/toolbutton.sci b/demos/declarative/flickr/mobile/images/toolbutton.sci new file mode 100644 index 0000000..9e4f965 --- /dev/null +++ b/demos/declarative/flickr/mobile/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/demos/declarative/minehunt/MinehuntCore/Explosion.qml b/demos/declarative/minehunt/MinehuntCore/Explosion.qml new file mode 100644 index 0000000..b2644ff --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/Explosion.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +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 new file mode 100644 index 0000000..64dd63c --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/Tile.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/No-Ones-Laughing-3.jpg b/demos/declarative/minehunt/MinehuntCore/pics/No-Ones-Laughing-3.jpg Binary files differnew file mode 100644 index 0000000..445567f --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/pics/No-Ones-Laughing-3.jpg diff --git a/demos/declarative/minehunt/MinehuntCore/pics/back.png b/demos/declarative/minehunt/MinehuntCore/pics/back.png Binary files differnew file mode 100644 index 0000000..f6b3f0b --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/pics/back.png diff --git a/demos/declarative/minehunt/MinehuntCore/pics/bomb-color.png b/demos/declarative/minehunt/MinehuntCore/pics/bomb-color.png Binary files differnew file mode 100644 index 0000000..61ad0a9 --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/pics/bomb-color.png diff --git a/demos/declarative/minehunt/MinehuntCore/pics/bomb.png b/demos/declarative/minehunt/MinehuntCore/pics/bomb.png Binary files differnew file mode 100644 index 0000000..a992575 --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/pics/bomb.png diff --git a/demos/declarative/minehunt/MinehuntCore/pics/face-sad.png b/demos/declarative/minehunt/MinehuntCore/pics/face-sad.png Binary files differnew file mode 100644 index 0000000..cf00aaf --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/pics/face-sad.png diff --git a/demos/declarative/minehunt/MinehuntCore/pics/face-smile-big.png b/demos/declarative/minehunt/MinehuntCore/pics/face-smile-big.png Binary files differnew file mode 100644 index 0000000..f9c2335 --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/pics/face-smile-big.png diff --git a/demos/declarative/minehunt/MinehuntCore/pics/face-smile.png b/demos/declarative/minehunt/MinehuntCore/pics/face-smile.png Binary files differnew file mode 100644 index 0000000..3d66d72 --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/pics/face-smile.png diff --git a/demos/declarative/minehunt/MinehuntCore/pics/flag-color.png b/demos/declarative/minehunt/MinehuntCore/pics/flag-color.png Binary files differnew file mode 100644 index 0000000..aadad0f --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/pics/flag-color.png diff --git a/demos/declarative/minehunt/MinehuntCore/pics/flag.png b/demos/declarative/minehunt/MinehuntCore/pics/flag.png Binary files differnew file mode 100644 index 0000000..39cde4d --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/pics/flag.png diff --git a/demos/declarative/minehunt/MinehuntCore/pics/front.png b/demos/declarative/minehunt/MinehuntCore/pics/front.png Binary files differnew file mode 100644 index 0000000..834331b --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/pics/front.png diff --git a/demos/declarative/minehunt/MinehuntCore/pics/star.png b/demos/declarative/minehunt/MinehuntCore/pics/star.png Binary files differnew file mode 100644 index 0000000..3772359 --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/pics/star.png diff --git a/demos/declarative/minehunt/MinehuntCore/qmldir b/demos/declarative/minehunt/MinehuntCore/qmldir new file mode 100644 index 0000000..2beccf9 --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/qmldir @@ -0,0 +1,3 @@ +plugin qmlminehuntplugin +Explosion 1.0 Explosion.qml +Tile 1.0 Tile.qml diff --git a/demos/declarative/minehunt/README b/demos/declarative/minehunt/README new file mode 100644 index 0000000..b9f1d2a --- /dev/null +++ b/demos/declarative/minehunt/README @@ -0,0 +1,3 @@ +To compile the C++ part, do 'qmake && make'. Minehunt will not run properly if the C++ plugin is not compiled. + +To run, simply load the minehunt.qml file with the qml runtime. diff --git a/demos/declarative/minehunt/minehunt.cpp b/demos/declarative/minehunt/minehunt.cpp new file mode 100644 index 0000000..2a4ed10 --- /dev/null +++ b/demos/declarative/minehunt/minehunt.cpp @@ -0,0 +1,334 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** 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$ +** +****************************************************************************/ + +#include <stdlib.h> +#include <qdeclarativeextensionplugin.h> +#include <qdeclarativecontext.h> +#include <qdeclarativeengine.h> +#include <qdeclarative.h> + +#include <QTime> +#include <QTimer> + +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; +}; + +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); + } + + remaining--; + if(!remaining){ + won = true; + hasWonChanged(); + setPlaying(false); + } + return true; +} + +bool MinehuntGame::flag(int row, int col) +{ + TileData *t = tile(row, col); + if(!t) + return false; + + t->setHasFlag(!t->hasFlag()); + nFlags += (t->hasFlag()?1:-1); + emit numFlagsChanged(); + return true; +} + +class MinehuntExtensionPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT + + public: + void registerTypes(const char *uri) { + Q_UNUSED(uri); + qmlRegisterType<TileData>(); + } + + void initializeEngine(QDeclarativeEngine *engine, const char *uri) { + Q_UNUSED(uri); + + srand(QTime(0,0,0).secsTo(QTime::currentTime())); + + MinehuntGame* game = new MinehuntGame(); + + engine->rootContext()->setContextObject(game); + } +}; + +#include "minehunt.moc" + +Q_EXPORT_PLUGIN(MinehuntExtensionPlugin); + diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro new file mode 100644 index 0000000..91d02cf --- /dev/null +++ b/demos/declarative/minehunt/minehunt.pro @@ -0,0 +1,39 @@ +TEMPLATE = lib +TARGET = qmlminehuntplugin +QT += declarative +CONFIG += qt plugin + +TARGET = $$qtLibraryTarget($$TARGET) +DESTDIR = MinehuntCore + +# Input +SOURCES += minehunt.cpp + +sources.files = minehunt.qml minehunt.pro +sources.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt + +target.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt/MinehuntCore + +MinehuntCore_sources.files = \ + MinehuntCore/Explosion.qml \ + MinehuntCore/Tile.qml \ + MinehuntCore/pics \ + MinehuntCore/qmldir +MinehuntCore_sources.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt/MinehuntCore + +INSTALLS = sources MinehuntCore_sources target + +symbian:{ + load(data_caging_paths) + TARGET.EPOCALLOWDLLDATA = 1 + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + TARGET.CAPABILITY = NetworkServices ReadUserData + importFiles.sources = qmlminehuntplugin.dll \ + MinehuntCore/Explosion.qml \ + MinehuntCore/pics \ + MinehuntCore/qmldir + importFiles.path = MinehuntCore + DEPLOYMENT = importFiles +} + +INSTALLS = sources MinehuntCore_sources target diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml new file mode 100644 index 0000000..136f56a --- /dev/null +++ b/demos/declarative/minehunt/minehunt.qml @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +import "MinehuntCore" 1.0 + +Item { + id: field + property int clickx: 0 + property int clicky: 0 + + width: 450; height: 450 + + Image { source: "MinehuntCore/pics/No-Ones-Laughing-3.jpg"; 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 + + 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 will not run properly if the C++ plugin is not compiled.\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 new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/demos/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/demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml new file mode 100644 index 0000000..0df8155 --- /dev/null +++ b/demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml b/demos/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml new file mode 100644 index 0000000..e55bf17 --- /dev/null +++ b/demos/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/photoviewer/PhotoViewerCore/Button.qml b/demos/declarative/photoviewer/PhotoViewerCore/Button.qml new file mode 100644 index 0000000..a60d5ca --- /dev/null +++ b/demos/declarative/photoviewer/PhotoViewerCore/Button.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + id: container + + property alias label: labelText.text + property string tint: "" + 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/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml new file mode 100644 index 0000000..e15adbc --- /dev/null +++ b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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.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.forceFocus() + } +} diff --git a/demos/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/demos/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml new file mode 100644 index 0000000..dadb409 --- /dev/null +++ b/demos/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +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: border.visible ? 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) + fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height + } + Image { + id: hqImage; smooth: true; source: ""; visible: 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/demos/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml b/demos/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml new file mode 100644 index 0000000..779d342 --- /dev/null +++ b/demos/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/photoviewer/PhotoViewerCore/RssModel.qml b/demos/declarative/photoviewer/PhotoViewerCore/RssModel.qml new file mode 100644 index 0000000..29bad52 --- /dev/null +++ b/demos/declarative/photoviewer/PhotoViewerCore/RssModel.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/photoviewer/PhotoViewerCore/Tag.qml b/demos/declarative/photoviewer/PhotoViewerCore/Tag.qml new file mode 100644 index 0000000..5e93046 --- /dev/null +++ b/demos/declarative/photoviewer/PhotoViewerCore/Tag.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png b/demos/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png Binary files differnew file mode 100644 index 0000000..431af85 --- /dev/null +++ b/demos/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png diff --git a/demos/declarative/photoviewer/PhotoViewerCore/images/busy.png b/demos/declarative/photoviewer/PhotoViewerCore/images/busy.png Binary files differnew file mode 100644 index 0000000..664c2b1 --- /dev/null +++ b/demos/declarative/photoviewer/PhotoViewerCore/images/busy.png diff --git a/demos/declarative/photoviewer/PhotoViewerCore/images/cardboard.png b/demos/declarative/photoviewer/PhotoViewerCore/images/cardboard.png Binary files differnew file mode 100644 index 0000000..1847ab5 --- /dev/null +++ b/demos/declarative/photoviewer/PhotoViewerCore/images/cardboard.png diff --git a/demos/declarative/photoviewer/PhotoViewerCore/qmldir b/demos/declarative/photoviewer/PhotoViewerCore/qmldir new file mode 100644 index 0000000..d3c247f --- /dev/null +++ b/demos/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/demos/declarative/photoviewer/PhotoViewerCore/script/script.js b/demos/declarative/photoviewer/PhotoViewerCore/script/script.js new file mode 100644 index 0000000..e8ef93a --- /dev/null +++ b/demos/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/demos/declarative/photoviewer/i18n/base.ts b/demos/declarative/photoviewer/i18n/base.ts new file mode 100644 index 0000000..1accfd2 --- /dev/null +++ b/demos/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/demos/declarative/photoviewer/i18n/qml_fr.qm b/demos/declarative/photoviewer/i18n/qml_fr.qm Binary files differnew file mode 100644 index 0000000..c24fcbc --- /dev/null +++ b/demos/declarative/photoviewer/i18n/qml_fr.qm diff --git a/demos/declarative/photoviewer/i18n/qml_fr.ts b/demos/declarative/photoviewer/i18n/qml_fr.ts new file mode 100644 index 0000000..9f892db --- /dev/null +++ b/demos/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/demos/declarative/photoviewer/photoviewer.qml b/demos/declarative/photoviewer/photoviewer.qml new file mode 100644 index 0000000..4ed3105 --- /dev/null +++ b/demos/declarative/photoviewer/photoviewer.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +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 + } + } + + 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/demos/declarative/photoviewer/photoviewer.qmlproject b/demos/declarative/photoviewer/photoviewer.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/demos/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/demos/declarative/rssnews/content/BusyIndicator.qml b/demos/declarative/rssnews/content/BusyIndicator.qml new file mode 100644 index 0000000..13f54f2 --- /dev/null +++ b/demos/declarative/rssnews/content/BusyIndicator.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/rssnews/content/CategoryDelegate.qml b/demos/declarative/rssnews/content/CategoryDelegate.qml new file mode 100644 index 0000000..edfb4bb --- /dev/null +++ b/demos/declarative/rssnews/content/CategoryDelegate.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/rssnews/content/NewsDelegate.qml b/demos/declarative/rssnews/content/NewsDelegate.qml new file mode 100644 index 0000000..040dadc --- /dev/null +++ b/demos/declarative/rssnews/content/NewsDelegate.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + id: delegate + height: childrenRect.height + 20 + width: delegate.ListView.view.width + + 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/demos/declarative/rssnews/content/RssFeeds.qml b/demos/declarative/rssnews/content/RssFeeds.qml new file mode 100644 index 0000000..62e7f14 --- /dev/null +++ b/demos/declarative/rssnews/content/RssFeeds.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/rssnews/content/ScrollBar.qml b/demos/declarative/rssnews/content/ScrollBar.qml new file mode 100644 index 0000000..e0214d2 --- /dev/null +++ b/demos/declarative/rssnews/content/ScrollBar.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/rssnews/content/images/busy.png b/demos/declarative/rssnews/content/images/busy.png Binary files differnew file mode 100644 index 0000000..664c2b1 --- /dev/null +++ b/demos/declarative/rssnews/content/images/busy.png diff --git a/demos/declarative/rssnews/content/images/scrollbar.png b/demos/declarative/rssnews/content/images/scrollbar.png Binary files differnew file mode 100644 index 0000000..0228dcf --- /dev/null +++ b/demos/declarative/rssnews/content/images/scrollbar.png diff --git a/demos/declarative/rssnews/rssnews.qml b/demos/declarative/rssnews/rssnews.qml new file mode 100644 index 0000000..def3e2c --- /dev/null +++ b/demos/declarative/rssnews/rssnews.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +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 + 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 {} + } + } + + 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/demos/declarative/rssnews/rssnews.qmlproject b/demos/declarative/rssnews/rssnews.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/demos/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/demos/declarative/samegame/SamegameCore/BoomBlock.qml b/demos/declarative/samegame/SamegameCore/BoomBlock.qml new file mode 100644 index 0000000..3f43579 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/BoomBlock.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +import Qt.labs.particles 1.0 + +Item { + id: block + property bool dying: false + property bool spawned: false + property int type: 0 + property int targetX: 0 + property int targetY: 0 + + SpringFollow on x { enabled: spawned; to: targetX; spring: 2; damping: 0.2 } + SpringFollow on y { to: targetY; 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 + } + + 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 == 0){ + "pics/redStar.png"; + } else if (type == 1) { + "pics/blueStar.png"; + } else { + "pics/greenStar.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 } + StateChangeScript { script: block.destroy(1000); } + } + ] +} diff --git a/demos/declarative/samegame/SamegameCore/Button.qml b/demos/declarative/samegame/SamegameCore/Button.qml new file mode 100644 index 0000000..d5979b2 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/Button.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 6 + 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 + } +} diff --git a/demos/declarative/samegame/SamegameCore/Dialog.qml b/demos/declarative/samegame/SamegameCore/Dialog.qml new file mode 100644 index 0000000..8dd12f6 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/Dialog.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Rectangle { + id: page + + property Item text: dialogText + + signal closed + + function forceClose() { + page.closed(); + page.opacity = 0; + } + + function show(txt) { + dialogText.text = txt; + page.opacity = 1; + } + + width: dialogText.width + 20; height: dialogText.height + 20 + color: "white" + border.width: 1 + 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/demos/declarative/samegame/SamegameCore/pics/background.png b/demos/declarative/samegame/SamegameCore/pics/background.png Binary files differnew file mode 100644 index 0000000..3734a27 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/pics/background.png diff --git a/demos/declarative/samegame/SamegameCore/pics/blueStar.png b/demos/declarative/samegame/SamegameCore/pics/blueStar.png Binary files differnew file mode 100644 index 0000000..ff9588f --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/pics/blueStar.png diff --git a/demos/declarative/samegame/SamegameCore/pics/blueStone.png b/demos/declarative/samegame/SamegameCore/pics/blueStone.png Binary files differnew file mode 100644 index 0000000..20e43c7 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/pics/blueStone.png diff --git a/demos/declarative/samegame/SamegameCore/pics/greenStar.png b/demos/declarative/samegame/SamegameCore/pics/greenStar.png Binary files differnew file mode 100644 index 0000000..cd06854 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/pics/greenStar.png diff --git a/demos/declarative/samegame/SamegameCore/pics/greenStone.png b/demos/declarative/samegame/SamegameCore/pics/greenStone.png Binary files differnew file mode 100644 index 0000000..b568a19 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/pics/greenStone.png diff --git a/demos/declarative/samegame/SamegameCore/pics/redStar.png b/demos/declarative/samegame/SamegameCore/pics/redStar.png Binary files differnew file mode 100644 index 0000000..0a4dffe --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/pics/redStar.png diff --git a/demos/declarative/samegame/SamegameCore/pics/redStone.png b/demos/declarative/samegame/SamegameCore/pics/redStone.png Binary files differnew file mode 100644 index 0000000..36b09a2 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/pics/redStone.png diff --git a/demos/declarative/samegame/SamegameCore/pics/star.png b/demos/declarative/samegame/SamegameCore/pics/star.png Binary files differnew file mode 100644 index 0000000..defbde5 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/pics/star.png diff --git a/demos/declarative/samegame/SamegameCore/pics/yellowStone.png b/demos/declarative/samegame/SamegameCore/pics/yellowStone.png Binary files differnew file mode 100644 index 0000000..b1ce762 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/pics/yellowStone.png diff --git a/demos/declarative/samegame/SamegameCore/qmldir b/demos/declarative/samegame/SamegameCore/qmldir new file mode 100644 index 0000000..e17b1f5 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/qmldir @@ -0,0 +1,3 @@ +BoomBlock BoomBlock.qml +Button Button.qml +Dialog Dialog.qml diff --git a/demos/declarative/samegame/SamegameCore/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js new file mode 100755 index 0000000..5c008a2 --- /dev/null +++ b/demos/declarative/samegame/SamegameCore/samegame.js @@ -0,0 +1,238 @@ +/* This script file handles the game logic */ + +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn*maxRow; +var board = new Array(maxIndex); +var blockSrc = "SamegameCore/BoomBlock.qml"; +var scoresURL = ""; +var gameDuration; +var component = Qt.createComponent(blockSrc); + +//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.targetY += 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.targetX -= 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; + nameInputDialog.show("You won! Please enter your name: "); + nameInputDialog.initialWidth = nameInputDialog.text.width + 20; + nameInputDialog.width = nameInputDialog.initialWidth; + nameInputDialog.text.opacity = 0;//Just a spacer + } +} + +//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); + if(dynamicObject == null){ + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.type = Math.floor(Math.random() * 3); + dynamicObject.x = column*gameCanvas.blockSize; + dynamicObject.targetX = column*gameCanvas.blockSize; + dynamicObject.targetY = row*gameCanvas.blockSize; + dynamicObject.width = gameCanvas.blockSize; + dynamicObject.height = 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 saveHighScore(name) { + if(scoresURL!="") + sendHighScore(name); + //OfflineStorage + 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'; + } + 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/demos/declarative/samegame/highscores/README b/demos/declarative/samegame/highscores/README new file mode 100644 index 0000000..eaa00fa --- /dev/null +++ b/demos/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/demos/declarative/samegame/highscores/score_data.xml b/demos/declarative/samegame/highscores/score_data.xml new file mode 100755 index 0000000..c3fd90d --- /dev/null +++ b/demos/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/demos/declarative/samegame/highscores/score_style.xsl b/demos/declarative/samegame/highscores/score_style.xsl new file mode 100755 index 0000000..670354c --- /dev/null +++ b/demos/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/demos/declarative/samegame/highscores/scores.php b/demos/declarative/samegame/highscores/scores.php new file mode 100755 index 0000000..3cceb2d --- /dev/null +++ b/demos/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/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml new file mode 100644 index 0000000..54c18d6 --- /dev/null +++ b/demos/declarative/samegame/samegame.qml @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +import "SamegameCore" +import "SamegameCore/samegame.js" as Logic + +Rectangle { + id: screen + width: 490; height: 720 + + 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); + } + } + } + + Dialog { id: dialog; anchors.centerIn: parent; z: 21 } + + Dialog { + id: nameInputDialog + + property int initialWidth: 0 + + anchors.centerIn: parent + z: 22; + + Behavior on width { + NumberAnimation {} + enabled: initialWidth != 0 + } + + Text { + id: dialogText + anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter } + text: "You won! Please enter your name: " + } + + TextInput { + id: nameInputText + anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } + focus: true + + onTextChanged: { + var newWidth = nameInputText.width + dialogText.width + 40; + if ( (newWidth > nameInputDialog.width && newWidth < screen.width) + || (nameInputDialog.width > nameInputDialog.initialWidth) ) + nameInputDialog.width = newWidth; + } + onAccepted: { + if (nameInputDialog.opacity == 1 && nameInputText.text != "") + Logic.saveHighScore(nameInputText.text); + nameInputDialog.forceClose(); + } + } + } + + Rectangle { + id: toolBar + width: parent.width; height: 32 + 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 { + 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 + color: activePalette.windowText + } + } +} diff --git a/demos/declarative/samegame/samegame.qmlproject b/demos/declarative/samegame/samegame.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/demos/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/demos/declarative/snake/content/Button.qml b/demos/declarative/snake/content/Button.qml new file mode 100644 index 0000000..5d9eebe --- /dev/null +++ b/demos/declarative/snake/content/Button.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/snake/content/Cookie.qml b/demos/declarative/snake/content/Cookie.qml new file mode 100644 index 0000000..e67a7af --- /dev/null +++ b/demos/declarative/snake/content/Cookie.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +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 + Behavior on opacity { NumberAnimation { duration: 100 } } + 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 } + } + ] +} diff --git a/demos/declarative/snake/content/HighScoreModel.qml b/demos/declarative/snake/content/HighScoreModel.qml new file mode 100644 index 0000000..99799c8 --- /dev/null +++ b/demos/declarative/snake/content/HighScoreModel.qml @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +// 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 <= ?", + [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/demos/declarative/snake/content/Link.qml b/demos/declarative/snake/content/Link.qml new file mode 100644 index 0000000..9aa6006 --- /dev/null +++ b/demos/declarative/snake/content/Link.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +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 { NumberAnimation { duration: spawned ? 200 : 0} } + } + } + + Image { + source: "pics/stoneShadow.png" + } + + opacity: 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + } + + + 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 } + } + ] +} diff --git a/demos/declarative/snake/content/Skull.qml b/demos/declarative/snake/content/Skull.qml new file mode 100644 index 0000000..0cc6186 --- /dev/null +++ b/demos/declarative/snake/content/Skull.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/snake/content/pics/README b/demos/declarative/snake/content/pics/README new file mode 100644 index 0000000..0215132 --- /dev/null +++ b/demos/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/demos/declarative/snake/content/pics/background.png b/demos/declarative/snake/content/pics/background.png Binary files differnew file mode 100644 index 0000000..72dffaa --- /dev/null +++ b/demos/declarative/snake/content/pics/background.png diff --git a/demos/declarative/snake/content/pics/blueStar.png b/demos/declarative/snake/content/pics/blueStar.png Binary files differnew file mode 100644 index 0000000..ba7acab --- /dev/null +++ b/demos/declarative/snake/content/pics/blueStar.png diff --git a/demos/declarative/snake/content/pics/blueStone.png b/demos/declarative/snake/content/pics/blueStone.png Binary files differnew file mode 100644 index 0000000..356affd --- /dev/null +++ b/demos/declarative/snake/content/pics/blueStone.png diff --git a/demos/declarative/snake/content/pics/cookie.png b/demos/declarative/snake/content/pics/cookie.png Binary files differnew file mode 100644 index 0000000..aec2957 --- /dev/null +++ b/demos/declarative/snake/content/pics/cookie.png diff --git a/demos/declarative/snake/content/pics/eyes.svg b/demos/declarative/snake/content/pics/eyes.svg new file mode 100644 index 0000000..1078692 --- /dev/null +++ b/demos/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/demos/declarative/snake/content/pics/head.png b/demos/declarative/snake/content/pics/head.png Binary files differnew file mode 100644 index 0000000..550e002 --- /dev/null +++ b/demos/declarative/snake/content/pics/head.png diff --git a/demos/declarative/snake/content/pics/head.svg b/demos/declarative/snake/content/pics/head.svg new file mode 100644 index 0000000..3bf0bd2 --- /dev/null +++ b/demos/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/demos/declarative/snake/content/pics/redStar.png b/demos/declarative/snake/content/pics/redStar.png Binary files differnew file mode 100644 index 0000000..cd06854 --- /dev/null +++ b/demos/declarative/snake/content/pics/redStar.png diff --git a/demos/declarative/snake/content/pics/redStone.png b/demos/declarative/snake/content/pics/redStone.png Binary files differnew file mode 100644 index 0000000..9bb7fe4 --- /dev/null +++ b/demos/declarative/snake/content/pics/redStone.png diff --git a/demos/declarative/snake/content/pics/skull.png b/demos/declarative/snake/content/pics/skull.png Binary files differnew file mode 100644 index 0000000..6318616 --- /dev/null +++ b/demos/declarative/snake/content/pics/skull.png diff --git a/demos/declarative/snake/content/pics/snake.jpg b/demos/declarative/snake/content/pics/snake.jpg Binary files differnew file mode 100644 index 0000000..e91a784 --- /dev/null +++ b/demos/declarative/snake/content/pics/snake.jpg diff --git a/demos/declarative/snake/content/pics/star.png b/demos/declarative/snake/content/pics/star.png Binary files differnew file mode 100644 index 0000000..defbde5 --- /dev/null +++ b/demos/declarative/snake/content/pics/star.png diff --git a/demos/declarative/snake/content/pics/stoneShadow.png b/demos/declarative/snake/content/pics/stoneShadow.png Binary files differnew file mode 100644 index 0000000..1bd56af --- /dev/null +++ b/demos/declarative/snake/content/pics/stoneShadow.png diff --git a/demos/declarative/snake/content/pics/yellowStar.png b/demos/declarative/snake/content/pics/yellowStar.png Binary files differnew file mode 100644 index 0000000..52fb9c4 --- /dev/null +++ b/demos/declarative/snake/content/pics/yellowStar.png diff --git a/demos/declarative/snake/content/pics/yellowStone.png b/demos/declarative/snake/content/pics/yellowStone.png Binary files differnew file mode 100644 index 0000000..c56124a --- /dev/null +++ b/demos/declarative/snake/content/pics/yellowStone.png diff --git a/demos/declarative/snake/content/snake.js b/demos/declarative/snake/content/snake.js new file mode 100644 index 0000000..6f78b33 --- /dev/null +++ b/demos/declarative/snake/content/snake.js @@ -0,0 +1,306 @@ + +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) +{ + direction = dir; + if(scheduledDirections[scheduledDirections.length-1]!=direction) + scheduledDirections.push(direction); +} + +function startNewGame() +{ + if (state == "starting") + return; + + if (heartbeat.running) { + endGame(); + startNewGameTimer.running = true; + return; + } + 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; + heartbeat.running = true; +} + +function endGame() +{ + heartbeat.running = false; + for(var i in snake) + snake[i].dying = true; + if (cookie) { + cookie.dying = true; + cookie = 0; + } + lastScore = score; + highScores.saveScore(lastScore); +} + +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/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml new file mode 100644 index 0000000..565e92c --- /dev/null +++ b/demos/declarative/snake/snake.qml @@ -0,0 +1,230 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +import "content" as Content +import "content/snake.js" as Logic + +Rectangle { + id: screen; + SystemPalette { id: activePalette } + color: activePalette.window + + 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; + repeat: true + onTriggered: { Logic.move() } + } + Timer { + id: halfbeat; + interval: halfbeatInterval; + repeat: true + running: heartbeat.running + onTriggered: { Logic.moveSkull() } + } + Timer { + + interval: 700; + onTriggered: { Logic.startNewGame(); } + } + + Timer { + id: startHeartbeatTimer; + interval: 1000 ; + } + + + Image { + Image { + id: title + source: "content/pics/snake.jpg" + fillMode: Image.PreserveAspectCrop + anchors.fill: parent + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + Behavior on opacity { NumberAnimation { duration: 500 } } + + Text { + color: "white" + font.pointSize: 24 + horizontalAlignment: Text.AlignHCenter + text: "Last Score:\t" + lastScore + "\nHighscore:\t" + highScores.topScore; + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: gridSize + } + } + + 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 (!head || !heartbeat.running) { + 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; + Behavior on width { NumberAnimation { duration: startHeartbeatTimer.running ? 1000 : 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 + } + + 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" + when: startHeartbeatTimer.running + PropertyChanges {target: progressIndicator; width: 200} + PropertyChanges {target: title; opacity: 0} + PropertyChanges {target: progressBar; opacity: 1} + }, + State { + name: "running" + when: (heartbeat.running && !startHeartbeatTimer.running) + PropertyChanges {target: progressIndicator; width: 200} + PropertyChanges {target: title; opacity: 0} + PropertyChanges {target: skull; row: 0; column: 0; } + PropertyChanges {target: skull; spawned: 1} + } + ] + +} diff --git a/demos/declarative/snake/snake.qmlproject b/demos/declarative/snake/snake.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/demos/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/demos/declarative/twitter/TwitterCore/AuthView.qml b/demos/declarative/twitter/TwitterCore/AuthView.qml new file mode 100644 index 0000000..ef10258 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/AuthView.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + id: wrapper + Column { + anchors.centerIn: parent + spacing: 20 + Column{ + spacing: 4 + Text { + text: "Screen name:" + font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + horizontalAlignment: Qt.AlignRight + } + Item { + width: 220 + height: 28 + BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } + TextInput{ + id: nameIn + width: parent.width - 8 + anchors.centerIn: parent + maximumLength:21 + font.pixelSize: 16; + font.bold: true + color: "#151515"; selectionColor: "green" + KeyNavigation.tab: passIn + KeyNavigation.backtab: guest + focus: true + } + } + } + Column{ + spacing: 4 + Text { + text: "Password:" + font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + horizontalAlignment: Qt.AlignRight + } + Item { + width: 220 + height: 28 + BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } + TextInput{ + id: passIn + width: parent.width - 8 + anchors.centerIn: parent + maximumLength:21 + echoMode: TextInput.Password + font.pixelSize: 16; + font.bold: true + color: "#151515"; selectionColor: "green" + KeyNavigation.tab: login + KeyNavigation.backtab: nameIn + } + } + } + Row{ + spacing: 10 + Button { + width: 100 + height: 32 + id: login + keyUsing: true; + function doLogin(){ + rssModel.authName=nameIn.text; + rssModel.authPass=passIn.text; + rssModel.tags='my timeline'; + screen.focus = true; + } + text: "Log in" + KeyNavigation.right: guest + KeyNavigation.tab: guest + KeyNavigation.backtab: passIn + Keys.onReturnPressed: login.doLogin(); + Keys.onSelectPressed: login.doLogin(); + Keys.onSpacePressed: login.doLogin(); + onClicked: login.doLogin(); + } + Button { + width: 100 + height: 32 + id: guest + keyUsing: true; + function doGuest() + { + rssModel.authName='-'; + screen.focus = true; + screen.setMode(true); + } + text: "Guest" + KeyNavigation.left: login + KeyNavigation.tab: nameIn + KeyNavigation.backtab: login + Keys.onReturnPressed: guest.doGuest(); + Keys.onSelectPressed: guest.doGuest(); + Keys.onSpacePressed: guest.doGuest(); + onClicked: guest.doGuest(); + } + } + } +} diff --git a/demos/declarative/twitter/TwitterCore/Button.qml b/demos/declarative/twitter/TwitterCore/Button.qml new file mode 100644 index 0000000..9c90c2c --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/Button.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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){"#DDDDDD";} 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.focus == true + PropertyChanges { target: btnText; color: "#FFFFFF" } + } + ] + transitions: Transition { + ColorAnimation { target: btnText; } + } +} diff --git a/demos/declarative/twitter/TwitterCore/FatDelegate.qml b/demos/declarative/twitter/TwitterCore/FatDelegate.qml new file mode 100644 index 0000000..ff03b0b --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/FatDelegate.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Component { + id: listDelegate + Item { + id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 58){txt.height+8}else{58}//50+4+4 + function handleLink(link){ + if(link.slice(0,3) == 'app'){ + screen.setUser(link.slice(7)); + screen.setMode(true); + }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; + } + 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 + } + Rectangle { + id: whiteRect; x: 6; width: 50; height: 50; color: "white"; 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 } + } + 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://@'+userScreenName+'"><b>'+userScreenName + "</b></a> from " +source + + "<br /><b>" + wrapper.addTags(statusText) + "</b></html>"; + textFormat: Qt.RichText + color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap + anchors.left: whiteRect.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6 + onLinkActivated: wrapper.handleLink(link) + } + } + } +} diff --git a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml new file mode 100644 index 0000000..3828a40 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + id: titleBar + + signal update() + onYChanged: state="" //When switching titlebars + + 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() { + if(rssModel.authName == '' || rssModel.authPass == '') + return false;//Can't login like that + + var postData = "status=" + editor.text; + var postman = new XMLHttpRequest(); + postman.open("POST", "http://twitter.com/statuses/update.xml", true, rssModel.authName, rssModel.authPass); + postman.onreadystatechange = function() { + if (postman.readyState == postman.DONE) { + titleBar.update(); + } + } + postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + postman.send(postData); + + editor.text = "" + titleBar.state = "" + } + + Rectangle { + x: 6; width: 50; height: 50; color: "white"; smooth: true + anchors.verticalCenter: parent.verticalCenter + + UserModel { user: rssModel.authName; id: userModel } + Component { id: imgDelegate; + Item { + Loading { width:48; height:48; visible: realImage.status != Image.Ready } + Image { source: image; width:48; height:48; id: realImage } + } + } + ListView { model: userModel.model; x:1; y:1; delegate: imgDelegate } + } + + Text { + id: categoryText + anchors.left: parent.left; anchors.right: tagButton.left + anchors.leftMargin: 58; anchors.rightMargin: 10 + anchors.verticalCenter: parent.verticalCenter + elide: Text.ElideLeft + text: "Timeline for " + rssModel.authName + font.pixelSize: 12; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + } + + Button { + id: tagButton; x: titleBar.width - 90; width: 85; height: 32; text: "New Post..." + anchors.verticalCenter: parent.verticalCenter; + onClicked: if (titleBar.state == "Posting") container.accept(); else titleBar.state = "Posting" + } + + Text { + id: charsLeftText; anchors.horizontalCenter: tagButton.horizontalCenter; + anchors.top: tagButton.bottom; anchors.topMargin: 2 + text: {140 - editor.text.length;} visible: titleBar.state == "Posting" + font.pointSize: 10; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + } + Item { + id: txtEdit; + anchors.left: tagButton.right; anchors.leftMargin: 5; y: 4 + anchors.right: parent.right; anchors.rightMargin: 40; height: parent.height - 9 + BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } + + Binding {//TODO: Can this be a function, which also resets the cursor? And flashes? + when: editor.text.length > 140 + target: editor + property: "text" + value: editor.text.slice(0,140) + } + TextEdit { + id: editor + anchors.left: parent.left; + anchors.leftMargin: 8; + anchors.bottom: parent.bottom + anchors.bottomMargin: 4; + cursorVisible: true; font.bold: true + width: parent.width - 12 + height: parent.height - 8 + font.pointSize: 10 + wrapMode: TextEdit.Wrap + color: "#151515"; selectionColor: "green" + } + Keys.forwardTo: [(returnKey), (editor)] + Item { + id: returnKey + Keys.onReturnPressed: container.accept() + Keys.onEscapePressed: titleBar.state = "" + } + } + } + states: [ + State { + name: "Posting" + PropertyChanges { target: container; x: -tagButton.x + 5 } + PropertyChanges { target: titleBar; height: 80 } + PropertyChanges { target: tagButton; text: "OK" } + PropertyChanges { target: tagButton; width: 28 } + PropertyChanges { target: tagButton; height: 24 } + PropertyChanges { target: txtEdit; focus: true } + } + ] + transitions: [ + Transition { + from: "*"; to: "*" + NumberAnimation { properties: "x,y,width,height"; easing.type: Easing.InOutQuad } + } + ] +} diff --git a/demos/declarative/twitter/TwitterCore/Loading.qml b/demos/declarative/twitter/TwitterCore/Loading.qml new file mode 100644 index 0000000..b979291 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/Loading.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml b/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml new file mode 100644 index 0000000..38d6c9c --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + height: homeBar.height + HomeTitleBar { id: homeBar; width: parent.width; height: 60; + onUpdate: rssModel.reload() + } + 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.userView + PropertyChanges { target: titleBar; y: 0 } + PropertyChanges { target: homeBar; y: -80 } + } + ] + transitions: [ + Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } } + ] +} + diff --git a/demos/declarative/twitter/TwitterCore/RssModel.qml b/demos/declarative/twitter/TwitterCore/RssModel.qml new file mode 100644 index 0000000..bd73200 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/RssModel.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { id: wrapper + property variant model: xmlModel + property string tags : "" + property string authName : "" + property string authPass : "" + property string mode : "everyone" + property int status: xmlModel.status + function reload() { xmlModel.reload(); } +XmlListModel { + id: xmlModel + + source:{ + if (wrapper.authName == ""){ + ""; //Avoid worthless calls to twitter servers + }else if(wrapper.mode == 'user'){ + "https://"+ ((wrapper.authName!="" && wrapper.authPass!="")? (wrapper.authName+":"+wrapper.authPass+"@") : "" )+"twitter.com/statuses/user_timeline.xml?screen_name="+wrapper.tags; + }else if(wrapper.mode == 'self'){ + "https://"+ ((wrapper.authName!="" && wrapper.authPass!="")? (wrapper.authName+":"+wrapper.authPass+"@") : "" )+"twitter.com/statuses/friends_timeline.xml"; + }else{//everyone/public + "http://twitter.com/statuses/public_timeline.xml"; + } + } + query: "/statuses/status" + + XmlRole { name: "statusText"; query: "text/string()" } + XmlRole { name: "timestamp"; query: "created_at/string()" } + XmlRole { name: "source"; query: "source/string()" } + XmlRole { name: "userName"; query: "user/name/string()" } + XmlRole { name: "userScreenName"; query: "user/screen_name/string()" } + XmlRole { name: "userImage"; query: "user/profile_image_url/string()" } + XmlRole { name: "userLocation"; query: "user/location/string()" } + XmlRole { name: "userDescription"; query: "user/description/string()" } + XmlRole { name: "userFollowers"; query: "user/followers_count/string()" } + XmlRole { name: "userStatuses"; query: "user/statuses_count/string()" } + //TODO: Could also get the user's color scheme, timezone and a few other things +} +Binding { + property: "mode" + target: wrapper + value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}} +} +} diff --git a/demos/declarative/twitter/TwitterCore/TitleBar.qml b/demos/declarative/twitter/TwitterCore/TitleBar.qml new file mode 100644 index 0000000..0cf79a3 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/TitleBar.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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 + } + + Text { + id: categoryText + anchors { + left: parent.left; right: tagButton.left; leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + elide: Text.ElideLeft + text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags) + font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black" + font.pixelSize: 12 + } + + 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.onEscapePressed: titleBar.state = "" + } + } + } + + states: State { + name: "Tags" + PropertyChanges { target: container; x: -tagButton.x + 5 } + PropertyChanges { target: tagButton; text: "OK" } + PropertyChanges { target: lineEdit; focus: true } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } + } +} diff --git a/demos/declarative/twitter/TwitterCore/ToolBar.qml b/demos/declarative/twitter/TwitterCore/ToolBar.qml new file mode 100644 index 0000000..b9cb915 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/ToolBar.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + id: toolbar + + property alias button1Label: button1.text + property alias button2Label: button2.text + signal button1Clicked + signal button2Clicked + + 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() + } + + Button { + id: button2 + anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32 + onClicked: toolbar.button2Clicked() + } +} diff --git a/demos/declarative/twitter/TwitterCore/UserModel.qml b/demos/declarative/twitter/TwitterCore/UserModel.qml new file mode 100644 index 0000000..e653836 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/UserModel.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +//This "model" gets the user information about the searched user. Mainly for the icon. +//Copied from RssModel + +Item { id: wrapper + property variant model: xmlModel + property string user : "" + property int status: xmlModel.status + function reload() { xmlModel.reload(); } +XmlListModel { + id: xmlModel + + source: {if(user!="") {"http://twitter.com/users/show.xml?screen_name="+user;}else{"";}} + 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()" } + //XmlRole { name: "protected"; query: "protected/bool()" } + //TODO: Could also get the user's color scheme, timezone and a few other things +} +} diff --git a/demos/declarative/twitter/TwitterCore/images/gloss.png b/demos/declarative/twitter/TwitterCore/images/gloss.png Binary files differnew file mode 100644 index 0000000..5d370cd --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/images/gloss.png diff --git a/demos/declarative/twitter/TwitterCore/images/lineedit.png b/demos/declarative/twitter/TwitterCore/images/lineedit.png Binary files differnew file mode 100644 index 0000000..2cc38dc --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/images/lineedit.png diff --git a/demos/declarative/twitter/TwitterCore/images/lineedit.sci b/demos/declarative/twitter/TwitterCore/images/lineedit.sci new file mode 100644 index 0000000..054bff7 --- /dev/null +++ b/demos/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/demos/declarative/twitter/TwitterCore/images/loading.png b/demos/declarative/twitter/TwitterCore/images/loading.png Binary files differnew file mode 100644 index 0000000..47a1589 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/images/loading.png diff --git a/demos/declarative/twitter/TwitterCore/images/stripes.png b/demos/declarative/twitter/TwitterCore/images/stripes.png Binary files differnew file mode 100644 index 0000000..9f36727 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/images/stripes.png diff --git a/demos/declarative/twitter/TwitterCore/images/titlebar.png b/demos/declarative/twitter/TwitterCore/images/titlebar.png Binary files differnew file mode 100644 index 0000000..51c9008 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/images/titlebar.png diff --git a/demos/declarative/twitter/TwitterCore/images/titlebar.sci b/demos/declarative/twitter/TwitterCore/images/titlebar.sci new file mode 100644 index 0000000..0418d94 --- /dev/null +++ b/demos/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/demos/declarative/twitter/TwitterCore/images/toolbutton.png b/demos/declarative/twitter/TwitterCore/images/toolbutton.png Binary files differnew file mode 100644 index 0000000..1131001 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/images/toolbutton.png diff --git a/demos/declarative/twitter/TwitterCore/images/toolbutton.sci b/demos/declarative/twitter/TwitterCore/images/toolbutton.sci new file mode 100644 index 0000000..9e4f965 --- /dev/null +++ b/demos/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/demos/declarative/twitter/TwitterCore/qmldir b/demos/declarative/twitter/TwitterCore/qmldir new file mode 100644 index 0000000..8b56c56 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/qmldir @@ -0,0 +1,10 @@ +AuthView 1.0 AuthView.qml +Button 1.0 Button.qml +FatDelegate 1.0 FatDelegate.qml +HomeTitleBar 1.0 HomeTitleBar.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/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml new file mode 100644 index 0000000..aa216cc --- /dev/null +++ b/demos/declarative/twitter/twitter.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +import "TwitterCore" 1.0 as Twitter + +Item { + id: screen; width: 320; height: 480 + property bool userView : false + property variant tmpStr + function setMode(m){ + screen.userView = m; + if(m == false){ + rssModel.tags='my timeline'; + rssModel.reload(); + toolBar.button2Label = "View others"; + } else { + toolBar.button2Label = "Return home"; + } + } + function setUser(str){hack.running = true; tmpStr = str} + function reallySetUser(){rssModel.tags = tmpStr;} + + //Workaround for bug 260266 + Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack } + + //TODO: better way to return to the auth screen + Keys.onEscapePressed: rssModel.authName='' + Rectangle { + id: background + anchors.fill: parent; color: "#343434"; + + Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } + + 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: 380 + + Twitter.AuthView{ + id: authView + 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: "Update" + button2Label: "View others" + onButton1Clicked: rssModel.reload(); + onButton2Clicked: + { + if(screen.userView == true){ + screen.setMode(false); + }else{ + rssModel.tags=''; + screen.setMode(true); + } + } + } + + states: [ + State { + name: "unauthed"; when: rssModel.authName=="" + PropertyChanges { target: authView; x: 0 } + PropertyChanges { target: mainView; x: -(parent.width * 1.5) } + PropertyChanges { target: titleBar; y: -80 } + PropertyChanges { target: toolBar; y: screen.height } + } + ] + transitions: [ + Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } } + ] + } +} diff --git a/demos/declarative/twitter/twitter.qmlproject b/demos/declarative/twitter/twitter.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/demos/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 " ] +} diff --git a/demos/declarative/webbrowser/content/Button.qml b/demos/declarative/webbrowser/content/Button.qml new file mode 100644 index 0000000..4642cc7 --- /dev/null +++ b/demos/declarative/webbrowser/content/Button.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + property alias image: icon.source + property variant action + + width: 40; height: parent.height + + Image { + id: icon; anchors.centerIn: parent + opacity: if(action != undefined) {action.enabled ? 1.0 : 0.4} else 0 + } + + MouseArea { + anchors { fill: parent; topMargin: -10; bottomMargin: -10 } + onClicked: action.trigger() + } +} diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml new file mode 100644 index 0000000..62da2ea --- /dev/null +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -0,0 +1,196 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +import org.webkit 1.0 + +Flickable { + property alias title: webView.title + property alias icon: webView.icon + property alias progress: webView.progress + property alias url: webView.url + property alias back: webView.back + property alias stop: webView.stop + property alias reload: webView.reload + property alias forward: webView.forward + + id: flickable + width: parent.width + contentWidth: Math.max(parent.width,webView.width) + contentHeight: Math.max(parent.height,webView.height) + anchors.top: headerSpace.bottom + anchors.bottom: parent.top + anchors.left: parent.left + anchors.right: parent.right + pressDelay: 200 + + onWidthChanged : { + // Expand (but not above 1:1) if otherwise would be smaller that available width. + if (width > webView.width*webView.contentsScale && webView.contentsScale < 1.0) + webView.contentsScale = width / webView.width * webView.contentsScale; + } + + WebView { + id: webView + transformOrigin: Item.TopLeft + + function fixUrl(url) + { + if (url == "") return url + if (url[0] == "/") return "file://"+url + if (url.indexOf(":")<0) { + if (url.indexOf(".")<0 || url.indexOf(" ")>=0) { + // Fall back to a search engine; hard-code Wikipedia + return "http://en.wikipedia.org/w/index.php?search="+url + } else { + return "http://"+url + } + } + return url + } + + url: fixUrl(webBrowser.urlString) + smooth: false // We don't want smooth scaling, since we only scale during (fast) transitions + focus: true + zoomFactor: 1 + + onAlert: console.log(message) + + function doZoom(zoom,centerX,centerY) + { + if (centerX) { + var sc = zoom*contentsScale; + scaleAnim.to = sc; + flickVX.from = flickable.contentX + flickVX.to = Math.max(0,Math.min(centerX-flickable.width/2,webView.width*sc-flickable.width)) + finalX.value = flickVX.to + flickVY.from = flickable.contentY + flickVY.to = Math.max(0,Math.min(centerY-flickable.height/2,webView.height*sc-flickable.height)) + finalY.value = flickVY.to + quickZoom.start() + } + } + + Keys.onLeftPressed: webView.contentsScale -= 0.1 + Keys.onRightPressed: webView.contentsScale += 0.1 + + preferredWidth: flickable.width + preferredHeight: flickable.height + contentsScale: 1/zoomFactor + onContentsSizeChanged: { + // zoom out + contentsScale = Math.min(1,flickable.width / contentsSize.width) + } + onUrlChanged: { + // got to topleft + flickable.contentX = 0 + flickable.contentY = 0 + if (url != null) { header.editUrl = url.toString(); } + } + onDoubleClick: { + if (!heuristicZoom(clickX,clickY,2.5)) { + var zf = flickable.width / contentsSize.width + if (zf >= contentsScale) + zf = 2.0/zoomFactor // zoom in (else zooming out) + doZoom(zf,clickX*zf,clickY*zf) + } + } + + SequentialAnimation { + id: quickZoom + + PropertyAction { + target: webView + property: "renderingEnabled" + value: false + } + ParallelAnimation { + NumberAnimation { + id: scaleAnim + target: webView + property: "contentsScale" + // the to property is set before calling + easing.type: Easing.Linear + duration: 200 + } + NumberAnimation { + id: flickVX + target: flickable + property: "contentX" + easing.type: Easing.Linear + duration: 200 + from: 0 // set before calling + to: 0 // set before calling + } + NumberAnimation { + id: flickVY + target: flickable + property: "contentY" + easing.type: Easing.Linear + duration: 200 + from: 0 // set before calling + to: 0 // set before calling + } + } + // Have to set the contentXY, since the above 2 + // size changes may have started a correction if + // contentsScale < 1.0. + PropertyAction { + id: finalX + target: flickable + property: "contentX" + value: 0 // set before calling + } + PropertyAction { + id: finalY + target: flickable + property: "contentY" + value: 0 // set before calling + } + PropertyAction { + target: webView + property: "renderingEnabled" + value: true + } + } + onZoomTo: doZoom(zoom,centerX,centerY) + } +} diff --git a/demos/declarative/webbrowser/content/Header.qml b/demos/declarative/webbrowser/content/Header.qml new file mode 100644 index 0000000..2c9d0fb --- /dev/null +++ b/demos/declarative/webbrowser/content/Header.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Image { + property alias editUrl: urlInput.url + + source: "pics/titlebar-bg.png"; fillMode: Image.TileHorizontally + + x: webView.contentX < 0 ? -webView.contentX : webView.contentX > webView.contentWidth-webView.width + ? -webView.contentX+webView.contentWidth-webView.width : 0 + + y: { + if (webView.progress < 1.0) + return 0; + else { + webView.contentY < 0 ? -webView.contentY : webView.contentY > height ? -height : -webView.contentY + } + } + + Column { + width: parent.width + + Item { + width: parent.width; height: 20 + Text { + anchors.centerIn: parent + text: webView.title; font.pixelSize: 14; font.bold: true + color: "white"; styleColor: "black"; style: Text.Sunken + } + } + + Item { + width: parent.width; height: 40 + + Button { + id: backButton + action: webView.back; image: "pics/go-previous-view.png" + anchors { left: parent.left; bottom: parent.bottom } + } + + Button { + id: nextButton + anchors.left: backButton.right + action: webView.forward; image: "pics/go-next-view.png" + } + + UrlInput { + id: urlInput + anchors { left: nextButton.right; right: reloadButton.left } + image: "pics/display.png" + onUrlEntered: { + webBrowser.urlString = url + webBrowser.focus = true + } + } + + Button { + id: reloadButton + anchors { right: parent.right; rightMargin: 4 } + action: webView.reload; image: "pics/view-refresh.png"; visible: webView.progress == 1.0 + } + + Button { + id: stopButton + anchors { right: parent.right; rightMargin: 4 } + action: webView.stop; image: "pics/edit-delete.png"; visible: webView.progress < 1.0 + } + } + } +} diff --git a/demos/declarative/webbrowser/content/ScrollBar.qml b/demos/declarative/webbrowser/content/ScrollBar.qml new file mode 100644 index 0000000..d3f272c --- /dev/null +++ b/demos/declarative/webbrowser/content/ScrollBar.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +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.5 } + + BorderImage { + source: "pics/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/demos/declarative/webbrowser/content/UrlInput.qml b/demos/declarative/webbrowser/content/UrlInput.qml new file mode 100644 index 0000000..9ea1904 --- /dev/null +++ b/demos/declarative/webbrowser/content/UrlInput.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 + +Item { + id: container + + property alias image: bg.source + property alias url: urlText.text + + signal urlEntered(string url) + + width: parent.height; height: parent.height + + BorderImage { + id: bg; rotation: 180 + x: 8; width: parent.width - 16; height: 30; + anchors.verticalCenter: parent.verticalCenter + border { left: 10; top: 10; right: 10; bottom: 10 } + } + + Rectangle { + anchors.bottom: bg.bottom + x: 18; height: 4; color: "#63b1ed" + width: (bg.width - 20) * webView.progress + opacity: webView.progress == 1.0 ? 0.0 : 1.0 + } + + TextInput { + id: urlText + horizontalAlignment: TextEdit.AlignLeft + font.pixelSize: 14; focusOnPress: true + Keys.onEscapePressed: { + urlText.text = webView.url + webView.focus = true + } + Keys.onReturnPressed: { + container.urlEntered(urlText.text) + webView.focus = true + } + anchors { + left: parent.left; right: parent.right; leftMargin: 18; rightMargin: 18 + verticalCenter: parent.verticalCenter + } + } +} diff --git a/demos/declarative/webbrowser/content/pics/display.png b/demos/declarative/webbrowser/content/pics/display.png Binary files differnew file mode 100644 index 0000000..9507f43 --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/display.png diff --git a/demos/declarative/webbrowser/content/pics/edit-delete.png b/demos/declarative/webbrowser/content/pics/edit-delete.png Binary files differnew file mode 100644 index 0000000..351659b --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/edit-delete.png diff --git a/demos/declarative/webbrowser/content/pics/go-next-view.png b/demos/declarative/webbrowser/content/pics/go-next-view.png Binary files differnew file mode 100644 index 0000000..3bce02d --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/go-next-view.png diff --git a/demos/declarative/webbrowser/content/pics/go-previous-view.png b/demos/declarative/webbrowser/content/pics/go-previous-view.png Binary files differnew file mode 100644 index 0000000..3ec011e --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/go-previous-view.png diff --git a/demos/declarative/webbrowser/content/pics/scrollbar.png b/demos/declarative/webbrowser/content/pics/scrollbar.png Binary files differnew file mode 100644 index 0000000..0228dcf --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/scrollbar.png diff --git a/demos/declarative/webbrowser/content/pics/titlebar-bg.png b/demos/declarative/webbrowser/content/pics/titlebar-bg.png Binary files differnew file mode 100644 index 0000000..06961e8 --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/titlebar-bg.png diff --git a/demos/declarative/webbrowser/content/pics/view-refresh.png b/demos/declarative/webbrowser/content/pics/view-refresh.png Binary files differnew file mode 100644 index 0000000..afa2a9d --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/view-refresh.png diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml new file mode 100644 index 0000000..a923c92 --- /dev/null +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Qt 4.7 +import org.webkit 1.0 + +import "content" + +Rectangle { + id: webBrowser + + property string urlString : "http://www.nokia.com/" + + width: 800; height: 600 + color: "#343434" + + FlickableWebView { + id: webView + url: webBrowser.urlString + anchors { top: headerSpace.bottom; left: parent.left; right: parent.right; bottom: parent.bottom } + } + + Item { id: headerSpace; width: parent.width; height: 62 } + + Header { + id: header + editUrl: webBrowser.urlString + width: headerSpace.width; height: headerSpace.height + } + + ScrollBar { + scrollArea: webView; width: 8 + anchors { right: parent.right; top: header.bottom; bottom: parent.bottom } + } + + ScrollBar { + scrollArea: webView; height: 8; orientation: Qt.Horizontal + anchors { right: parent.right; rightMargin: 8; left: parent.left; bottom: parent.bottom } + } +} diff --git a/demos/declarative/webbrowser/webbrowser.qmlproject b/demos/declarative/webbrowser/webbrowser.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/demos/declarative/webbrowser/webbrowser.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/demos/deform/main.cpp b/demos/deform/main.cpp index 4539973..bef075a 100644 --- a/demos/deform/main.cpp +++ b/demos/deform/main.cpp @@ -50,10 +50,7 @@ int main(int argc, char **argv) QApplication app(argc, argv); - bool smallScreen = false; - for (int i=0; i<argc; i++) - if (QString(argv[i]) == "-small-screen") - smallScreen = true; + bool smallScreen = QApplication::arguments().contains("-small-screen"); PathDeformWidget deformWidget(0, smallScreen); diff --git a/demos/demos.pro b/demos/demos.pro index 00092d9..f359bd7 100644 --- a/demos/demos.pro +++ b/demos/demos.pro @@ -1,4 +1,6 @@ TEMPLATE = subdirs + +!contains(QT_CONFIG, no-gui) { SUBDIRS = \ demos_shared \ demos_deform \ @@ -38,12 +40,12 @@ wince*: SUBDIRS = \ demos_undo \ demos_sub-attaq -contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles1):!contains(QT_CONFIG, opengles1cl):!contains(QT_CONFIG, opengles2):{ +contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles1):!contains(QT_CONFIG, opengles2):{ SUBDIRS += demos_boxes } mac*: SUBDIRS += demos_macmainwindow -wince*|symbian|embedded|x11: SUBDIRS += embedded +wince*|symbian|embedded|x11: SUBDIRS += demos_embedded !contains(QT_EDITION, Console):!cross_compile:!embedded:!wince*:SUBDIRS += demos_arthurplugin @@ -55,6 +57,7 @@ wince*:SUBDIRS += demos_sqlbrowser } contains(QT_CONFIG, phonon):!static:SUBDIRS += demos_mediaplayer contains(QT_CONFIG, webkit):contains(QT_CONFIG, svg):!symbian:SUBDIRS += demos_browser +contains(QT_CONFIG, declarative):SUBDIRS += demos_declarative contains(QT_CONFIG, multimedia):SUBDIRS += demos_spectrum # install @@ -66,6 +69,9 @@ symbian: include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) demos_chip.subdir = chip demos_embeddeddialogs.subdir = embeddeddialogs +demos_embedded.subdir = embedded +# Because of fluidlauncher +demos_embedded.depends = demos_deform demos_pathstroke demos_shared.subdir = shared demos_deform.subdir = deform demos_gradients.subdir = gradients @@ -83,6 +89,7 @@ demos_sqlbrowser.subdir = sqlbrowser demos_undo.subdir = undo demos_qtdemo.subdir = qtdemo demos_mediaplayer.subdir = qmediaplayer +demos_declarative.subdir = declarative demos_browser.subdir = browser @@ -99,3 +106,4 @@ demos_spectrum.subdir = spectrum demos_arthurplugin.depends = demos_shared demos_pathstroke.depends = demos_shared } +} diff --git a/demos/embedded/anomaly/anomaly.pro b/demos/embedded/anomaly/anomaly.pro index e16ef66..584e5cd 100644 --- a/demos/embedded/anomaly/anomaly.pro +++ b/demos/embedded/anomaly/anomaly.pro @@ -26,7 +26,7 @@ RESOURCES += src/anomaly.qrc symbian { TARGET.UID3 = 0xA000CF71 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h + INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 diff --git a/demos/embedded/desktopservices/desktopservices.pro b/demos/embedded/desktopservices/desktopservices.pro index bff7c46..94ddedd 100644 --- a/demos/embedded/desktopservices/desktopservices.pro +++ b/demos/embedded/desktopservices/desktopservices.pro @@ -24,8 +24,8 @@ symbian { } wince*{ - music.path = "\My Documents\My Music" - image.path = "\My Documents\My Pictures" + music.path = "\\My Documents\\My Music" + image.path = "\\My Documents\\My Pictures" DEPLOYMENT += music image } diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro index 5bd3276..a3fc72b 100644 --- a/demos/embedded/embedded.pro +++ b/demos/embedded/embedded.pro @@ -4,6 +4,8 @@ SUBDIRS = styledemo raycasting flickable digiflip contains(QT_CONFIG, svg) { SUBDIRS += embeddedsvgviewer \ desktopservices + fluidlauncher.subdir = fluidlauncher + fluidlauncher.depends = styledemo desktopservices raycasting flickable digiflip lightmaps flightinfo !vxworks:!qnx:SUBDIRS += fluidlauncher } @@ -17,6 +19,11 @@ contains(QT_CONFIG, webkit) { SUBDIRS += anomaly } +contains(QT_CONFIG, declarative) { + # Qml demos require DEPLOYMENT support. Therefore, only symbian. + symbian:SUBDIRS += qmlcalculator qmlclocks qmldialcontrol qmleasing qmlflickr qmlphotoviewer qmltwitter +} + # install sources.files = README *.pro sources.path = $$[QT_INSTALL_DEMOS]/embedded diff --git a/demos/embedded/flightinfo/flightinfo.cpp b/demos/embedded/flightinfo/flightinfo.cpp index 10d3f02..425d6aa 100644 --- a/demos/embedded/flightinfo/flightinfo.cpp +++ b/demos/embedded/flightinfo/flightinfo.cpp @@ -43,10 +43,6 @@ #include <QtGui> #include <QtNetwork> -#if defined (Q_OS_SYMBIAN) -#include "sym_iap_util.h" -#endif - #include "ui_form.h" #define FLIGHTVIEW_URL "http://mobile.flightview.com/TrackByFlight.aspx" @@ -100,6 +96,8 @@ private: QUrl m_url; QDate m_searchDate; QPixmap m_map; + QNetworkAccessManager m_manager; + QList<QNetworkReply *> mapReplies; public: @@ -115,7 +113,6 @@ public: connect(ui.flightEdit, SIGNAL(returnPressed()), SLOT(startSearch())); setWindowTitle("Flight Info"); - QTimer::singleShot(0, this, SLOT(delayedInit())); // Rendered from the public-domain vectorized aircraft // http://openclipart.org/media/people/Jarno @@ -127,6 +124,8 @@ public: connect(searchTodayAction, SIGNAL(triggered()), SLOT(today())); connect(searchYesterdayAction, SIGNAL(triggered()), SLOT(yesterday())); connect(randomAction, SIGNAL(triggered()), SLOT(randomFlight())); + connect(&m_manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(handleNetworkData(QNetworkReply*))); #if defined(Q_OS_SYMBIAN) menuBar()->addAction(searchTodayAction); menuBar()->addAction(searchYesterdayAction); @@ -140,31 +139,21 @@ public: } private slots: - void delayedInit() { -#if defined(Q_OS_SYMBIAN) - qt_SetDefaultIap(); -#endif - } - void handleNetworkData(QNetworkReply *networkReply) { if (!networkReply->error()) { - // Assume UTF-8 encoded - QByteArray data = networkReply->readAll(); - QString xml = QString::fromUtf8(data); - digest(xml); - } - networkReply->deleteLater(); - networkReply->manager()->deleteLater(); - } - - void handleMapData(QNetworkReply *networkReply) { - if (!networkReply->error()) { - m_map.loadFromData(networkReply->readAll()); - update(); + if (!mapReplies.contains(networkReply)) { + // Assume UTF-8 encoded + QByteArray data = networkReply->readAll(); + QString xml = QString::fromUtf8(data); + digest(xml); + } else { + mapReplies.removeOne(networkReply); + m_map.loadFromData(networkReply->readAll()); + update(); + } } networkReply->deleteLater(); - networkReply->manager()->deleteLater(); } void today() { @@ -185,6 +174,10 @@ private slots: ui.infoBox->hide(); ui.flightStatus->hide(); ui.flightName->setText("Enter flight number"); + ui.flightEdit->setFocus(); +#ifdef QT_KEYPAD_NAVIGATION + ui.flightEdit->setEditFocus(true); +#endif m_map = QPixmap(); update(); } @@ -224,10 +217,7 @@ public slots: ui.flightName->setText("Getting a random flight..."); } - QNetworkAccessManager *manager = new QNetworkAccessManager(this); - connect(manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(handleNetworkData(QNetworkReply*))); - manager->get(QNetworkRequest(m_url)); + m_manager.get(QNetworkRequest(m_url)); } @@ -248,10 +238,7 @@ private: regex.indexIn(href); QString airport = regex.cap(1); m_url.addEncodedQueryItem("dpap", QUrl::toPercentEncoding(airport)); - QNetworkAccessManager *manager = new QNetworkAccessManager(this); - connect(manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(handleNetworkData(QNetworkReply*))); - manager->get(QNetworkRequest(m_url)); + m_manager.get(QNetworkRequest(m_url)); return; } @@ -287,12 +274,9 @@ private: } if (xml.name() == "img" && inFlightMap) { QString src = xml.attributes().value("src").toString(); - src.prepend("http://mobile.flightview.com"); + src.prepend("http://mobile.flightview.com/"); QUrl url = QUrl::fromPercentEncoding(src.toAscii()); - QNetworkAccessManager *manager = new QNetworkAccessManager(this); - connect(manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(handleMapData(QNetworkReply*))); - manager->get(QNetworkRequest(url)); + mapReplies.append(m_manager.get(QNetworkRequest(url))); } } diff --git a/demos/embedded/flightinfo/flightinfo.pro b/demos/embedded/flightinfo/flightinfo.pro index 7391f88..985cc42 100644 --- a/demos/embedded/flightinfo/flightinfo.pro +++ b/demos/embedded/flightinfo/flightinfo.pro @@ -8,7 +8,7 @@ QT += network symbian { TARGET.UID3 = 0xA000CF74 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h + INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices } diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index d926a4b..4f10488 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -21,6 +21,13 @@ <example filename="digiflip" name="Flipping Clock" image="screenshots/digiflip.png"/> <example filename="qmediaplayer" name="Media Player" image="screenshots/mediaplayer.png" args="-small-screen"/> <example filename="spectrum" name="Spectrum Analyzer" image="screenshots/spectrum.png" args="-small-screen"/> + <example filename="qmlcalculator" name="Qml Calculator" image="screenshots/qmlcalculator.png"/> + <example filename="qmlclocks" name="Qml Clocks" image="screenshots/qmlclocks.png"/> + <example filename="qmldialcontrol" name="Qml Dial Control" image="screenshots/qmldialcontrol.png"/> + <example filename="qmleasing" name="Qml Easing Curves" image="screenshots/qmleasing.png"/> + <example filename="qmlflickr" name="Qml flickr" image="screenshots/qmlflickr.jpg"/> + <example filename="qmlphotoviewer" name="Qml Photo Viewer" image="screenshots/qmlphotoviewer.jpg"/> + <example filename="qmltwitter" name="Qml twitter" image="screenshots/qmltwitter.jpg"/> </demos> <slideshow timeout="60000" interval="10000"> <imagedir dir="slides"/> diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro index 4cc73bf..416e58b 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.pro +++ b/demos/embedded/fluidlauncher/fluidlauncher.pro @@ -2,6 +2,7 @@ TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += . +VERSION = $$QT_VERSION # Input HEADERS += \ @@ -57,46 +58,63 @@ wince*{ symbian { load(data_caging_paths) + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + RSS_RULES = # Clear RSS_RULES, otherwise fluidlauncher will get put into QtDemos folder TARGET.UID3 = 0xA000A641 - ICON = $$QT_SOURCE_TREE/src/s60installs/qt.svg + + defineReplace(regResourceDir) { + symbian-abld|symbian-sbsv2 { + return($${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/$$basename(1)) + } else { + return($${QT_BUILD_TREE}/$$1) + } + } + + defineReplace(appResourceDir) { + symbian-abld|symbian-sbsv2 { + return($${EPOCROOT}$${HW_ZDIR}$${APP_RESOURCE_DIR}/$$basename(1)) + } else { + return($${QT_BUILD_TREE}/$$1) + } + } executables.sources = \ - styledemo.exe \ - deform.exe \ - pathstroke.exe \ - wiggly.exe \ - qftp.exe \ - saxbookmarks.exe \ - desktopservices.exe \ - fridgemagnets.exe \ - softkeys.exe \ - raycasting.exe \ - flickable.exe \ - digiflip.exe \ - lightmaps.exe \ - flightinfo.exe + $$QT_BUILD_TREE/demos/embedded/styledemo/styledemo.exe \ + $$QT_BUILD_TREE/demos/deform/deform.exe \ + $$QT_BUILD_TREE/demos/pathstroke/pathstroke.exe \ + $$QT_BUILD_TREE/examples/widgets/wiggly/wiggly.exe \ + $$QT_BUILD_TREE/examples/network/qftp/qftp.exe \ + $$QT_BUILD_TREE/examples/xml/saxbookmarks/saxbookmarks.exe \ + $$QT_BUILD_TREE/demos/embedded/desktopservices/desktopservices.exe \ + $$QT_BUILD_TREE/examples/draganddrop/fridgemagnets/fridgemagnets.exe \ + $$QT_BUILD_TREE/examples/widgets/softkeys/softkeys.exe \ + $$QT_BUILD_TREE/demos/embedded/raycasting/raycasting.exe \ + $$QT_BUILD_TREE/demos/embedded/flickable/flickable.exe \ + $$QT_BUILD_TREE/demos/embedded/digiflip/digiflip.exe \ + $$QT_BUILD_TREE/demos/embedded/lightmaps/lightmaps.exe \ + $$QT_BUILD_TREE/demos/embedded/flightinfo/flightinfo.exe executables.path = /sys/bin reg_resource.sources = \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/styledemo_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/deform_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/pathstroke_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/wiggly_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/qftp_reg.rsc\ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/saxbookmarks_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/desktopservices_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/fridgemagnets_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/softkeys_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/raycasting_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/flickable_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/digiflip_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/lightmaps_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/flightinfo_reg.rsc + $$regResourceDir(demos/embedded/styledemo/styledemo_reg.rsc) \ + $$regResourceDir(demos/deform/deform_reg.rsc) \ + $$regResourceDir(demos/pathstroke/pathstroke_reg.rsc) \ + $$regResourceDir(examples/widgets/wiggly/wiggly_reg.rsc) \ + $$regResourceDir(examples/network/qftp/qftp_reg.rsc)\ + $$regResourceDir(examples/xml/saxbookmarks/saxbookmarks_reg.rsc) \ + $$regResourceDir(demos/embedded/desktopservices/desktopservices_reg.rsc) \ + $$regResourceDir(examples/draganddrop/fridgemagnets/fridgemagnets_reg.rsc) \ + $$regResourceDir(examples/widgets/softkeys/softkeys_reg.rsc) \ + $$regResourceDir(demos/embedded/raycasting/raycasting_reg.rsc) \ + $$regResourceDir(demos/embedded/flickable/flickable_reg.rsc) \ + $$regResourceDir(demos/embedded/digiflip/digiflip_reg.rsc) \ + $$regResourceDir(demos/embedded/lightmaps/lightmaps_reg.rsc) \ + $$regResourceDir(demos/embedded/flightinfo/flightinfo_reg.rsc) contains(QT_CONFIG, phonon) { - reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/qmediaplayer_reg.rsc + reg_resource.sources += $$regResourceDir(demos/qmediaplayer/qmediaplayer_reg.rsc) } contains(QT_CONFIG, multimedia) { @@ -107,66 +125,66 @@ symbian { reg_resource.path = $$REG_RESOURCE_IMPORT_DIR resource.sources = \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/styledemo.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/deform.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/pathstroke.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/wiggly.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/qftp.rsc\ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/saxbookmarks.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/desktopservices.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/fridgemagnets.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/softkeys.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/raycasting.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/flickable.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/digiflip.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/lightmaps.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/flightinfo.rsc + $$appResourceDir(demos/embedded/styledemo/styledemo.rsc) \ + $$appResourceDir(demos/deform/deform.rsc) \ + $$appResourceDir(demos/pathstroke/pathstroke.rsc) \ + $$appResourceDir(examples/widgets/wiggly/wiggly.rsc) \ + $$appResourceDir(examples/network/qftp/qftp.rsc)\ + $$appResourceDir(examples/xml/saxbookmarks/saxbookmarks.rsc) \ + $$appResourceDir(demos/embedded/desktopservices/desktopservices.rsc) \ + $$appResourceDir(examples/draganddrop/fridgemagnets/fridgemagnets.rsc) \ + $$appResourceDir(examples/widgets/softkeys/softkeys.rsc) \ + $$appResourceDir(demos/embedded/raycasting/raycasting.rsc) \ + $$appResourceDir(demos/embedded/flickable/flickable.rsc) \ + $$appResourceDir(demos/embedded/digiflip/digiflip.rsc) \ + $$appResourceDir(demos/embedded/lightmaps/lightmaps.rsc) \ + $$appResourceDir(demos/embedded/flightinfo/flightinfo.rsc) resource.path = $$APP_RESOURCE_DIR mifs.sources = \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/fluidlauncher.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/styledemo.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/deform.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/pathstroke.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/wiggly.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/qftp.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/saxbookmarks.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/desktopservices.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/fridgemagnets.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/softkeys.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/raycasting.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/flickable.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/digiflip.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/lightmaps.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/flightinfo.mif + $$appResourceDir(demos/embedded/fluidlauncher/fluidlauncher.mif) \ + $$appResourceDir(demos/embedded/styledemo/styledemo.mif) \ + $$appResourceDir(demos/deform/deform.mif) \ + $$appResourceDir(demos/pathstroke/pathstroke.mif) \ + $$appResourceDir(examples/widgets/wiggly/wiggly.mif) \ + $$appResourceDir(examples/network/qftp/qftp.mif) \ + $$appResourceDir(examples/xml/saxbookmarks/saxbookmarks.mif) \ + $$appResourceDir(demos/embedded/desktopservices/desktopservices.mif) \ + $$appResourceDir(examples/draganddrop/fridgemagnets/fridgemagnets.mif) \ + $$appResourceDir(examples/widgets/softkeys/softkeys.mif) \ + $$appResourceDir(demos/embedded/raycasting/raycasting.mif) \ + $$appResourceDir(demos/embedded/flickable/flickable.mif) \ + $$appResourceDir(demos/embedded/digiflip/digiflip.mif) \ + $$appResourceDir(demos/embedded/lightmaps/lightmaps.mif) \ + $$appResourceDir(demos/embedded/flightinfo/flightinfo.mif) mifs.path = $$APP_RESOURCE_DIR contains(QT_CONFIG, svg) { executables.sources += \ - embeddedsvgviewer.exe \ - weatherinfo.exe + $$QT_BUILD_TREE/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.exe \ + $$QT_BUILD_TREE/demos/embedded/weatherinfo/weatherinfo.exe reg_resource.sources += \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/embeddedsvgviewer_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/weatherinfo_reg.rsc + $$regResourceDir(demos/embedded/embeddedsvgviewer/embeddedsvgviewer_reg.rsc) \ + $$regResourceDir(demos/embedded/weatherinfo/weatherinfo_reg.rsc) resource.sources += \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/embeddedsvgviewer.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/weatherinfo.rsc + $$appResourceDir(demos/embedded/embeddedsvgviewer/embeddedsvgviewer.rsc) \ + $$appResourceDir(demos/embedded/weatherinfo/weatherinfo.rsc) mifs.sources += \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/embeddedsvgviewer.mif \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/weatherinfo.mif + $$appResourceDir(demos/embedded/embeddedsvgviewer/embeddedsvgviewer.mif) \ + $$appResourceDir(demos/embedded/weatherinfo/weatherinfo.mif) } contains(QT_CONFIG, webkit) { - executables.sources += anomaly.exe - reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/anomaly_reg.rsc - resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/anomaly.rsc + executables.sources += $$QT_BUILD_TREE/demos/embedded/anomaly/anomaly.exe + reg_resource.sources += $$regResourceDir(demos/embedded/anomaly/anomaly_reg.rsc) + resource.sources += $$appResourceDir(demos/embedded/anomaly/anomaly.rsc) mifs.sources += \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/anomaly.mif + $$appResourceDir(demos/embedded/anomaly/anomaly.mif) isEmpty(QT_LIBINFIX) { # Since Fluidlauncher itself doesn't link webkit, we won't get dependency automatically @@ -177,10 +195,10 @@ symbian { } contains(QT_CONFIG, phonon) { - executables.sources += qmediaplayer.exe - resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/qmediaplayer.rsc + executables.sources += $$QT_BUILD_TREE/demos/qmediaplayer/qmediaplayer.exe + resource.sources += $$appResourceDir(demos/qmediaplayer/qmediaplayer.rsc) mifs.sources += \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/qmediaplayer.mif + $$appResourceDir(demos/qmediaplayer/qmediaplayer.mif) } contains(QT_CONFIG, multimedia) { @@ -191,11 +209,21 @@ symbian { } contains(QT_CONFIG, script) { - executables.sources += context2d.exe - reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/context2d_reg.rsc - resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/context2d.rsc + executables.sources += $$QT_BUILD_TREE/examples/script/context2d/context2d.exe + reg_resource.sources += $$regResourceDir(examples/script/context2d/context2d_reg.rsc) + resource.sources += $$appResourceDir(examples/script/context2d/context2d.rsc) mifs.sources += \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/context2d.mif + $$appResourceDir(examples/script/context2d/context2d.mif) + } + + qmldemos = qmlcalculator qmlclocks qmldialcontrol qmleasing qmlflickr qmlphotoviewer qmltwitter + contains(QT_CONFIG, declarative) { + for(qmldemo, qmldemos) { + executables.sources += $$QT_BUILD_TREE/demos/embedded/$${qmldemo}/$${qmldemo}.exe + reg_resource.sources += $$regResourceDir(demos/embedded/$${qmldemo}/$${qmldemo}_reg.rsc) + resource.sources += $$appResourceDir(demos/embedded/$${qmldemo}/$${qmldemo}.rsc) + mifs.sources += $$appResourceDir(demos/embedded/$${qmldemo}/$${qmldemo}.mif) + } } files.sources = $$PWD/screenshots $$PWD/slides @@ -226,6 +254,8 @@ symbian { DEPLOYMENT += config files executables viewerimages saxbookmarks reg_resource resource \ mifs desktopservices_music desktopservices_images fluidbackup + contains(QT_CONFIG, declarative):for(qmldemo, qmldemos):include($$QT_BUILD_TREE/demos/embedded/$${qmldemo}/deployment.pri) + DEPLOYMENT.installer_header = 0xA000D7CD TARGET.EPOCHEAPSIZE = 100000 20000000 diff --git a/demos/embedded/fluidlauncher/screenshots/qmlcalculator.png b/demos/embedded/fluidlauncher/screenshots/qmlcalculator.png Binary files differnew file mode 100644 index 0000000..f4218f5 --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/qmlcalculator.png diff --git a/demos/embedded/fluidlauncher/screenshots/qmlclocks.png b/demos/embedded/fluidlauncher/screenshots/qmlclocks.png Binary files differnew file mode 100644 index 0000000..ba25a18 --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/qmlclocks.png diff --git a/demos/embedded/fluidlauncher/screenshots/qmldialcontrol.png b/demos/embedded/fluidlauncher/screenshots/qmldialcontrol.png Binary files differnew file mode 100644 index 0000000..b8def8c --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/qmldialcontrol.png diff --git a/demos/embedded/fluidlauncher/screenshots/qmleasing.png b/demos/embedded/fluidlauncher/screenshots/qmleasing.png Binary files differnew file mode 100644 index 0000000..d34c2ac --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/qmleasing.png diff --git a/demos/embedded/fluidlauncher/screenshots/qmlflickr.jpg b/demos/embedded/fluidlauncher/screenshots/qmlflickr.jpg Binary files differnew file mode 100644 index 0000000..d7faabf --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/qmlflickr.jpg diff --git a/demos/embedded/fluidlauncher/screenshots/qmlphotoviewer.jpg b/demos/embedded/fluidlauncher/screenshots/qmlphotoviewer.jpg Binary files differnew file mode 100644 index 0000000..673ffc6 --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/qmlphotoviewer.jpg diff --git a/demos/embedded/fluidlauncher/screenshots/qmltwitter.jpg b/demos/embedded/fluidlauncher/screenshots/qmltwitter.jpg Binary files differnew file mode 100644 index 0000000..4399eea --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/qmltwitter.jpg diff --git a/demos/embedded/lightmaps/lightmaps.pro b/demos/embedded/lightmaps/lightmaps.pro index ef1a0a6..ee4cc5a 100644 --- a/demos/embedded/lightmaps/lightmaps.pro +++ b/demos/embedded/lightmaps/lightmaps.pro @@ -5,7 +5,7 @@ QT += network symbian { TARGET.UID3 = 0xA000CF75 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h + INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 diff --git a/demos/embedded/qmlcalculator/deployment.pri b/demos/embedded/qmlcalculator/deployment.pri new file mode 100644 index 0000000..d5078f6 --- /dev/null +++ b/demos/embedded/qmlcalculator/deployment.pri @@ -0,0 +1,7 @@ +qmlcalculator_src = $$PWD/../../declarative/calculator +symbian { + qmlcalculator_uid3 = EA8EBD98 + qmlcalculator_files.path = ../$$qmlcalculator_uid3 +} +qmlcalculator_files.sources = $$qmlcalculator_src/calculator.qml $$qmlcalculator_src/Core +DEPLOYMENT += qmlcalculator_files diff --git a/demos/embedded/qmlcalculator/qmlcalculator.cpp b/demos/embedded/qmlcalculator/qmlcalculator.cpp new file mode 100644 index 0000000..3030e81 --- /dev/null +++ b/demos/embedded/qmlcalculator/qmlcalculator.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** 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$ +** +****************************************************************************/ + +#include <QtCore/QFileInfo> +#include <QtGui/QApplication> +#include <QtDeclarative/QDeclarativeView> + +#if defined(Q_OS_SYMBIAN) +#include <eikenv.h> +#include <eikappui.h> +#include <aknenv.h> +#include <aknappui.h> +#endif // Q_OS_SYMBIAN + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + const QString mainQmlApp = QLatin1String("calculator.qml"); + QDeclarativeView view; + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + +#if defined(QT_KEYPAD_NAVIGATION) + QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); +#endif // QT_KEYPAD_NAVIGATION + +#if defined(Q_OS_SYMBIAN) + CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi()); + TRAPD(error, + if (appUi) + appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait) + ) + view.showFullScreen(); +#else // Q_OS_SYMBIAN + view.show(); +#endif // Q_OS_SYMBIAN + + return application.exec(); +} diff --git a/demos/embedded/qmlcalculator/qmlcalculator.pro b/demos/embedded/qmlcalculator/qmlcalculator.pro new file mode 100644 index 0000000..1e71eed --- /dev/null +++ b/demos/embedded/qmlcalculator/qmlcalculator.pro @@ -0,0 +1,12 @@ +!symbian:!wince*:warning("DEPLOYMENT support required. This project only works on Symbian and WinCE.") + +QT += declarative +SOURCES += $$PWD/qmlcalculator.cpp +include($$PWD/deployment.pri) + +symbian { + TARGET.UID3 = 0x$$qmlcalculator_uid3 # defined in deployment.pri + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 + LIBS += -lcone -leikcore -lavkon # Screen orientation +} diff --git a/demos/embedded/qmlclocks/deployment.pri b/demos/embedded/qmlclocks/deployment.pri new file mode 100644 index 0000000..84803ec --- /dev/null +++ b/demos/embedded/qmlclocks/deployment.pri @@ -0,0 +1,7 @@ +qmlclocks_src = $$PWD/../../../examples/declarative/toys/clocks +symbian { + qmlclocks_uid3 = E19225B9 + qmlclocks_files.path = ../$$qmlclocks_uid3 +} +qmlclocks_files.sources = $$qmlclocks_src/clocks.qml $$qmlclocks_src/content +DEPLOYMENT += qmlclocks_files diff --git a/demos/embedded/qmlclocks/qmlclocks.cpp b/demos/embedded/qmlclocks/qmlclocks.cpp new file mode 100644 index 0000000..d94cbdd --- /dev/null +++ b/demos/embedded/qmlclocks/qmlclocks.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** 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$ +** +****************************************************************************/ + +#include <QtCore/QFileInfo> +#include <QtGui/QApplication> +#include <QtDeclarative/QDeclarativeView> + +#if defined(Q_OS_SYMBIAN) +#include <eikenv.h> +#include <eikappui.h> +#include <aknenv.h> +#include <aknappui.h> +#endif // Q_OS_SYMBIAN + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + const QString mainQmlApp = QLatin1String("clocks.qml"); + QDeclarativeView view; + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + +#if defined(QT_KEYPAD_NAVIGATION) + QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); +#endif // QT_KEYPAD_NAVIGATION + +#if defined(Q_OS_SYMBIAN) + CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi()); + TRAPD(error, + if (appUi) + appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape) + ) + view.showFullScreen(); +#else // Q_OS_SYMBIAN + view.show(); +#endif // Q_OS_SYMBIAN + + return application.exec(); +} diff --git a/demos/embedded/qmlclocks/qmlclocks.pro b/demos/embedded/qmlclocks/qmlclocks.pro new file mode 100644 index 0000000..5edfe14 --- /dev/null +++ b/demos/embedded/qmlclocks/qmlclocks.pro @@ -0,0 +1,12 @@ +!symbian:!wince*:warning("DEPLOYMENT support required. This project only works on Symbian and WinCE.") + +QT += declarative +SOURCES += $$PWD/qmlclocks.cpp +include($$PWD/deployment.pri) + +symbian { + TARGET.UID3 = 0x$$qmlclocks_uid3 # defined in deployment.pri + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 + LIBS += -lcone -leikcore -lavkon # Screen orientation +} diff --git a/demos/embedded/qmldialcontrol/deployment.pri b/demos/embedded/qmldialcontrol/deployment.pri new file mode 100644 index 0000000..8eb39b2 --- /dev/null +++ b/demos/embedded/qmldialcontrol/deployment.pri @@ -0,0 +1,7 @@ +qmldialcontrol_src = $$PWD/../../../examples/declarative/ui-components/dialcontrol +symbian { + qmldialcontrol_uid3 = E59A9283 + qmldialcontrol_files.path = ../$$qmldialcontrol_uid3 +} +qmldialcontrol_files.sources = $$qmldialcontrol_src/dialcontrol.qml $$qmldialcontrol_src/content +DEPLOYMENT += qmldialcontrol_files diff --git a/demos/embedded/qmldialcontrol/qmldialcontrol.cpp b/demos/embedded/qmldialcontrol/qmldialcontrol.cpp new file mode 100644 index 0000000..311cee0 --- /dev/null +++ b/demos/embedded/qmldialcontrol/qmldialcontrol.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** 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$ +** +****************************************************************************/ + +#include <QtCore/QFileInfo> +#include <QtGui/QApplication> +#include <QtDeclarative/QDeclarativeView> + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + const QString mainQmlApp = QLatin1String("dialcontrol.qml"); + QDeclarativeView view; + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + +#if defined(QT_KEYPAD_NAVIGATION) + QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); +#endif // QT_KEYPAD_NAVIGATION + +#if defined(Q_OS_SYMBIAN) + view.showFullScreen(); +#else // Q_OS_SYMBIAN + view.show(); +#endif // Q_OS_SYMBIAN + + return application.exec(); +} diff --git a/demos/embedded/qmldialcontrol/qmldialcontrol.pro b/demos/embedded/qmldialcontrol/qmldialcontrol.pro new file mode 100644 index 0000000..193cf55 --- /dev/null +++ b/demos/embedded/qmldialcontrol/qmldialcontrol.pro @@ -0,0 +1,11 @@ +!symbian:!wince*:warning("DEPLOYMENT support required. This project only works on Symbian and WinCE.") + +QT += declarative +SOURCES += $$PWD/qmldialcontrol.cpp +include($$PWD/deployment.pri) + +symbian { + TARGET.UID3 = 0x$$qmldialcontrol_uid3 # defined in deployment.pri + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} diff --git a/demos/embedded/qmleasing/deployment.pri b/demos/embedded/qmleasing/deployment.pri new file mode 100644 index 0000000..ddab1ba --- /dev/null +++ b/demos/embedded/qmleasing/deployment.pri @@ -0,0 +1,7 @@ +qmleasing_src = $$PWD/../../../examples/declarative/animation/easing +symbian { + qmleasing_uid3 = E8E8E725 + qmleasing_files.path = ../$$qmleasing_uid3 +} +qmleasing_files.sources = $$qmleasing_src/easing.qml +DEPLOYMENT += qmleasing_files diff --git a/demos/embedded/qmleasing/qmleasing.cpp b/demos/embedded/qmleasing/qmleasing.cpp new file mode 100644 index 0000000..d326468 --- /dev/null +++ b/demos/embedded/qmleasing/qmleasing.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** 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$ +** +****************************************************************************/ + +#include <QtCore/QFileInfo> +#include <QtGui/QApplication> +#include <QtDeclarative/QDeclarativeView> + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + const QString mainQmlApp = QLatin1String("easing.qml"); + QDeclarativeView view; + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + +#if defined(QT_KEYPAD_NAVIGATION) + QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); +#endif // QT_KEYPAD_NAVIGATION + +#if defined(Q_OS_SYMBIAN) + view.showFullScreen(); +#else // Q_OS_SYMBIAN + view.show(); +#endif // Q_OS_SYMBIAN + + return application.exec(); +} diff --git a/demos/embedded/qmleasing/qmleasing.pro b/demos/embedded/qmleasing/qmleasing.pro new file mode 100644 index 0000000..084a880 --- /dev/null +++ b/demos/embedded/qmleasing/qmleasing.pro @@ -0,0 +1,11 @@ +!symbian:!wince*:warning("DEPLOYMENT support required. This project only works on Symbian and WinCE.") + +QT += declarative +SOURCES += $$PWD/qmleasing.cpp +include($$PWD/deployment.pri) + +symbian { + TARGET.UID3 = 0x$$qmleasing_uid3 # defined in deployment.pri + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} diff --git a/demos/embedded/qmlflickr/deployment.pri b/demos/embedded/qmlflickr/deployment.pri new file mode 100644 index 0000000..aef3198 --- /dev/null +++ b/demos/embedded/qmlflickr/deployment.pri @@ -0,0 +1,7 @@ +qmlflickr_src = $$PWD/../../declarative/flickr +symbian { + qmlflickr_uid3 = E56D5A92 + qmlflickr_files.path = ../$$qmlflickr_uid3 +} +qmlflickr_files.sources = $$qmlflickr_src/flickr.qml $$qmlflickr_src/common $$qmlflickr_src/mobile +DEPLOYMENT += qmlflickr_files diff --git a/demos/embedded/qmlflickr/qmlflickr.cpp b/demos/embedded/qmlflickr/qmlflickr.cpp new file mode 100644 index 0000000..6f0c528 --- /dev/null +++ b/demos/embedded/qmlflickr/qmlflickr.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** 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$ +** +****************************************************************************/ + +#include <QtCore/QFileInfo> +#include <QtGui/QApplication> +#include <QtDeclarative/QDeclarativeView> +#include <QtDeclarative/QDeclarativeEngine> + +#if defined(Q_OS_SYMBIAN) +#include <QtCore/QTextCodec> +#include <QtCore/QTimer> +#include "sym_iap_util.h" + +class QmlAppView : public QDeclarativeView +{ +Q_OBJECT +public: + QmlAppView(QWidget *parent = 0) + : QDeclarativeView(parent) + { + QTimer::singleShot(0, this, SLOT(setDefaultIap())); + } + +private slots: + void setDefaultIap() + { + qt_SetDefaultIap(); + } +}; +#else // Q_OS_SYMBIAN +typedef QDeclarativeView QmlAppView; +#endif // Q_OS_SYMBIAN + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + const QString mainQmlApp = QLatin1String("flickr.qml"); + QmlAppView view; + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + +#if defined(Q_OS_SYMBIAN) + view.showFullScreen(); +#else // Q_OS_SYMBIAN + view.setGeometry(QRect(100, 100, 360, 640)); + view.show(); +#endif // Q_OS_SYMBIAN + return application.exec(); +} + +#if defined(Q_OS_SYMBIAN) +#include "qmlflickr.moc" +#endif // Q_OS_SYMBIAN diff --git a/demos/embedded/qmlflickr/qmlflickr.pro b/demos/embedded/qmlflickr/qmlflickr.pro new file mode 100644 index 0000000..e706134 --- /dev/null +++ b/demos/embedded/qmlflickr/qmlflickr.pro @@ -0,0 +1,14 @@ +!symbian:!wince*:warning("DEPLOYMENT support required. This project only works on Symbian and WinCE.") + +QT += declarative network +SOURCES += $$PWD/qmlflickr.cpp +include($$PWD/deployment.pri) + +symbian { + TARGET.UID3 = 0x$$qmlflickr_uid3 # defined in deployment.pri + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ + LIBS += -lesock -lcommdb -linsock # For IAP selection + TARGET.CAPABILITY = NetworkServices + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} diff --git a/demos/embedded/qmlphotoviewer/deployment.pri b/demos/embedded/qmlphotoviewer/deployment.pri new file mode 100644 index 0000000..99475cc --- /dev/null +++ b/demos/embedded/qmlphotoviewer/deployment.pri @@ -0,0 +1,7 @@ +qmlphotoviewer_src = $$PWD/../../declarative/photoviewer +symbian { + qmlphotoviewer_uid3 = E8567E72 + qmlphotoviewer_files.path = ../$$qmlphotoviewer_uid3 +} +qmlphotoviewer_files.sources = $$qmlphotoviewer_src/photoviewer.qml $$qmlphotoviewer_src/PhotoViewerCore +DEPLOYMENT += qmlphotoviewer_files diff --git a/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp b/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp new file mode 100644 index 0000000..7889842 --- /dev/null +++ b/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** 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$ +** +****************************************************************************/ + +#include <QtCore/QFileInfo> +#include <QtGui/QApplication> +#include <QtDeclarative/QDeclarativeView> +#include <QtDeclarative/QDeclarativeEngine> + +#if defined(Q_OS_SYMBIAN) +#include <QtCore/QTextCodec> +#include <QtCore/QTimer> +#include "sym_iap_util.h" + +class QmlAppView : public QDeclarativeView +{ +Q_OBJECT +public: + QmlAppView(QWidget *parent = 0) + : QDeclarativeView(parent) + { + QTimer::singleShot(0, this, SLOT(setDefaultIap())); + } + +private slots: + void setDefaultIap() + { + qt_SetDefaultIap(); + } +}; +#else // Q_OS_SYMBIAN +typedef QDeclarativeView QmlAppView; +#endif // Q_OS_SYMBIAN + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + const QString mainQmlApp = QLatin1String("photoviewer.qml"); + QmlAppView view; + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + +#if defined(Q_OS_SYMBIAN) + view.showFullScreen(); +#else // Q_OS_SYMBIAN + view.setGeometry(QRect(100, 100, 360, 640)); + view.show(); +#endif // Q_OS_SYMBIAN + return application.exec(); +} + +#if defined(Q_OS_SYMBIAN) +#include "qmlphotoviewer.moc" +#endif // Q_OS_SYMBIAN diff --git a/demos/embedded/qmlphotoviewer/qmlphotoviewer.pro b/demos/embedded/qmlphotoviewer/qmlphotoviewer.pro new file mode 100644 index 0000000..ead5e67 --- /dev/null +++ b/demos/embedded/qmlphotoviewer/qmlphotoviewer.pro @@ -0,0 +1,14 @@ +!symbian:!wince*:warning("DEPLOYMENT support required. This project only works on Symbian and WinCE.") + +QT += declarative network +SOURCES += $$PWD/qmlphotoviewer.cpp +include($$PWD/deployment.pri) + +symbian { + TARGET.UID3 = 0x$$qmlphotoviewer_uid3 # defined in deployment.pri + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ + LIBS += -lesock -lcommdb -linsock # For IAP selection + TARGET.CAPABILITY = NetworkServices + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} diff --git a/demos/embedded/qmltwitter/deployment.pri b/demos/embedded/qmltwitter/deployment.pri new file mode 100644 index 0000000..e5bd884 --- /dev/null +++ b/demos/embedded/qmltwitter/deployment.pri @@ -0,0 +1,7 @@ +qmltwitter_src = $$PWD/../../declarative/twitter +symbian { + qmltwitter_uid3 = EEF6D468 + qmltwitter_files.path = ../$$qmltwitter_uid3 +} +qmltwitter_files.sources = $$qmltwitter_src/twitter.qml $$qmltwitter_src/TwitterCore +DEPLOYMENT += qmltwitter_files diff --git a/demos/embedded/qmltwitter/qmltwitter.cpp b/demos/embedded/qmltwitter/qmltwitter.cpp new file mode 100644 index 0000000..e30ab24 --- /dev/null +++ b/demos/embedded/qmltwitter/qmltwitter.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** 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$ +** +****************************************************************************/ + +#include <QtCore/QFileInfo> +#include <QtGui/QApplication> +#include <QtDeclarative/QDeclarativeView> +#include <QtDeclarative/QDeclarativeEngine> + +#if defined(Q_OS_SYMBIAN) +#include <QtCore/QTextCodec> +#include <QtCore/QTimer> +#include "sym_iap_util.h" + +class QmlAppView : public QDeclarativeView +{ +Q_OBJECT +public: + QmlAppView(QWidget *parent = 0) + : QDeclarativeView(parent) + { + QTimer::singleShot(0, this, SLOT(setDefaultIap())); + } + +private slots: + void setDefaultIap() + { + qt_SetDefaultIap(); + } +}; +#else // Q_OS_SYMBIAN +typedef QDeclarativeView QmlAppView; +#endif // Q_OS_SYMBIAN + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + + const QString mainQmlApp = QLatin1String("twitter.qml"); + QmlAppView view; + view.setSource(QUrl(mainQmlApp)); + view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + +#if defined(Q_OS_SYMBIAN) + view.showFullScreen(); +#else // Q_OS_SYMBIAN + view.setGeometry(QRect(100, 100, 360, 640)); + view.show(); +#endif // Q_OS_SYMBIAN + return application.exec(); +} + +#if defined(Q_OS_SYMBIAN) +#include "qmltwitter.moc" +#endif // Q_OS_SYMBIAN diff --git a/demos/embedded/qmltwitter/qmltwitter.pro b/demos/embedded/qmltwitter/qmltwitter.pro new file mode 100644 index 0000000..7f9be57 --- /dev/null +++ b/demos/embedded/qmltwitter/qmltwitter.pro @@ -0,0 +1,14 @@ +!symbian:!wince*:warning("DEPLOYMENT support required. This project only works on Symbian and WinCE.") + +QT += declarative network +SOURCES += $$PWD/qmltwitter.cpp +include($$PWD/deployment.pri) + +symbian { + TARGET.UID3 = 0x$$qmltwitter_uid3 # defined in deployment.pri + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ + LIBS += -lesock -lcommdb -linsock # For IAP selection + TARGET.CAPABILITY = NetworkServices + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} diff --git a/demos/embedded/weatherinfo/weatherinfo.cpp b/demos/embedded/weatherinfo/weatherinfo.cpp index 42b685e..3e0226a 100644 --- a/demos/embedded/weatherinfo/weatherinfo.cpp +++ b/demos/embedded/weatherinfo/weatherinfo.cpp @@ -44,10 +44,6 @@ #include <QtNetwork> #include <QtSvg> -#if defined (Q_OS_SYMBIAN) -#include "sym_iap_util.h" -#endif - class WeatherInfo: public QMainWindow { Q_OBJECT @@ -67,6 +63,7 @@ private: QList<QGraphicsTextItem*> m_rangeItems; QTimeLine m_timeLine; QHash<QString, QString> m_icons; + QNetworkAccessManager m_manager; public: WeatherInfo(QWidget *parent = 0): QMainWindow(parent) { @@ -98,14 +95,14 @@ public: } setContextMenuPolicy(Qt::ActionsContextMenu); + connect(&m_manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(handleNetworkData(QNetworkReply*))); + QTimer::singleShot(0, this, SLOT(delayedInit())); } private slots: void delayedInit() { -#if defined(Q_OS_SYMBIAN) - qt_SetDefaultIap(); -#endif request("Oslo"); } @@ -122,7 +119,6 @@ private slots: if (!networkReply->error()) digest(QString::fromUtf8(networkReply->readAll())); networkReply->deleteLater(); - networkReply->manager()->deleteLater(); } void animate(int frame) { @@ -185,10 +181,7 @@ private: url.addEncodedQueryItem("hl", "en"); url.addEncodedQueryItem("weather", QUrl::toPercentEncoding(location)); - QNetworkAccessManager *manager = new QNetworkAccessManager(this); - connect(manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(handleNetworkData(QNetworkReply*))); - manager->get(QNetworkRequest(url)); + m_manager.get(QNetworkRequest(url)); city = QString(); setWindowTitle("Loading..."); diff --git a/demos/embedded/weatherinfo/weatherinfo.pro b/demos/embedded/weatherinfo/weatherinfo.pro index f007bbb..9addbbb 100644 --- a/demos/embedded/weatherinfo/weatherinfo.pro +++ b/demos/embedded/weatherinfo/weatherinfo.pro @@ -7,7 +7,7 @@ QT += network svg symbian { TARGET.UID3 = 0xA000CF77 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h + INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices } diff --git a/demos/interview/model.cpp b/demos/interview/model.cpp index 3f9548a..840bc60 100644 --- a/demos/interview/model.cpp +++ b/demos/interview/model.cpp @@ -45,6 +45,7 @@ Model::Model(int rows, int columns, QObject *parent) : QAbstractItemModel(parent), + services(QPixmap(":/images/services.png")), rc(rows), cc(columns), tree(new QVector<Node>(rows, Node(0))) { @@ -105,7 +106,6 @@ QVariant Model::data(const QModelIndex &index, int role) const QVariant Model::headerData(int section, Qt::Orientation orientation, int role) const { - static QIcon services(QPixmap(":/images/services.png")); if (role == Qt::DisplayRole) return QString::number(section); if (role == Qt::DecorationRole) diff --git a/demos/interview/model.h b/demos/interview/model.h index bad83a8..c7c15f7 100644 --- a/demos/interview/model.h +++ b/demos/interview/model.h @@ -44,6 +44,7 @@ #include <QAbstractItemModel> #include <QFileIconProvider> +#include <QIcon> #include <QVector> class Model : public QAbstractItemModel @@ -80,6 +81,7 @@ private: Node *parent(Node *child) const; int row(Node *node) const; + QIcon services; int rc, cc; QVector<Node> *tree; QFileIconProvider iconProvider; diff --git a/demos/mainwindow/mainwindow.cpp b/demos/mainwindow/mainwindow.cpp index 32066d7..3ddb74b 100644 --- a/demos/mainwindow/mainwindow.cpp +++ b/demos/mainwindow/mainwindow.cpp @@ -329,7 +329,7 @@ void MainWindow::setupDockWidgets(const QMap<QString, QSize> &customSizeHints) BlueTitleBar *titlebar = new BlueTitleBar(swatch); swatch->setTitleBarWidget(titlebar); connect(swatch, SIGNAL(topLevelChanged(bool)), titlebar, SLOT(updateMask())); - connect(swatch, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)), titlebar, SLOT(updateMask())); + connect(swatch, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)), titlebar, SLOT(updateMask()), Qt::QueuedConnection); #ifdef Q_WS_QWS QPalette pal = palette(); diff --git a/demos/pathstroke/main.cpp b/demos/pathstroke/main.cpp index 1465682..534b233 100644 --- a/demos/pathstroke/main.cpp +++ b/demos/pathstroke/main.cpp @@ -48,10 +48,7 @@ int main(int argc, char **argv) QApplication app(argc, argv); - bool smallScreen = false; - for (int i=0; i<argc; i++) - if (QString(argv[i]) == "-small-screen") - smallScreen = true; + bool smallScreen = QApplication::arguments().contains("-small-screen"); PathStrokeWidget pathStrokeWidget(smallScreen); QStyle *arthurStyle = new ArthurStyle(); diff --git a/demos/qtdemo/colors.cpp b/demos/qtdemo/colors.cpp index 802d77d..b352e3d 100644 --- a/demos/qtdemo/colors.cpp +++ b/demos/qtdemo/colors.cpp @@ -81,6 +81,7 @@ bool Colors::noRescale = false; bool Colors::noAnimations = false; bool Colors::noBlending = false; bool Colors::noScreenSync = false; +bool Colors::noBlur = true; bool Colors::fullscreen = false; bool Colors::usePixmaps = false; bool Colors::useLoop = false; @@ -232,6 +233,8 @@ void Colors::parseArgs(int argc, char *argv[]) Colors::showFps = true; else if (s == "-no-blending") Colors::noBlending = true; + else if (s == "-use-blur") + Colors::noBlur = false; else if (s == "-no-sync") Colors::noScreenSync = true; else if (s.startsWith("-menu")) @@ -267,7 +270,7 @@ void Colors::parseArgs(int argc, char *argv[]) else if (s.startsWith("-h") || s.startsWith("-help")){ QMessageBox::warning(0, "Arguments", QString("Usage: qtdemo [-verbose] [-no-adapt] [-opengl] [-software] [-fullscreen] [-ticker[0|1]] ") - + "[-animations[0|1]] [-no-blending] [-no-sync] [-use-timer-update[0|1]] [-pause[0|1]] " + + "[-animations[0|1]] [-no-blending] [-use-blur] [-no-sync] [-use-timer-update[0|1]] [-pause[0|1]] " + "[-use-window-mask] [-no-rescale] " + "[-use-pixmaps] [-show-fps] [-show-br] [-8bit[0|1]] [-menu<int>] [-use-loop] [-use-balls] " + "[-animation-speed<float>] [-fps<int>] " @@ -295,6 +298,7 @@ void Colors::setLowSettings() Colors::usePixmaps = true; Colors::noAnimations = true; Colors::noBlending = true; + Colors::noBlur = true; } void Colors::detectSystemResources() diff --git a/demos/qtdemo/colors.h b/demos/qtdemo/colors.h index 1e0b795..2d58058 100644 --- a/demos/qtdemo/colors.h +++ b/demos/qtdemo/colors.h @@ -91,6 +91,7 @@ public: static bool noAnimations; static bool noBlending; static bool noScreenSync; + static bool noBlur; static bool useLoop; static bool noWindowMask; static bool usePixmaps; diff --git a/demos/qtdemo/mainwindow.cpp b/demos/qtdemo/mainwindow.cpp index a679c4f..753014a 100644 --- a/demos/qtdemo/mainwindow.cpp +++ b/demos/qtdemo/mainwindow.cpp @@ -266,12 +266,14 @@ void MainWindow::setupSceneItems() { if (Colors::showFps){ this->fpsLabel = new DemoTextItem(QString("FPS: --"), Colors::buttonFont(), Qt::white, -1, this->scene, 0, DemoTextItem::DYNAMIC_TEXT); - this->fpsLabel->setZValue(100); + this->fpsLabel->setZValue(1000); this->fpsLabel->setPos(Colors::stageStartX, 600 - QFontMetricsF(Colors::buttonFont()).height() - 5); } - this->companyLogo = new ImageItem(QImage(":/images/trolltech-logo.png"), 1000, 1000, this->scene, 0, true, 0.5f); - this->qtLogo = new ImageItem(QImage(":/images/qtlogo_small.png"), 1000, 1000, this->scene, 0, true, 0.5f); + this->mainSceneRoot = new QGraphicsWidget(); + this->scene->addItem(mainSceneRoot); + this->companyLogo = new ImageItem(QImage(":/images/trolltech-logo.png"), 1000, 1000, this->scene, mainSceneRoot, true, 0.5f); + this->qtLogo = new ImageItem(QImage(":/images/qtlogo_small.png"), 1000, 1000, this->scene, mainSceneRoot, true, 0.5f); this->companyLogo->setZValue(100); this->qtLogo->setZValue(100); this->pausedLabel = new DemoTextItem(QString("PAUSED"), Colors::buttonFont(), Qt::white, -1, this->scene, 0); @@ -308,6 +310,14 @@ void MainWindow::checkAdapt() qDebug() << "- benchmark adaption: removed ticker (fps < 30)"; } + //Note: Because we don't adapt later in the program, if blur makes FPS plummet then we won't catch it + if (!Colors::noBlur && MenuManager::instance()->declarativeEngine && this->mainSceneRoot){ + Colors::noBlur = true; + MenuManager::instance()->declarativeEngine->rootContext()->setContextProperty("useBlur", false); + if (Colors::verbose) + qDebug() << "- benchmark adaption: removed blur (fps < 30)"; + } + if (this->fpsMedian < 20){ Colors::noAnimations = true; if (Colors::verbose) @@ -376,7 +386,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) this->loop = false; QApplication::quit(); } - else if (event->key() == Qt::Key_1){ + else if (event->key() == Qt::Key_F1){ QString s(""); s += "Rendering system: "; if (Colors::openGlRendering) @@ -415,6 +425,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) s += Colors::noScreenSync ? "no" : "yes"; QMessageBox::information(0, QString("Current configuration"), s); } + QGraphicsView::keyPressEvent(event); } void MainWindow::focusInEvent(QFocusEvent *) diff --git a/demos/qtdemo/mainwindow.h b/demos/qtdemo/mainwindow.h index edcc146..e613268 100644 --- a/demos/qtdemo/mainwindow.h +++ b/demos/qtdemo/mainwindow.h @@ -43,6 +43,7 @@ #define MAIN_WINDOW_H #include <QtGui> +#include <QtDeclarative> #include <QPixmap> class DemoTextItem; @@ -62,6 +63,8 @@ public: void start(); QGraphicsScene *scene; + QGraphicsWidget* mainSceneRoot; + bool loop; // FPS stuff: diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp index 40af30f..a2ceb0e 100644 --- a/demos/qtdemo/menumanager.cpp +++ b/demos/qtdemo/menumanager.cpp @@ -152,6 +152,9 @@ void MenuManager::itemSelected(int userCode, const QString &menuName) case LAUNCH: this->launchExample(this->currentInfo); break; + case LAUNCH_QML: + this->launchQmlExample(this->currentInfo); + break; case DOCUMENTATION: this->showDocInAssistant(this->currentInfo); break; @@ -169,6 +172,8 @@ void MenuManager::itemSelected(int userCode, const QString &menuName) this->score->queueMovie(this->currentInfo + " -out"); this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY); this->score->queueMovie("back -out", Score::ONLY_IF_VISIBLE); + if(qmlRoot) + qmlRoot->setProperty("show", QVariant(false)); // book-keeping: this->currentMenuCode = ROOT; this->currentMenu = menuName + " -menu1"; @@ -191,6 +196,8 @@ void MenuManager::itemSelected(int userCode, const QString &menuName) this->score->queueMovie(this->currentMenu + " -out", Score::FROM_START, Score::LOCK_ITEMS); this->score->queueMovie(this->currentMenuButtons + " -out", Score::FROM_START, Score::LOCK_ITEMS); this->score->queueMovie(this->currentInfo + " -out"); + if(qmlRoot) + qmlRoot->setProperty("show", QVariant(false)); // book-keeping: this->currentMenuCode = MENU1; this->currentCategory = menuName; @@ -208,6 +215,8 @@ void MenuManager::itemSelected(int userCode, const QString &menuName) // out: this->score->queueMovie(this->currentInfo + " -out", Score::NEW_ANIMATION_ONLY); this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY); + if(qmlRoot) + qmlRoot->setProperty("show", QVariant(false)); // book-keeping: this->currentMenuCode = MENU2; this->currentInfo = menuName; @@ -242,6 +251,8 @@ void MenuManager::itemSelected(int userCode, const QString &menuName) // out: this->score->queueMovie(this->currentInfo + " -out", Score::NEW_ANIMATION_ONLY); this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY); + if(qmlRoot) + qmlRoot->setProperty("show", QVariant(false)); // book-keeping: this->currentMenuCode = MENU1; this->currentMenuButtons = this->currentCategory + " -buttons"; @@ -343,6 +354,47 @@ void MenuManager::launchExample(const QString &name) #endif } +void MenuManager::launchQmlExample(const QString &name) +{ + if(!qmlRoot){ + exampleError(QProcess::UnknownError); + return; + } + //resolveQmlFilename - refactor to separate fn? + QString dirName = this->info[name]["dirname"]; + QString category = this->info[name]["category"]; + QString fileName = this->info[name]["filename"]; + QDir dir; + if (category == "demos") + dir = QDir(QLibraryInfo::location(QLibraryInfo::DemosPath)); + else + dir = QDir(QLibraryInfo::location(QLibraryInfo::ExamplesPath)); + QFile file(dir.path() + "/" + dirName + "/" + fileName + "/" + fileName.split('/').last() + ".qml"); + if(!file.exists()){ + //try main.qml as well + file.setFileName(dir.path() + "/" + dirName + "/" + fileName + "/" + "main.qml"); + if(!file.exists()){ + exampleError(QProcess::UnknownError); + return; + } + } + if(!Colors::noBlur){ + QImage qmlBgImage(this->window->rect().size(), QImage::Format_ARGB32_Premultiplied); + QPainter painter(&qmlBgImage); + if(Colors::showFps) + this->window->fpsLabel->setOpacity(0); + this->window->render(&painter); + if(Colors::showFps) + this->window->fpsLabel->setOpacity(1.0); + Qt::ImageConversionFlags convFlags = Qt::AvoidDither | Qt::NoOpaqueDetection; + this->declarativeEngine->rootContext()->setContextProperty("bgAppPixmap", QVariant(QPixmap::fromImage(qmlBgImage, convFlags))); + } + + qmlRoot->setProperty("qmlFile", QVariant(""));//unload component + qmlRoot->setProperty("show", QVariant(true)); + qmlRoot->setProperty("qmlFile", QUrl::fromLocalFile(file.fileName())); +} + void MenuManager::exampleFinished() { } @@ -385,6 +437,40 @@ void MenuManager::init(MainWindow *window) level2MenuNode = level2MenuNode.nextSibling(); } + + // Create QML Loader + qmlRegisterType<QGraphicsBlurEffect>("Effects", 1, 0, "Blur"); + qmlRegisterType<QGraphicsDropShadowEffect>("Effects", 1, 0, "DropShadow"); + declarativeEngine = new QDeclarativeEngine(this); + + // Note that we paint the background into a static image for a theorized performance improvement when blurring + // It has not yet been determined what, if any, speed up this gives (but is left in 'cause the QML expects it now) + declarativeEngine->rootContext()->setContextProperty("useBlur", !Colors::noBlur); + QImage qmlBgImage(this->window->rect().size(), QImage::Format_ARGB32_Premultiplied); + qmlBgImage.fill(0); + this->declarativeEngine->rootContext()->setContextProperty("bgAppPixmap", QVariant(QPixmap::fromImage(qmlBgImage))); + + QDeclarativeComponent component(declarativeEngine, QUrl("qrc:qml/qmlShell.qml"), this); + qmlRoot = 0; + if(component.isReady()) + qmlRoot = qobject_cast<QDeclarativeItem*>(component.create()); + else + qDebug() << component.status() << component.errorString(); + if(qmlRoot){ + qmlRoot->setHeight(this->window->scene->sceneRect().height()); + qmlRoot->setWidth(this->window->scene->sceneRect().width()); + qmlRoot->setZValue(101);//Above other items + qmlRoot->setCursor(Qt::ArrowCursor); + window->scene->addItem(qmlRoot); + + //Note that QML adds key handling to the app. + window->viewport()->setFocusPolicy(Qt::NoFocus);//Correct keyboard focus handling + window->setFocusPolicy(Qt::StrongFocus); + window->scene->setStickyFocus(true); + window->setFocus(); + }else{ + qDebug() << "Error intializing QML subsystem, Declarative examples will not work"; + } } void MenuManager::readInfoAboutExample(const QDomElement &example) @@ -392,13 +478,14 @@ void MenuManager::readInfoAboutExample(const QDomElement &example) QString name = example.attribute("name"); if (this->info.contains(name)) qWarning() << "__WARNING: MenuManager::readInfoAboutExample: Demo/example with name" - << name << "appears twize in the xml-file!__"; + << name << "appears twice in the xml-file!__"; this->info[name]["filename"] = example.attribute("filename"); this->info[name]["category"] = example.parentNode().toElement().tagName(); this->info[name]["dirname"] = example.parentNode().toElement().attribute("dirname"); this->info[name]["changedirectory"] = example.attribute("changedirectory"); this->info[name]["image"] = example.attribute("image"); + this->info[name]["qml"] = example.attribute("qml"); } QString MenuManager::resolveDataDir(const QString &name) @@ -454,7 +541,7 @@ QString MenuManager::resolveDocUrl(const QString &name) QString fileName = this->info[name]["filename"]; if (category == "demos") - return this->helpRootUrl + "demos-" + fileName + ".html"; + return this->helpRootUrl + "demos-" + fileName.replace("/", "-") + ".html"; else return this->helpRootUrl + dirName.replace("/", "-") + "-" + fileName + ".html"; } @@ -474,6 +561,9 @@ QByteArray MenuManager::getImage(const QString &name) QString imageName = this->info[name]["image"]; QString category = this->info[name]["category"]; QString fileName = this->info[name]["filename"]; + bool qml = (this->info[name]["qml"] == QLatin1String("true")); + if(qml) + fileName = QLatin1String("qml-") + fileName.split('/').last(); if (imageName.isEmpty()){ if (category == "demos") @@ -493,7 +583,7 @@ void MenuManager::createRootMenu(const QDomElement &el) { QString name = el.attribute("name"); createMenu(el, MENU1); - createInfo(new MenuContentItem(el, this->window->scene, 0), name + " -info"); + createInfo(new MenuContentItem(el, this->window->scene, this->window->mainSceneRoot), name + " -info"); Movie *menuButtonsIn = this->score->insertMovie(name + " -buttons"); Movie *menuButtonsOut = this->score->insertMovie(name + " -buttons -out"); @@ -505,19 +595,21 @@ void MenuManager::createSubMenu(const QDomElement &el) { QString name = el.attribute("name"); createMenu(el, MENU2); - createInfo(new MenuContentItem(el, this->window->scene, 0), name + " -info"); + createInfo(new MenuContentItem(el, this->window->scene, this->window->mainSceneRoot), name + " -info"); } void MenuManager::createLeafMenu(const QDomElement &el) { QString name = el.attribute("name"); - createInfo(new ExampleContent(name, this->window->scene, 0), name); + createInfo(new ExampleContent(name, this->window->scene, this->window->mainSceneRoot), name); Movie *infoButtonsIn = this->score->insertMovie(name + " -buttons"); Movie *infoButtonsOut = this->score->insertMovie(name + " -buttons -out"); createLowRightLeafButton("Documentation", 600, DOCUMENTATION, infoButtonsIn, infoButtonsOut, 0); if (el.attribute("executable") != "false") createLowRightLeafButton("Launch", 405, LAUNCH, infoButtonsIn, infoButtonsOut, 0); + else if(el.attribute("qml") == "true") + createLowRightLeafButton("Display", 405, LAUNCH_QML, infoButtonsIn, infoButtonsOut, 0); } void MenuManager::createMenu(const QDomElement &category, BUTTON_TYPE type) @@ -546,7 +638,7 @@ void MenuManager::createMenu(const QDomElement &category, BUTTON_TYPE type) // create normal menu button QString label = currentNode.toElement().attribute("name"); - item = new TextButton(label, TextButton::LEFT, type, this->window->scene, 0); + item = new TextButton(label, TextButton::LEFT, type, this->window->scene, this->window->mainSceneRoot); currentNode = currentNode.nextSibling(); #ifndef QT_OPENGL_SUPPORT @@ -646,7 +738,7 @@ void MenuManager::createMenu(const QDomElement &category, BUTTON_TYPE type) void MenuManager::createLowLeftButton(const QString &label, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie *movieShake, const QString &menuString) { - TextButton *button = new TextButton(label, TextButton::RIGHT, type, this->window->scene, 0, TextButton::PANEL); + TextButton *button = new TextButton(label, TextButton::RIGHT, type, this->window->scene, this->window->mainSceneRoot, TextButton::PANEL); if (!menuString.isNull()) button->setMenuString(menuString); button->setRecursiveVisible(false); @@ -688,7 +780,7 @@ void MenuManager::createLowLeftButton(const QString &label, BUTTON_TYPE type, void MenuManager::createLowRightButton(const QString &label, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie * /*movieShake*/) { - TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, 0, TextButton::PANEL); + TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, this->window->mainSceneRoot, TextButton::PANEL); item->setRecursiveVisible(false); item->setZValue(10); @@ -715,7 +807,7 @@ void MenuManager::createLowRightButton(const QString &label, BUTTON_TYPE type, M void MenuManager::createLowRightLeafButton(const QString &label, int xOffset, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie * /*movieShake*/) { - TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, 0, TextButton::PANEL); + TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, this->window->mainSceneRoot, TextButton::PANEL); item->setRecursiveVisible(false); item->setZValue(10); @@ -831,12 +923,12 @@ void MenuManager::createUpnDownButtons() float xOffset = 15.0f; float yOffset = 450.0f; - this->upButton = new TextButton("", TextButton::LEFT, MenuManager::UP, this->window->scene, 0, TextButton::UP); + this->upButton = new TextButton("", TextButton::LEFT, MenuManager::UP, this->window->scene, this->window->mainSceneRoot, TextButton::UP); this->upButton->prepare(); this->upButton->setPos(xOffset, yOffset); this->upButton->setState(TextButton::DISABLED); - this->downButton = new TextButton("", TextButton::LEFT, MenuManager::DOWN, this->window->scene, 0, TextButton::DOWN); + this->downButton = new TextButton("", TextButton::LEFT, MenuManager::DOWN, this->window->scene, this->window->mainSceneRoot, TextButton::DOWN); this->downButton->prepare(); this->downButton->setPos(xOffset + 10 + this->downButton->sceneBoundingRect().width(), yOffset); diff --git a/demos/qtdemo/menumanager.h b/demos/qtdemo/menumanager.h index ff98341..5e14204 100644 --- a/demos/qtdemo/menumanager.h +++ b/demos/qtdemo/menumanager.h @@ -61,7 +61,7 @@ class MenuManager : public QObject Q_OBJECT public: - enum BUTTON_TYPE {ROOT, MENU1, MENU2, LAUNCH, DOCUMENTATION, QUIT, FULLSCREEN, UP, DOWN, BACK}; + enum BUTTON_TYPE {ROOT, MENU1, MENU2, LAUNCH, DOCUMENTATION, QUIT, FULLSCREEN, UP, DOWN, BACK, LAUNCH_QML}; // singleton pattern: static MenuManager *instance(); @@ -83,6 +83,9 @@ public: Score *score; int currentMenuCode; + QDeclarativeEngine* declarativeEngine; + QDeclarativeItem *qmlRoot; + private slots: void exampleFinished(); void exampleError(QProcess::ProcessError error); @@ -100,6 +103,7 @@ private: void readInfoAboutExample(const QDomElement &example); void showDocInAssistant(const QString &docFile); void launchExample(const QString &uniqueName); + void launchQmlExample(const QString &uniqueName); void createMenu(const QDomElement &category, BUTTON_TYPE type); void createLowLeftButton(const QString &label, BUTTON_TYPE type, @@ -128,6 +132,7 @@ private: TextButton *upButton; TextButton *downButton; + }; #endif // MENU_MANAGER_H diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml new file mode 100644 index 0000000..b1ee79a --- /dev/null +++ b/demos/qtdemo/qmlShell.qml @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** 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 Qt 4.7 +import Effects 1.0 + +/* Vars exposed from C++ + pixmap bgAppPixmap + bool useBlur (to turn on, pass -use-blur on the cmd line. Off by default 'cause it's too slow) +*/ +Item { + id: main + //height and width set by program to fill window + //below properties are sometimes set from C++ + property url qmlFile: '' + property bool show: false + Image{ + id: bg + opacity: 0 + anchors.fill: parent + z: -1 + pixmap: bgAppPixmap + effect: Blur { id: blurEffect; enabled: useBlur; blurRadius: 8;} + } + + Item{ id:embeddedViewer + width: parent.width + height: parent.height + opacity: 0; + z: 10 + Loader{ + id: loader + z: 10 + focus: true //Automatic FocusScope + clip: true + source: qmlFile + anchors.centerIn: parent + onStatusChanged: if(status == Loader.Ready) { + if(loader.item.width > 640) + loader.item.width = 640; + if(loader.item.height > 480) + loader.item.height = 480; + } + + } + Rectangle{ id: frame + z: 9 + anchors.fill: loader.status == Loader.Ready ? loader : errorTxt + anchors.margins: -8 + radius: 4 + smooth: true + border.color: "#88aaaaaa" + gradient: Gradient{ + GradientStop{ position: 0.0; color: "#14FFFFFF" } + GradientStop{ position: 1.0; color: "#5AFFFFFF" } + } + MouseArea{ + anchors.fill: parent + onClicked: loader.focus=true;/* and don't propogate to the 'exit' area*/ + } + + Rectangle{ id: innerFrame + anchors.margins: 7 + anchors.bottomMargin: 8 + anchors.rightMargin: 8 + color: "black" + border.color: "#44000000" + anchors.fill:parent + } + + effect: DropShadow { + enabled: useBlur; + blurRadius: 9; + color: "#88000000"; + xOffset:0 + yOffset:0 + } + } + + Text{ + id: errorTxt + z: 10 + anchors.centerIn: parent + color: 'white' + smooth: true + visible: loader.status == Loader.Error + textFormat: Text.RichText + //Note that if loader is Error, it is because the file was found but there was an error creating the component + //This means either we have a bug in our demos, or the required modules (which ship with Qt) did not deploy correctly + text: "The example has failed to load.<br />If you installed Qt's QML modules this is a bug!<br />" + + 'Report it at <a href="http://bugreports.qt.nokia.com">http://bugreports.qt.nokia.com</a>'; + onLinkActivated: Qt.openUrlExternally(link); + } + } + Rectangle{ id: blackout //Maybe use a colorize effect instead? + z: 8 + anchors.fill: parent + color: "#000000" + opacity: 0 + } + MouseArea{ + z: 8 + enabled: main.show + hoverEnabled: true //To steal focus from the buttons + anchors.fill: parent + onClicked: main.show=false; + } + + states: [ + State { + name: "show" + when: show == true + PropertyChanges { + target: embeddedViewer + opacity: 1 + } + PropertyChanges { + target: bg + opacity: 1 + } + PropertyChanges { + target: blackout + opacity: 0.5 + } + } + ] + transitions: [//Should not be too long, because the component has already started running + Transition { from: ''; to: "show"; reversible: true + SequentialAnimation{ + PropertyAction { target: bg; property: useBlur?"y":"opacity";}//fade in blurred background only if blurred + NumberAnimation{ properties: "opacity"; easing.type: Easing.InQuad; duration: 500} + PropertyAction { target: loader; property: "focus"; value: true}//Might be needed to ensure the focus stays with us + } + } + ] +} diff --git a/demos/qtdemo/qtdemo.pro b/demos/qtdemo/qtdemo.pro index 011ea0c..4d4177e 100644 --- a/demos/qtdemo/qtdemo.pro +++ b/demos/qtdemo/qtdemo.pro @@ -3,12 +3,10 @@ TARGET = qtdemo DEMO_DESTDIR = $$QT_BUILD_TREE isEmpty(DEMO_DESTDIR):DEMO_DESTDIR=../.. DESTDIR = $$DEMO_DESTDIR/bin -OBJECTS_DIR = .obj -MOC_DIR = .moc INSTALLS += target sources -QT += xml network +QT += xml network declarative contains(QT_CONFIG, opengl) { DEFINES += QT_OPENGL_SUPPORT @@ -76,3 +74,5 @@ target.path = $$[QT_INSTALL_BINS] sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES qtdemo.pro images xml *.ico *.icns *.rc *.plist sources.path = $$[QT_INSTALL_DEMOS]/qtdemo +OTHER_FILES += \ + qmlShell.qml diff --git a/demos/qtdemo/qtdemo.qrc b/demos/qtdemo/qtdemo.qrc index b30dd58..c18420f 100644 --- a/demos/qtdemo/qtdemo.qrc +++ b/demos/qtdemo/qtdemo.qrc @@ -1,8 +1,11 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/"> - <file>xml/examples.xml</file> - <file>images/qtlogo_small.png</file> - <file>images/trolltech-logo.png</file> - <file>images/demobg.png</file> -</qresource> +<RCC> + <qresource prefix="/"> + <file>xml/examples.xml</file> + <file>images/qtlogo_small.png</file> + <file>images/trolltech-logo.png</file> + <file>images/demobg.png</file> + </qresource> + <qresource prefix="/qml" lang="qml"> + <file>qmlShell.qml</file> + </qresource> </RCC> diff --git a/demos/qtdemo/xml/examples.xml b/demos/qtdemo/xml/examples.xml index 9121861..0ab048e 100644 --- a/demos/qtdemo/xml/examples.xml +++ b/demos/qtdemo/xml/examples.xml @@ -1,25 +1,32 @@ <?xml version="1.0" encoding="iso-8859-1"?> <categories name="Qt Examples and Demos"> <demos dirname="." docname="demos" name="Demonstrations"> + <example filename="declarative/samegame" name="SameGame" executable="false" qml="true"/> + <example filename="declarative/flickr" name="Flickr Client" executable="false" qml="true"/> <example filename="affine" name="Affine Transformations" /> - <example filename="arthurplugin" name="Arthur Plugin" executable="false" /> <example filename="composition" name="Composition Modes" /> <example filename="gradients" name="Gradients" /> <example filename="pathstroke" name="Path Stroking" /> - <example filename="deform" name="Vector Deformation" /> - <example filename="books" name="Books" /> - <example filename="mainwindow" name="Main Window" /> - <example filename="spreadsheet" name="Spreadsheet" /> - <example filename="sqlbrowser" name="SQL Browser" /> <example filename="textedit" name="Text Edit" /> <example filename="chip" name="40000 Chips" /> <example filename="embeddeddialogs" name="Embedded Dialogs" /> <example filename="interview" name="Interview" /> + <example filename="declarative/rssnews" name="Rss Client" executable="false" qml="true"/> + <example filename="declarative/twitter" name="Twitter Client" executable="false" qml="true"/> <example filename="browser" name="Browser" /> <example filename="qmediaplayer" name="Media Player" /> <example filename="boxes" name="Boxes" /> <example filename="sub-attaq" name="Sub-attaq" /> <example filename="spectrum" name="Spectrum Analyzer" /> + <example filename="declarative/minehunt" name="Minehunt" executable="false" qml="true"/> + <example filename="declarative/snake" name="Snake" executable="false" qml="true"/> + <example filename="deform" name="Vector Deformation" /> + <example filename="books" name="Books" /> + <example filename="mainwindow" name="Main Window" /> + <example filename="spreadsheet" name="Spreadsheet" /> + <example filename="sqlbrowser" name="SQL Browser" /> + <example filename="arthurplugin" name="Arthur Plugin" executable="false" /> + </demos> <category dirname="animation" name="Animation Framework"> <example filename="animatedtiles" name="Animated Tiles" /> @@ -35,6 +42,13 @@ <example filename="runfunction" name="Run Function" executable="false"/> <example filename="wordcount" name="Word Count" executable="false" /> </category> + <category dirname="declarative/toys" name="Qt Declarative Examples"> + <example filename="dynamicscene" name="Dynamic Scene" executable="false" qml="true" /> + <example filename="tic-tac-toe" name="Tic Tac Toe" executable="false" qml="true" /> + <example filename="clocks" name="Clocks" executable="false" qml="true" /> + <example filename="corkboards" name="Corkboards" executable="false" qml="true" /> + <example filename="tvtennis" name="TV Tennis" executable="false" qml="true" /> + </category> <category dirname="designer" name="Qt Designer"> <example filename="calculatorbuilder" name="Calculator Builder" /> <example filename="calculatorform" name="Calculator Form" /> @@ -116,6 +130,16 @@ <example filename="menus" name="Menus" /> <example filename="recentfiles" name="Recent Files" /> </category> + <category dirname="declarative/ui-components" name="QML UI Components"> + <example filename="dialcontrol" name="Dial" executable="false" qml="true" /> + <example filename="flipable" name="Flipable" executable="false" qml="true" /> + <example filename="progressbar" name="Progress bar" executable="false" qml="true" /> + <example filename="scrollbar" name="Scroll bar" executable="false" qml="true" /> + <example filename="searchbox" name="Search box" executable="false" qml="true" /> + <example filename="slideswitch" name="Slide switch" executable="false" qml="true" /> + <example filename="spinner" name="Spinner" executable="false" qml="true" /> + <example filename="tabwidget" name="Tab widget" executable="false" qml="true" /> + </category> <category dirname="network" name="Networking"> <example filename="blockingfortuneclient" name="Blocking Fortune Client" /> <example filename="broadcastreceiver" name="Broadcast Receiver" /> diff --git a/demos/shared/shared.pri b/demos/shared/shared.pri index 1541fa7..fb7b04c 100644 --- a/demos/shared/shared.pri +++ b/demos/shared/shared.pri @@ -6,12 +6,12 @@ build_all:!build_pass { } contains(CONFIG, debug_and_release_target) { CONFIG(debug, debug|release) { - LIBS+=-L$$SHARED_FOLDER/debug + QMAKE_LIBDIR += $$SHARED_FOLDER/debug } else { - LIBS+=-L$$SHARED_FOLDER/release + QMAKE_LIBDIR += $$SHARED_FOLDER/release } } else { - LIBS += -L$$SHARED_FOLDER + QMAKE_LIBDIR += $$SHARED_FOLDER } hpux-acc*:LIBS += $$SHARED_FOLDER/libdemo_shared.a diff --git a/demos/spectrum/app/app.pro b/demos/spectrum/app/app.pro index db9a144..c4b0943 100644 --- a/demos/spectrum/app/app.pro +++ b/demos/spectrum/app/app.pro @@ -57,6 +57,7 @@ symbian { symbian { # Must explicitly add the .dll suffix to ensure dynamic linkage LIBS += -lfftreal.dll + QMAKE_LIBDIR += $${fftreal_dir} } else { macx { # Link to fftreal framework diff --git a/demos/spectrum/app/engine.h b/demos/spectrum/app/engine.h index ab5ae0d..b6fe3ed 100644 --- a/demos/spectrum/app/engine.h +++ b/demos/spectrum/app/engine.h @@ -65,7 +65,6 @@ #endif class FrequencySpectrum; - QT_FORWARD_DECLARE_CLASS(QAudioInput) QT_FORWARD_DECLARE_CLASS(QAudioOutput) QT_FORWARD_DECLARE_CLASS(QFile) diff --git a/demos/spectrum/app/mainwidget.h b/demos/spectrum/app/mainwidget.h index ddab8b7..b3dc352 100644 --- a/demos/spectrum/app/mainwidget.h +++ b/demos/spectrum/app/mainwidget.h @@ -59,6 +59,7 @@ QT_FORWARD_DECLARE_CLASS(QLabel) QT_FORWARD_DECLARE_CLASS(QPushButton) QT_FORWARD_DECLARE_CLASS(QMenu) QT_FORWARD_DECLARE_CLASS(QAction) +QT_END_NAMESPACE /** * Main application widget, responsible for connecting the various UI diff --git a/demos/spreadsheet/spreadsheet.cpp b/demos/spreadsheet/spreadsheet.cpp index 9693f3c..f2a1738 100644 --- a/demos/spreadsheet/spreadsheet.cpp +++ b/demos/spreadsheet/spreadsheet.cpp @@ -70,6 +70,7 @@ SpreadSheet::SpreadSheet(int rows, int cols, QWidget *parent) updateColor(0); setupMenuBar(); setupContents(); + setupContextMenu(); setCentralWidget(table); statusBar(); diff --git a/demos/sqlbrowser/browser.cpp b/demos/sqlbrowser/browser.cpp index 1232428..fe699c7 100644 --- a/demos/sqlbrowser/browser.cpp +++ b/demos/sqlbrowser/browser.cpp @@ -242,6 +242,6 @@ void Browser::updateActions() void Browser::about() { QMessageBox::about(this, tr("About"), tr("The SQL Browser demonstration " - "show how a data browser can be used to visualize the results of SQL" + "shows how a data browser can be used to visualize the results of SQL" "statements on a live database")); } |