diff options
Diffstat (limited to 'examples/declarative/toys')
23 files changed, 0 insertions, 345 deletions
diff --git a/examples/declarative/toys/README b/examples/declarative/toys/README deleted file mode 100644 index ff4d024..0000000 --- a/examples/declarative/toys/README +++ /dev/null @@ -1,37 +0,0 @@ -These pure QML examples demonstrate -some of what can be easily done using just a few QML files. - -The example launcher provided with Qt can be used to explore each of the -examples in this directory. They can also be viewed directly with the -QML viewer utility, without requiring compilation. - -Documentation for these examples can be found via the Tutorial and Examples -link in the main Qt documentation. - - -Finding the Qt Examples and Demos launcher -========================================== - -On Windows: - -The launcher can be accessed via the Windows Start menu. Select the menu -entry entitled "Qt Examples and Demos" entry in the submenu containing -the Qt tools. - -On Mac OS X: - -For the binary distribution, the qtdemo executable is installed in the -/Developer/Applications/Qt directory. For the source distribution, it is -installed alongside the other Qt tools on the path specified when Qt is -configured. - -On Unix/Linux: - -The qtdemo executable is installed alongside the other Qt tools on the path -specified when Qt is configured. - -On all platforms: - -The source code for the launcher can be found in the demos/qtdemo directory -in the Qt package. This example is built at the same time as the Qt libraries, -tools, examples, and demonstrations. diff --git a/examples/declarative/toys/clocks/clocks.qmlproject b/examples/declarative/toys/clocks/clocks.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/toys/clocks/clocks.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/toys/corkboards/cork.jpg b/examples/declarative/toys/corkboards/cork.jpg Binary files differdeleted file mode 100644 index 160bc00..0000000 --- a/examples/declarative/toys/corkboards/cork.jpg +++ /dev/null diff --git a/examples/declarative/toys/corkboards/corkboards.qmlproject b/examples/declarative/toys/corkboards/corkboards.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/toys/corkboards/corkboards.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/toys/corkboards/note-yellow.png b/examples/declarative/toys/corkboards/note-yellow.png Binary files differdeleted file mode 100644 index 8ddecc8..0000000 --- a/examples/declarative/toys/corkboards/note-yellow.png +++ /dev/null diff --git a/examples/declarative/toys/corkboards/tack.png b/examples/declarative/toys/corkboards/tack.png Binary files differdeleted file mode 100644 index cef2d1c..0000000 --- a/examples/declarative/toys/corkboards/tack.png +++ /dev/null diff --git a/examples/declarative/toys/dynamicscene/dynamicscene.qmlproject b/examples/declarative/toys/dynamicscene/dynamicscene.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/toys/dynamicscene/dynamicscene.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/toys/dynamicscene/images/NOTE b/examples/declarative/toys/dynamicscene/images/NOTE deleted file mode 100644 index fcd87f9..0000000 --- a/examples/declarative/toys/dynamicscene/images/NOTE +++ /dev/null @@ -1 +0,0 @@ -Images (except star.png) are from the KDE project. diff --git a/examples/declarative/toys/dynamicscene/images/face-smile.png b/examples/declarative/toys/dynamicscene/images/face-smile.png Binary files differdeleted file mode 100644 index 3d66d72..0000000 --- a/examples/declarative/toys/dynamicscene/images/face-smile.png +++ /dev/null diff --git a/examples/declarative/toys/dynamicscene/images/moon.png b/examples/declarative/toys/dynamicscene/images/moon.png Binary files differdeleted file mode 100644 index 1c0d606..0000000 --- a/examples/declarative/toys/dynamicscene/images/moon.png +++ /dev/null diff --git a/examples/declarative/toys/dynamicscene/images/rabbit_brown.png b/examples/declarative/toys/dynamicscene/images/rabbit_brown.png Binary files differdeleted file mode 100644 index ebfdeed..0000000 --- a/examples/declarative/toys/dynamicscene/images/rabbit_brown.png +++ /dev/null diff --git a/examples/declarative/toys/dynamicscene/images/rabbit_bw.png b/examples/declarative/toys/dynamicscene/images/rabbit_bw.png Binary files differdeleted file mode 100644 index 7bff9b9..0000000 --- a/examples/declarative/toys/dynamicscene/images/rabbit_bw.png +++ /dev/null diff --git a/examples/declarative/toys/dynamicscene/images/star.png b/examples/declarative/toys/dynamicscene/images/star.png Binary files differdeleted file mode 100644 index 27ef924..0000000 --- a/examples/declarative/toys/dynamicscene/images/star.png +++ /dev/null diff --git a/examples/declarative/toys/dynamicscene/images/sun.png b/examples/declarative/toys/dynamicscene/images/sun.png Binary files differdeleted file mode 100644 index 7713ca5..0000000 --- a/examples/declarative/toys/dynamicscene/images/sun.png +++ /dev/null diff --git a/examples/declarative/toys/dynamicscene/images/tree_s.png b/examples/declarative/toys/dynamicscene/images/tree_s.png Binary files differdeleted file mode 100644 index 6eac35a..0000000 --- a/examples/declarative/toys/dynamicscene/images/tree_s.png +++ /dev/null diff --git a/examples/declarative/toys/dynamicscene/qml/itemCreation.js b/examples/declarative/toys/dynamicscene/qml/itemCreation.js deleted file mode 100644 index 4ee74c2..0000000 --- a/examples/declarative/toys/dynamicscene/qml/itemCreation.js +++ /dev/null @@ -1,62 +0,0 @@ -var itemComponent = null; -var draggedItem = null; -var startingMouse; -var posnInWindow; - -function startDrag(mouse) -{ - posnInWindow = paletteItem.mapToItem(window, 0, 0); - startingMouse = { x: mouse.x, y: mouse.y } - loadComponent(); -} - -//Creation is split into two functions due to an asynchronous wait while -//possible external files are loaded. - -function loadComponent() { - if (itemComponent != null) { // component has been previously loaded - createItem(); - return; - } - - itemComponent = Qt.createComponent(paletteItem.componentFile); - if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately - component.statusChanged.connect(createItem); - else - createItem(); -} - -function createItem() { - if (itemComponent.status == Component.Ready && draggedItem == null) { - draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); - // make sure created item is above the ground layer - } else if (itemComponent.status == Component.Error) { - draggedItem = null; - console.log("error creating component"); - console.log(itemComponent.errorString()); - } -} - -function continueDrag(mouse) -{ - if (draggedItem == null) - return; - - draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; - draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; -} - -function endDrag(mouse) -{ - if (draggedItem == null) - return; - - if (draggedItem.x + draggedItem.width > toolbox.x) { //Don't drop it in the toolbox - draggedItem.destroy(); - draggedItem = null; - } else { - draggedItem.created = true; - draggedItem = null; - } -} - diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/board.png b/examples/declarative/toys/tic-tac-toe/content/pics/board.png Binary files differdeleted file mode 100644 index 7e5b7ba..0000000 --- a/examples/declarative/toys/tic-tac-toe/content/pics/board.png +++ /dev/null diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/o.png b/examples/declarative/toys/tic-tac-toe/content/pics/o.png Binary files differdeleted file mode 100644 index abc7ee0..0000000 --- a/examples/declarative/toys/tic-tac-toe/content/pics/o.png +++ /dev/null diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/x.png b/examples/declarative/toys/tic-tac-toe/content/pics/x.png Binary files differdeleted file mode 100644 index ddc65c8..0000000 --- a/examples/declarative/toys/tic-tac-toe/content/pics/x.png +++ /dev/null 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 deleted file mode 100644 index 5a166b7..0000000 --- a/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js +++ /dev/null @@ -1,149 +0,0 @@ -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) - 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) - return true - } - - 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 != "") - return true - - return false -} - -function restartGame() -{ - game.running = true - - for (var i=0; i<9; ++i) - board.children[i].state = "" -} - -function makeMove(pos, player) -{ - board.children[pos].state = player - if (winner(board)) { - 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) - smartAI(); - else - randomAI(); -} - -function smartAI() -{ - function boardCopy(a) { - var ret = new Object; - ret.children = new Array(9); - 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++) { - var simpleBoard = boardCopy(board); - if (canPlayAtPos(i)) { - simpleBoard.children[i].state = "O"; - if (winner(simpleBoard)) { - makeMove(i, "O") - return - } - } - } - for (var i=0; i<9; i++) { - var simpleBoard = boardCopy(board); - if (canPlayAtPos(i)) { - simpleBoard.children[i].state = "X"; - if (winner(simpleBoard)) { - makeMove(i, "O") - return - } - } - } - - function thwart(a,b,c) { //If they are at a, try b or c - if (board.children[a].state == "X") { - if (canPlayAtPos(b)) { - makeMove(b, "O") - return true - } 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++) { - if (canPlayAtPos(i)) { - makeMove(i, "O") - return - } - } - restartGame(); -} - -function randomAI() -{ - 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"); - } -} - -function gameFinished(message) -{ - messageDisplay.text = message - messageDisplay.visible = true - game.running = false -} - diff --git a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qmlproject b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/toys/toys.qmlproject b/examples/declarative/toys/toys.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/toys/toys.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/toys/tvtennis/tvtennis.qmlproject b/examples/declarative/toys/tvtennis/tvtennis.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/toys/tvtennis/tvtennis.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -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 " ] -} |