X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmdictionary%2Fqml%2FButton.qml;fp=src%2Fmdictionary%2Fqml%2FButton.qml;h=953fdbca72630fab994eaeda6cf330544530aad3;hb=29aa1caa7c232b517244c11463844a7b54fed22d;hp=d10edc6df598b83f57c2fe06238d93ecd9efbccb;hpb=08e403fb8f97d1352819f64d81eeda2c65148a40;p=mdictionary diff --git a/src/mdictionary/qml/Button.qml b/src/mdictionary/qml/Button.qml index d10edc6..953fdbc 100644 --- a/src/mdictionary/qml/Button.qml +++ b/src/mdictionary/qml/Button.qml @@ -1,13 +1,27 @@ import Qt 4.7 -BorderImage { +Rectangle { id: button property alias textInButton: buttonText.text - signal clicked - opacity: 1 + property bool checkable: false + property bool checked: false + + height: 20; + width: 60; + + signal clicked; + signal changeCheck; function setText(string) { textInButton = qsTr(string); } - border { left: 10; top: 10; right: 10; bottom: 10 } + function press() { mouseArea.pressed } + + Keys.onReturnPressed: { + button.clicked(); + if(checkable){ + button.checked=!button.checked; + button.changeCheck(); + } + } MouseArea { id: mouseArea @@ -16,20 +30,27 @@ BorderImage { height: parent.height; onClicked: { button.clicked(); + if(checkable){ + button.checked=!button.checked; + button.changeCheck(); + } } } Text { z:1 id: buttonText + width: parent.width; anchors.centerIn: parent; + horizontalAlignment: Text.AlignHCenter font.pixelSize: parent.height * .5 + elide: Text.ElideRight; style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true } Image { id: image1 - width: (35*parent.height)/107 +1 + width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1 height: parent.height anchors.left: parent.left source: "qrc:/button/buttonLeft.png" @@ -46,13 +67,15 @@ BorderImage { anchors.left: image1.right anchors.leftMargin: -1 source: "qrc:/button/buttonCenter.png" - fillMode:Image.Stretch + //fillMode:Image.Stretch + fillMode: Image.TileHorizontally + } Image { id: image2 smooth: true - width: (35*parent.height)/107 +1 + width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1 height: parent.height anchors.right: parent.right source: "qrc:/button/buttonR.png" @@ -62,7 +85,7 @@ BorderImage { states: [ State { name: "pressed"; - when: (mouseArea.pressed == true && button.enabled == true); + when: ((button.enabled) && (mouseArea.pressed || (button.checkable && button.checked) ) ) PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" } PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" } @@ -75,6 +98,15 @@ BorderImage { PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" } PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" } PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" } + }, + State { + name: "focused"; + when: (button.enabled && !mouseArea.pressed && button.focus) + + PropertyChanges { target: image1; source: "qrc:/button/buttonLeftFocus.png" } + PropertyChanges { target: image3; source: "qrc:/button/buttonCenterFocus.png" } + PropertyChanges { target: image2; source: "qrc:/button/buttonRFocus.png" } } + ] }