summaryrefslogtreecommitdiffstats
path: root/demos/declarative/calculator
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-08-26 03:31:27 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-08-26 04:48:04 (GMT)
commit2af41f34eca0effced19b59d4c3327e3e4b627cb (patch)
tree593e0ef0f985638a300a68f591eda76a75cf6234 /demos/declarative/calculator
parent58a76965e20c4c66ab2dc9cf73aa72b1cfddfbeb (diff)
downloadQt-2af41f34eca0effced19b59d4c3327e3e4b627cb.zip
Qt-2af41f34eca0effced19b59d4c3327e3e4b627cb.tar.gz
Qt-2af41f34eca0effced19b59d4c3327e3e4b627cb.tar.bz2
Add quit buttons to declarative demos
Task-number: QTBUG-13048 Reviewed-by: Martin Jones
Diffstat (limited to 'demos/declarative/calculator')
-rw-r--r--demos/declarative/calculator/Core/calculator.js10
-rw-r--r--demos/declarative/calculator/calculator.qml16
2 files changed, 12 insertions, 14 deletions
diff --git a/demos/declarative/calculator/Core/calculator.js b/demos/declarative/calculator/Core/calculator.js
index 16cc309..7c363c7 100644
--- a/demos/declarative/calculator/Core/calculator.js
+++ b/demos/declarative/calculator/Core/calculator.js
@@ -74,6 +74,11 @@ function doOperation(op) {
memory = display.text.valueOf()
} else if (op == leftArrow) {
display.text = display.text.toString().slice(0, -1)
+ if (display.text.length == 0) {
+ display.text = "0"
+ }
+ } else if (op == "Off") {
+ Qt.quit();
} else if (op == "C") {
display.text = "0"
} else if (op == "AC") {
@@ -82,10 +87,5 @@ function doOperation(op) {
lastOp = ""
display.text ="0"
}
-
- if (op == rotateRight)
- main.state = "orientation " + Orientation.Landscape
- if (op == rotateLeft)
- main.state = ''
}
diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml
index 288455b..68c922b 100644
--- a/demos/declarative/calculator/calculator.qml
+++ b/demos/declarative/calculator/calculator.qml
@@ -58,7 +58,7 @@ Rectangle {
property string plusminus : "\u00b1"
function doOp(operation) { CalcEngine.doOperation(operation) }
-
+
Item {
id: main
state: "orientation " + runtime.orientation
@@ -70,8 +70,10 @@ Rectangle {
anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 }
- Row {
- Display { id: display; width: box.width; height: 64 }
+ Display {
+ id: display
+ width: box.width-3
+ height: 64
}
Column {
@@ -82,11 +84,7 @@ Rectangle {
Row {
spacing: 6
-
- Button {
- id: rotateButton
- width: column.w; height: column.h; color: 'purple'; operation: rotateRight
- }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" }
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" }
@@ -103,7 +101,7 @@ Rectangle {
}
Grid {
- id: grid; rows: 4; columns: 5; spacing: 6
+ id: grid; rows: 5; columns: 5; spacing: 6
property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns)