aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/demos/calqlatr/content/Button.qml
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2014-09-24 14:37:46 +0200
committerTopi Reiniö <topi.reinio@digia.com>2014-09-30 12:37:28 +0200
commitf83d12e0c27ad76d98d66a663140a09698b11d37 (patch)
tree6ce1e66cd651c8b325f5a6790ea036e7bbe62c47 /examples/quick/demos/calqlatr/content/Button.qml
parentfccf0e29120f64a8b9b2a15b33971a648ab190e7 (diff)
Update the Calqltr demo visuals and engine logic
- Add logic for displaying the calculation result in the best available precision, determined by the display width - Display 'ERROR' when the result cannot be displayed - Animate the number pad button colors to react to presses and visually disable them when pressing the button has no effect - Fix issues in calculator.js logic - Update documentation accordingly Task-number: QTBUG-41253 Change-Id: Ibed7b8218ea4cd074b8f9b90d9bb4e3ea6b25ba2 Reviewed-by: Johanna Äijälä <johanna.aijala@digia.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com> Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
Diffstat (limited to 'examples/quick/demos/calqlatr/content/Button.qml')
-rw-r--r--examples/quick/demos/calqlatr/content/Button.qml29
1 files changed, 25 insertions, 4 deletions
diff --git a/examples/quick/demos/calqlatr/content/Button.qml b/examples/quick/demos/calqlatr/content/Button.qml
index fc6234414f..0748645274 100644
--- a/examples/quick/demos/calqlatr/content/Button.qml
+++ b/examples/quick/demos/calqlatr/content/Button.qml
@@ -41,12 +41,13 @@
import QtQuick 2.0
Item {
+ id: button
property alias text: textItem.text
- property alias color: textItem.color
+ property color color: "#eceeea"
property bool operator: false
-
- signal clicked
+ property bool dimmable: false
+ property bool dimmed: false
width: 30
height: 50
@@ -56,7 +57,18 @@ Item {
font.pixelSize: 48
wrapMode: Text.WordWrap
lineHeight: 0.75
- color: "white"
+ color: (dimmable && dimmed) ? Qt.darker(button.color) : button.color
+ Behavior on color { ColorAnimation { duration: 120; easing.type: Easing.OutElastic} }
+ states: [
+ State {
+ name: "pressed"
+ when: mouse.pressed && !dimmed
+ PropertyChanges {
+ target: textItem
+ color: Qt.lighter(button.color)
+ }
+ }
+ ]
}
MouseArea {
@@ -70,4 +82,13 @@ Item {
window.digitPressed(parent.text)
}
}
+
+ function updateDimmed() {
+ dimmed = window.isButtonDisabled(button.text)
+ }
+
+ Component.onCompleted: {
+ numPad.buttonPressed.connect(updateDimmed)
+ updateDimmed()
+ }
}