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.qml36
1 files changed, 25 insertions, 11 deletions
diff --git a/examples/quick/demos/calqlatr/content/Button.qml b/examples/quick/demos/calqlatr/content/Button.qml
index 3f28e6f3c0..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,25 +57,38 @@ 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)
+ }
+ }
+ ]
}
-// Rectangle {
-// color: "red"
-// opacity: 0.2
-// anchors.fill: mouse
-// }
-
MouseArea {
id: mouse
anchors.fill: parent
anchors.margins: -5
onClicked: {
- //parent.clicked()
if (operator)
window.operatorPressed(parent.text)
else
window.digitPressed(parent.text)
}
}
+
+ function updateDimmed() {
+ dimmed = window.isButtonDisabled(button.text)
+ }
+
+ Component.onCompleted: {
+ numPad.buttonPressed.connect(updateDimmed)
+ updateDimmed()
+ }
}