aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/demos/calqlatr/content/Button.qml
diff options
context:
space:
mode:
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()
+ }
}