diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2009-08-03 04:38:11 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2009-08-03 04:38:11 (GMT) |
commit | a23e4d3f55e7072ae3919092652b2dc915fc887f (patch) | |
tree | 1e3003be41dc9c7a5833dc647938ec8af08093fe /demos | |
parent | 77e802215ad8d3d94fb1821abf1932540ee7fb9f (diff) | |
download | Qt-a23e4d3f55e7072ae3919092652b2dc915fc887f.zip Qt-a23e4d3f55e7072ae3919092652b2dc915fc887f.tar.gz Qt-a23e4d3f55e7072ae3919092652b2dc915fc887f.tar.bz2 |
Improve calculator demo and add missing text property to QmlPalette.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/declarative/calculator/CalcButton.qml | 57 | ||||
-rw-r--r-- | demos/declarative/calculator/calculator.qml | 13 | ||||
-rw-r--r-- | demos/declarative/calculator/pics/button-pressed.png | bin | 644 -> 0 bytes | |||
-rw-r--r-- | demos/declarative/calculator/pics/button-pressed.sci | 5 | ||||
-rw-r--r-- | demos/declarative/calculator/pics/button.png | bin | 635 -> 0 bytes | |||
-rw-r--r-- | demos/declarative/calculator/pics/button.sci | 5 | ||||
-rw-r--r-- | demos/declarative/calculator/pics/clear.png | bin | 611 -> 0 bytes |
7 files changed, 25 insertions, 55 deletions
diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml index 5eb7fe1..ebb1967 100644 --- a/demos/declarative/calculator/CalcButton.qml +++ b/demos/declarative/calculator/CalcButton.qml @@ -1,62 +1,41 @@ import Qt 4.6 -Item { +Rect { property string operation property bool toggable : false property bool toggled : false + signal clicked id: Button; width: 50; height: 30 - - Script { - function buttonClicked(operation) { - if (Button.toggable == true) { - if (Button.toggled == true) { - Button.toggled = false; - Button.state = 'Toggled'; - } else { - Button.toggled = true; - Button.state = ''; - } - } - else - doOp(operation); - } - } - - Image { - id: Image - source: "pics/button.sci" - width: Button.width; height: Button.height + border.color: Palette.mid; radius: 6 + gradient: Gradient { + GradientStop { id: G1; position: 0.0; color: Palette.lighter(Palette.button) } + GradientStop { id: G2; position: 1.0; color: Palette.button } } - Image { - id: ImagePressed - source: "pics/button-pressed.sci" - width: Button.width; height: Button.height - opacity: 0 - } - - Text { - anchors.centerIn: Image - text: Button.operation - color: "white" - font.bold: true - } + Text { anchors.centerIn: parent; text: operation; color: Palette.buttonText } MouseRegion { id: MouseRegion - anchors.fill: Button - onClicked: { buttonClicked(Button.operation) } + anchors.fill: parent + onClicked: { + doOp(operation); + Button.clicked(); + if (!Button.toggable) return; + Button.toggled ? Button.toggled = false : Button.toggled = true + } } states: [ State { name: "Pressed"; when: MouseRegion.pressed == true - SetProperties { target: ImagePressed; opacity: 1 } + SetProperties { target: G1; color: Palette.dark } + SetProperties { target: G2; color: Palette.button } }, State { name: "Toggled"; when: Button.toggled == true - SetProperties { target: ImagePressed; opacity: 1 } + SetProperties { target: G1; color: Palette.dark } + SetProperties { target: G2; color: Palette.button } } ] } diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index 576fea9..a4e16e4 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -2,22 +2,23 @@ import Qt 4.6 Rect { id: MainWindow; - width: 320; height: 270; color: "black" + width: 320; height: 270; color: Palette.window + Palette { id: Palette } Script { source: "calculator.js" } VerticalLayout { - spacing: 2; margin: 2 + x: 2; spacing: 10; margin: 2 Rect { id: Container - width: 316; height: 60; z: 2 - border.color: "white"; color: "#343434" + width: 316; height: 50; z: 2 + border.color: Palette.dark; color: Palette.base Text { id: CurNum font.bold: true; font.size: 16 - color: "white" + color: Palette.text anchors.right: Container.right anchors.rightMargin: 5 anchors.verticalCenter: Container.verticalCenter @@ -25,7 +26,7 @@ Rect { Text { id: CurrentOperation - color: "white" + color: Palette.text font.bold: true; font.size: 16 anchors.left: Container.left anchors.leftMargin: 5 diff --git a/demos/declarative/calculator/pics/button-pressed.png b/demos/declarative/calculator/pics/button-pressed.png Binary files differdeleted file mode 100644 index 1a24cee..0000000 --- a/demos/declarative/calculator/pics/button-pressed.png +++ /dev/null diff --git a/demos/declarative/calculator/pics/button-pressed.sci b/demos/declarative/calculator/pics/button-pressed.sci deleted file mode 100644 index f3bc860..0000000 --- a/demos/declarative/calculator/pics/button-pressed.sci +++ /dev/null @@ -1,5 +0,0 @@ -gridLeft: 5 -gridTop: 5 -gridBottom: 5 -gridRight: 5 -imageFile: button-pressed.png diff --git a/demos/declarative/calculator/pics/button.png b/demos/declarative/calculator/pics/button.png Binary files differdeleted file mode 100644 index 88c8bf8..0000000 --- a/demos/declarative/calculator/pics/button.png +++ /dev/null diff --git a/demos/declarative/calculator/pics/button.sci b/demos/declarative/calculator/pics/button.sci deleted file mode 100644 index b1c7929..0000000 --- a/demos/declarative/calculator/pics/button.sci +++ /dev/null @@ -1,5 +0,0 @@ -gridLeft: 5 -gridTop: 5 -gridBottom: 5 -gridRight: 5 -imageFile: button.png diff --git a/demos/declarative/calculator/pics/clear.png b/demos/declarative/calculator/pics/clear.png Binary files differdeleted file mode 100644 index fb07a27c..0000000 --- a/demos/declarative/calculator/pics/clear.png +++ /dev/null |