diff options
-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 | |||
-rw-r--r-- | src/declarative/util/qmlpalette.cpp | 12 | ||||
-rw-r--r-- | src/declarative/util/qmlpalette.h | 2 |
9 files changed, 39 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 diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp index 3756878..e714bc7 100644 --- a/src/declarative/util/qmlpalette.cpp +++ b/src/declarative/util/qmlpalette.cpp @@ -124,6 +124,18 @@ QColor QmlPalette::base() const } /*! + \qmlproperty color Palette::text + The text color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlPalette::text() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::Text); +} + +/*! \qmlproperty color Palette::alternateBase The alternate base color of the current color group. diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h index 4c2cc31..e381814 100644 --- a/src/declarative/util/qmlpalette.h +++ b/src/declarative/util/qmlpalette.h @@ -62,6 +62,7 @@ class Q_DECLARATIVE_EXPORT QmlPalette : public QObject Q_PROPERTY(QColor window READ window NOTIFY paletteChanged) Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged) Q_PROPERTY(QColor base READ base NOTIFY paletteChanged) + Q_PROPERTY(QColor text READ text NOTIFY paletteChanged) Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged) Q_PROPERTY(QColor button READ button NOTIFY paletteChanged) Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged) @@ -81,6 +82,7 @@ public: QColor windowText() const; QColor base() const; + QColor text() const; QColor alternateBase() const; QColor button() const; |