summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/samegame/samegame3
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-05-04 23:50:53 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-05-05 02:54:01 (GMT)
commitdcee637a9f7a024803f0e5cc1bf57d878dca2ac3 (patch)
tree212950e45a79aeffc0a22492093f6531676739d2 /examples/declarative/tutorials/samegame/samegame3
parent4982b883c31874206aaa05268852fbcee81a8a39 (diff)
downloadQt-dcee637a9f7a024803f0e5cc1bf57d878dca2ac3.zip
Qt-dcee637a9f7a024803f0e5cc1bf57d878dca2ac3.tar.gz
Qt-dcee637a9f7a024803f0e5cc1bf57d878dca2ac3.tar.bz2
Doc improvements, simplify example code
Diffstat (limited to 'examples/declarative/tutorials/samegame/samegame3')
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Button.qml17
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Dialog.qml33
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.js9
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.qml14
4 files changed, 41 insertions, 32 deletions
diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml
index 737d886..4ed856b 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Button.qml
@@ -7,9 +7,9 @@ Rectangle {
signal clicked
- width: buttonLabel.width + 20; height: buttonLabel.height + 6
- smooth: true
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
radius: 8
// color the button with a gradient
@@ -26,7 +26,16 @@ Rectangle {
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
- Text { id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText }
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
}
diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
index 15b3b2f..3efed2f 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
@@ -2,31 +2,30 @@
import Qt 4.7
Rectangle {
- id: page
+ id: container
- signal closed
-
- function forceClose() {
- page.closed();
- page.opacity = 0;
+ function show(text) {
+ dialogText.text = text;
+ container.opacity = 1;
}
- function show(txt) {
- dialogText.text = txt;
- page.opacity = 1;
+ function hide() {
+ container.opacity = 0;
}
- width: dialogText.width + 20; height: dialogText.height + 20
- color: "white"
- border.width: 1
+ width: dialogText.width + 20
+ height: dialogText.height + 20
opacity: 0
- Behavior on opacity {
- NumberAnimation { duration: 1000 }
+ Text {
+ id: dialogText
+ anchors.centerIn: parent
+ text: ""
}
- Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" }
-
- MouseArea { anchors.fill: parent; onClicked: forceClose(); }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: hide();
+ }
}
//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js
index 4256aee..84439fc 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js
@@ -17,7 +17,7 @@ function startNewGame() {
maxIndex = maxRow * maxColumn;
//Close dialogs
- dialog.forceClose();
+ dialog.hide();
//Initialize Board
board = new Array(maxIndex);
@@ -59,10 +59,9 @@ function createBlock(column, row) {
return true;
}
-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
+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
+
//![1]
function handleClick(xPos, yPos) {
var column = Math.floor(xPos / gameCanvas.blockSize);
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
index 50f9d5d..ac93eb1 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
@@ -30,7 +30,6 @@ Rectangle {
width: parent.width - (parent.width % blockSize)
height: parent.height - (parent.height % blockSize)
anchors.centerIn: parent
- z: 20
MouseArea {
anchors.fill: parent
@@ -41,26 +40,29 @@ Rectangle {
}
//![2]
- Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
+ Dialog {
+ id: dialog
+ anchors.centerIn: parent
+ z: 100
+ }
//![2]
Rectangle {
id: toolBar
- width: parent.width; height: 32
+ width: parent.width; height: 30
color: activePalette.window
anchors.bottom: screen.bottom
Button {
- anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
text: "New Game"
onClicked: SameGame.startNewGame()
}
Text {
id: score
- anchors { right: parent.right; rightMargin: 3; verticalCenter: parent.verticalCenter }
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
text: "Score: Who knows?"
- font.bold: true
}
}
}