From 9ba03ca32ae12f8b135f3b4f80c445edc3e6b55e Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 29 Apr 2009 14:02:48 +1000 Subject: Convert the calculator demo. --- demos/declarative/calculator/CalcButton.qml | 64 ++++++--- demos/declarative/calculator/calculator.qml | 208 +++++++++++++++++----------- 2 files changed, 169 insertions(+), 103 deletions(-) diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml index c925314..f240000 100644 --- a/demos/declarative/calculator/CalcButton.qml +++ b/demos/declarative/calculator/CalcButton.qml @@ -1,12 +1,13 @@ - +Item { + id: Button; width: 50; height: 30 - - - - - + properties: [ + Property { name: "operation"; type: "string" }, + Property { name: "toggable"; value: false }, + Property { name: "toggled"; value: false } + ] - + } - - - - + Image { + id: Image + src: "pics/button.sci" + width: Button.width; height: Button.height + } - - - - - - - - + Image { + id: ImagePressed + src: "pics/button-pressed.sci" + width: Button.width; height: Button.height + opacity: 0 + } - + Text { + anchors.centeredIn: Image + text: Button.operation + color: "white" + font.bold: true + } + MouseRegion { + id: MouseRegion + anchors.fill: Button + onClicked: { buttonClicked(Button.operation) } + } + + states: [ + State { + name: "Pressed"; when: MouseRegion.pressed == true + SetProperties { target: ImagePressed; opacity: 1 } + }, + State { + name: "Toggled"; when: Button.toggled == true + SetProperties { target: ImagePressed; opacity: 1 } + } + ] +} diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index 4ada896..1e7c30a 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -1,83 +1,127 @@ - -