diff options
Diffstat (limited to 'examples')
21 files changed, 196 insertions, 179 deletions
diff --git a/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir b/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir index 1028590..6be88bc 100644 --- a/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir +++ b/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir @@ -1,2 +1,2 @@ -plugin imageprovider +plugin qmlimageproviderplugin diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/cppextensions/imageprovider/imageprovider.pro index 945a301..f218c30 100644 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.pro +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.pro @@ -1,12 +1,10 @@ TEMPLATE = lib -TARGET = imageprovider -QT += declarative CONFIG += qt plugin +QT += declarative -TARGET = $$qtLibraryTarget($$TARGET) DESTDIR = ImageProviderCore +TARGET = qmlimageproviderplugin -# Input SOURCES += imageprovider.cpp sources.files = $$SOURCES imageprovider.qml imageprovider.pro @@ -18,8 +16,14 @@ ImageProviderCore_sources.files = \ ImageProviderCore/qmldir ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider/ImageProviderCore +INSTALLS = sources ImageProviderCore_sources target + symbian:{ - TARGET.EPOCALLOWDLLDATA=1 -} + load(data_caging_paths) + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.EPOCALLOWDLLDATA = 1 -INSTALLS = sources ImageProviderCore_sources target + importFiles.sources = qmlimageproviderplugin.dll ImageProviderCore/qmldir + importFiles.path = ImageProviderCore + DEPLOYMENT = importFiles +} diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir index e9ef115..e1288cf 100644 --- a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir +++ b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir @@ -1,2 +1,2 @@ Clock 1.0 Clock.qml -plugin qtimeexampleqmlplugin +plugin qmlqtimeexampleplugin diff --git a/examples/declarative/cppextensions/plugins/plugin.cpp b/examples/declarative/cppextensions/plugins/plugin.cpp index 2b1b320..355ca3f 100644 --- a/examples/declarative/cppextensions/plugins/plugin.cpp +++ b/examples/declarative/cppextensions/plugins/plugin.cpp @@ -148,4 +148,4 @@ public: #include "plugin.moc" -Q_EXPORT_PLUGIN2(qtimeexampleqmlplugin, QExampleQmlPlugin); +Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin); diff --git a/examples/declarative/cppextensions/plugins/plugins.pro b/examples/declarative/cppextensions/plugins/plugins.pro index b501ae3..b7610a8 100644 --- a/examples/declarative/cppextensions/plugins/plugins.pro +++ b/examples/declarative/cppextensions/plugins/plugins.pro @@ -1,9 +1,10 @@ TEMPLATE = lib -DESTDIR = com/nokia/TimeExample -TARGET = qtimeexampleqmlplugin CONFIG += qt plugin QT += declarative +DESTDIR = com/nokia/TimeExample +TARGET = qmlqtimeexampleplugin + SOURCES += plugin.cpp qdeclarativesources.files += \ @@ -18,14 +19,11 @@ qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/noki sources.files += plugins.pro plugin.cpp plugins.qml README sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins - target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample -symbian:{ - TARGET.EPOCALLOWDLLDATA=1 -} - - INSTALLS += qdeclarativesources sources target -symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.EPOCALLOWDLLDATA = 1 +} diff --git a/examples/declarative/cppextensions/qwidgets/QWidgets/qmldir b/examples/declarative/cppextensions/qwidgets/QWidgets/qmldir index e55267c..a7c1d95 100644 --- a/examples/declarative/cppextensions/qwidgets/QWidgets/qmldir +++ b/examples/declarative/cppextensions/qwidgets/QWidgets/qmldir @@ -1 +1 @@ -plugin proxywidgetsplugin +plugin qmlqwidgetsplugin diff --git a/examples/declarative/cppextensions/qwidgets/qwidgets.cpp b/examples/declarative/cppextensions/qwidgets/qwidgets.cpp index 228f9f1..47d3932 100644 --- a/examples/declarative/cppextensions/qwidgets/qwidgets.cpp +++ b/examples/declarative/cppextensions/qwidgets/qwidgets.cpp @@ -94,4 +94,4 @@ public: #include "qwidgets.moc" -Q_EXPORT_PLUGIN2(qwidgetsplugin, QWidgetsPlugin); +Q_EXPORT_PLUGIN2(qmlqwidgetsplugin, QWidgetsPlugin); diff --git a/examples/declarative/cppextensions/qwidgets/qwidgets.pro b/examples/declarative/cppextensions/qwidgets/qwidgets.pro index 37f313d..8d87804 100644 --- a/examples/declarative/cppextensions/qwidgets/qwidgets.pro +++ b/examples/declarative/cppextensions/qwidgets/qwidgets.pro @@ -1,21 +1,25 @@ TEMPLATE = lib -DESTDIR = QWidgets -TARGET = qwidgetsplugin CONFIG += qt plugin QT += declarative +DESTDIR = QWidgets +TARGET = qmlqwidgetsplugin + SOURCES += qwidgets.cpp sources.files += qwidgets.pro qwidgets.cpp qwidgets.qml - sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins - target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins INSTALLS += sources target -symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - symbian:{ + load(data_caging_paths) + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) TARGET.EPOCALLOWDLLDATA = 1 + + importFiles.sources = qmlqwidgetsplugin.dll QWidgets/qmldir + importFiles.path = QWidgets + + DEPLOYMENT = importFiles } diff --git a/examples/declarative/sqllocalstorage/hello.qml b/examples/declarative/sqllocalstorage/hello.qml index 67f542e..0913d42 100644 --- a/examples/declarative/sqllocalstorage/hello.qml +++ b/examples/declarative/sqllocalstorage/hello.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +//![0] import Qt 4.7 Text { diff --git a/examples/declarative/toys/tic-tac-toe/content/Button.qml b/examples/declarative/toys/tic-tac-toe/content/Button.qml index 9b2dc8e..d0f387f 100644 --- a/examples/declarative/toys/tic-tac-toe/content/Button.qml +++ b/examples/declarative/toys/tic-tac-toe/content/Button.qml @@ -43,35 +43,37 @@ import Qt 4.7 Rectangle { id: container - property string text: "Button" - property bool down: false - property string mainCol: "lightgray" - property string darkCol: "darkgray" - property string lightCol: "white" + property string text + property bool pressed: false + + signal clicked width: buttonLabel.width + 20; height: buttonLabel.height + 6 - border { width: 1; color: Qt.darker(mainCol) } - radius: 8; - color: mainCol + border { width: 1; color: Qt.darker(container.color) } + radius: 8 + color: "lightgray" smooth: true gradient: Gradient { GradientStop { - id: topGrad; position: 0.0 - color: if (container.down) { darkCol } else { lightCol } + position: 0.0 + color: container.pressed ? "darkgray" : "white" + } + GradientStop { + position: 1.0 + color: container.color } - GradientStop { position: 1.0; color: mainCol } } - signal clicked - - MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() } + MouseArea { + anchors.fill: parent + onClicked: container.clicked() + } Text { id: buttonLabel - anchors.centerIn: container - text: container.text; + text: container.text font.pixelSize: 14 } } diff --git a/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js b/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js index f8d6d9f..5a166b7 100644 --- a/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js +++ b/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js @@ -1,145 +1,149 @@ function winner(board) { for (var i=0; i<3; ++i) { - if (board.children[i].state!="" - && board.children[i].state==board.children[i+3].state - && board.children[i].state==board.children[i+6].state) + if (board.children[i].state != "" + && board.children[i].state == board.children[i+3].state + && board.children[i].state == board.children[i+6].state) return true - if (board.children[i*3].state!="" - && board.children[i*3].state==board.children[i*3+1].state - && board.children[i*3].state==board.children[i*3+2].state) + if (board.children[i*3].state != "" + && board.children[i*3].state == board.children[i*3+1].state + && board.children[i*3].state == board.children[i*3+2].state) return true } - if (board.children[0].state!="" - && board.children[0].state==board.children[4].state!="" - && board.children[0].state==board.children[8].state!="") + if (board.children[0].state != "" + && board.children[0].state == board.children[4].state != "" + && board.children[0].state == board.children[8].state != "") return true - if (board.children[2].state!="" - && board.children[2].state==board.children[4].state!="" - && board.children[2].state==board.children[6].state!="") + if (board.children[2].state != "" + && board.children[2].state == board.children[4].state != "" + && board.children[2].state == board.children[6].state != "") return true return false } -function restart() +function restartGame() { - // No moves left - start again + game.running = true + for (var i=0; i<9; ++i) board.children[i].state = "" } -function makeMove(pos,player) +function makeMove(pos, player) { board.children[pos].state = player if (winner(board)) { - win(player + " wins") + gameFinished(player + " wins") return true } else { return false } } +function canPlayAtPos(pos) +{ + return board.children[pos].state == "" +} + function computerTurn() { var r = Math.random(); - if(r < game.difficulty){ + if (r < game.difficulty) smartAI(); - }else{ - randAI(); - } + else + randomAI(); } function smartAI() { - function boardCopy(a){ + function boardCopy(a) { var ret = new Object; ret.children = new Array(9); - for(var i = 0; i<9; i++){ + for (var i = 0; i<9; i++) { ret.children[i] = new Object; ret.children[i].state = a.children[i].state; } return ret; } - for(var i=0; i<9; i++){ + + for (var i=0; i<9; i++) { var simpleBoard = boardCopy(board); - if (board.children[i].state == "") { + if (canPlayAtPos(i)) { simpleBoard.children[i].state = "O"; - if(winner(simpleBoard)){ - makeMove(i,"O") + if (winner(simpleBoard)) { + makeMove(i, "O") return } } } - for(var i=0; i<9; i++){ + for (var i=0; i<9; i++) { var simpleBoard = boardCopy(board); - if (board.children[i].state == "") { + if (canPlayAtPos(i)) { simpleBoard.children[i].state = "X"; - if(winner(simpleBoard)){ - makeMove(i,"O") + if (winner(simpleBoard)) { + makeMove(i, "O") return } } } - function thwart(a,b,c){//If they are at a, try b or c + + function thwart(a,b,c) { //If they are at a, try b or c if (board.children[a].state == "X") { - if (board.children[b].state == "") { - makeMove(b,"O") + if (canPlayAtPos(b)) { + makeMove(b, "O") return true - }else if (board.children[c].state == "") { - makeMove(c,"O") + } else if (canPlayAtPos(c)) { + makeMove(c, "O") return true } } return false; } - if(thwart(4,0,2)) return; - if(thwart(0,4,3)) return; - if(thwart(2,4,1)) return; - if(thwart(6,4,7)) return; - if(thwart(8,4,5)) return; - if(thwart(1,4,2)) return; - if(thwart(3,4,0)) return; - if(thwart(5,4,8)) return; - if(thwart(7,4,6)) return; - for(var i =0; i<9; i++){//Backup - if (board.children[i].state == "") { - makeMove(i,"O") + + if (thwart(4,0,2)) return; + if (thwart(0,4,3)) return; + if (thwart(2,4,1)) return; + if (thwart(6,4,7)) return; + if (thwart(8,4,5)) return; + if (thwart(1,4,2)) return; + if (thwart(3,4,0)) return; + if (thwart(5,4,8)) return; + if (thwart(7,4,6)) return; + + for (var i =0; i<9; i++) { + if (canPlayAtPos(i)) { + makeMove(i, "O") return } } - restart(); + restartGame(); } -function randAI() +function randomAI() { - var open = 0; - for (var i=0; i<9; ++i) - if (board.children[i].state == "") { - open += 1; - } - if(open == 0){ - restart(); - return; + var unfilledPosns = new Array(); + + for (var i=0; i<9; ++i) { + if (canPlayAtPos(i)) + unfilledPosns.push(i); + } + + if (unfilledPosns.length == 0) { + restartGame(); + } else { + var choice = unfilledPosns[Math.floor(Math.random() * unfilledPosns.length)]; + makeMove(choice, "O"); } - var openA = new Array(open);//JS doesn't have lists I can append to (i think) - var acc = 0; - for (var i=0; i<9; ++i) - if (board.children[i].state == "") { - openA[acc] = i; - acc += 1; - } - var choice = openA[Math.floor(Math.random() * open)]; - makeMove(choice, "O"); } -function win(s) +function gameFinished(message) { - msg.text = s - msg.opacity = 1 - endtimer.running = true + messageDisplay.text = message + messageDisplay.visible = true + game.running = false } diff --git a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml index 76a6a3b..34c3130 100644 --- a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml +++ b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml @@ -42,75 +42,80 @@ import Qt 4.7 import "content" import "content/tic-tac-toe.js" as Logic -Item { +Rectangle { id: game - property bool show: false + property bool running: true property real difficulty: 1.0 //chance it will actually think - width: 440 - height: 480 + width: display.width; height: display.height + 10 Image { - id: boardimage - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.horizontalCenter } + id: boardImage source: "content/pics/board.png" } - Grid { - id: board - anchors.fill: boardimage - columns: 3 - - Repeater { - model: 9 - TicTac { - width: board.width/3 - height: board.height/3 - onClicked: { - if (!endtimer.running) { - if (!Logic.makeMove(index,"X")) - Logic.computerTurn() - } - } - } - } + Text { + id: messageDisplay + anchors.centerIn: parent + color: "blue" + style: Text.Outline; styleColor: "white" + font.pixelSize: 50; font.bold: true + visible: false Timer { - id: endtimer - interval: 1600 - onTriggered: { msg.opacity = 0; Logic.restart() } + running: messageDisplay.visible + onTriggered: { + messageDisplay.visible = false; + Logic.restartGame(); + } } } - Row { - spacing: 4 - anchors { top: board.bottom; horizontalCenter: board.horizontalCenter } + Column { + id: display - Button { - text: "Hard" - onClicked: game.difficulty = 1.0; - down: game.difficulty == 1.0 - } - Button { - text: "Moderate" - onClicked: game.difficulty = 0.8; - down: game.difficulty == 0.8 - } - Button { - text: "Easy" - onClicked: game.difficulty = 0.2; - down: game.difficulty == 0.2 + Grid { + id: board + width: boardImage.width; height: boardImage.height + columns: 3 + + Repeater { + model: 9 + + TicTac { + width: board.width/3 + height: board.height/3 + + onClicked: { + if (game.running && Logic.canPlayAtPos(index)) { + if (!Logic.makeMove(index, "X")) + Logic.computerTurn(); + } + } + } + } } - } - Text { - id: msg + Row { + spacing: 4 + anchors.horizontalCenter: parent.horizontalCenter - anchors.centerIn: parent - opacity: 0 - color: "blue" - style: Text.Outline; styleColor: "white" - font.pixelSize: 50; font.bold: true + Button { + text: "Hard" + pressed: game.difficulty == 1.0 + onClicked: { game.difficulty = 1.0 } + } + Button { + text: "Moderate" + pressed: game.difficulty == 0.8 + onClicked: { game.difficulty = 0.8 } + } + Button { + text: "Easy" + pressed: game.difficulty == 0.2 + onClicked: { game.difficulty = 0.2 } + } + } } } diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml index 96c543e..7de32f2 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/app.qml +++ b/examples/declarative/tutorials/extending/chapter1-basics/app.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +//![0] import Music 1.0 import Qt 4.7 diff --git a/examples/declarative/tutorials/extending/chapter2-methods/app.qml b/examples/declarative/tutorials/extending/chapter2-methods/app.qml index 82740d2..495413f 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/app.qml +++ b/examples/declarative/tutorials/extending/chapter2-methods/app.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +//![0] import Music 1.0 import Qt 4.7 diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml index 138d504..46408cb 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml +++ b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +//![0] import Music 1.0 import Qt 4.7 diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml index e238ec4..09662d6 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +//![0] import Music 1.0 import Qt 4.7 diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro b/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro index a8fb565..483da8f 100644 --- a/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro +++ b/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro @@ -2,6 +2,10 @@ TEMPLATE = lib CONFIG += qt plugin QT += declarative +DESTDIR = lib +OBJECTS_DIR = tmp +MOC_DIR = tmp + HEADERS += musician.h \ instrument.h \ musicplugin.h @@ -10,10 +14,6 @@ SOURCES += musician.cpp \ instrument.cpp \ musicplugin.cpp -DESTDIR = lib -OBJECTS_DIR = tmp -MOC_DIR = tmp - symbian { include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) TARGET.EPOCALLOWDLLDATA = 1 diff --git a/examples/declarative/ui-components/dialcontrol/dial.qmlproject b/examples/declarative/ui-components/dialcontrol/dialcontrol.qmlproject index d4909f8..d4909f8 100644 --- a/examples/declarative/ui-components/dialcontrol/dial.qmlproject +++ b/examples/declarative/ui-components/dialcontrol/dialcontrol.qmlproject diff --git a/examples/painting/svgviewer/svgviewer.pro b/examples/painting/svgviewer/svgviewer.pro index 5af8731..4809b91 100644 --- a/examples/painting/svgviewer/svgviewer.pro +++ b/examples/painting/svgviewer/svgviewer.pro @@ -17,15 +17,15 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/painting/svgviewer INSTALLS += target sources wince*: { - addFiles.sources = files\*.svg - addFiles.path = \My Documents + addFiles.sources = files\\*.svg + addFiles.path = "\\My Documents" DEPLOYMENT += addFiles } symbian: { TARGET.UID3 = 0xA000A64E include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - addFiles.sources = files\*.svg + addFiles.sources = files\\*.svg addFiles.path = . DEPLOYMENT += addFiles } diff --git a/examples/xml/dombookmarks/dombookmarks.pro b/examples/xml/dombookmarks/dombookmarks.pro index 25e21cd..f906d2f 100644 --- a/examples/xml/dombookmarks/dombookmarks.pro +++ b/examples/xml/dombookmarks/dombookmarks.pro @@ -15,6 +15,6 @@ symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) wince*: { addFiles.sources = frank.xbel jennifer.xbel - addFiles.path = \My Documents + addFiles.path = "\\My Documents" DEPLOYMENT += addFiles } diff --git a/examples/xml/saxbookmarks/saxbookmarks.pro b/examples/xml/saxbookmarks/saxbookmarks.pro index 4af3ddd..7293bd1 100644 --- a/examples/xml/saxbookmarks/saxbookmarks.pro +++ b/examples/xml/saxbookmarks/saxbookmarks.pro @@ -15,7 +15,7 @@ INSTALLS += target sources wince*: { addFiles.sources = frank.xbel jennifer.xbel - addFiles.path = \My Documents + addFiles.path = "\\My Documents" DEPLOYMENT += addFiles } |