From f83d12e0c27ad76d98d66a663140a09698b11d37 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 24 Sep 2014 14:37:46 +0200 Subject: Update the Calqltr demo visuals and engine logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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ä Reviewed-by: Leena Miettinen Reviewed-by: Venugopal Shivashankar --- examples/quick/demos/calqlatr/content/Button.qml | 29 ++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'examples/quick/demos/calqlatr/content/Button.qml') 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() + } } -- cgit v1.2.3