0491e99e079742e47d69ef482fa1481374c54e3a
[mdictionary] / src / mdictionary / qml / Button.qml
1 import Qt 4.7
2
3 BorderImage {
4     id: button
5     property alias textInButton: buttonText.text
6     signal clicked
7     opacity: 1
8
9     function setText(string) { textInButton = qsTr(string); }
10     border { left: 10; top: 10; right: 10; bottom: 10 }
11
12     MouseArea {
13         id: mouseArea
14         anchors.centerIn: parent;
15         width:  parent.width;
16         height: parent.height;
17         onClicked: {
18             button.clicked();
19         }
20     }
21
22     Text {
23         z:1
24         id: buttonText
25         anchors.centerIn: parent;
26         font.pixelSize: parent.height * .5
27         style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
28     }
29
30     Image {
31         id: image1
32         width: (35*parent.height)/107 +1
33         height: parent.height
34         anchors.left: parent.left
35         source: "qrc:/button/buttonLeft.png"
36         fillMode:Image.Stretch
37     }
38
39     Image {
40         id: image3
41         smooth: true
42         width: parent.width - ((70*parent.height)/107) +1;
43         height: parent.height
44         anchors.horizontalCenter: parent.horizontalCenter
45         source: "qrc:/button/buttonCenter.png"
46         fillMode:Image.Stretch
47     }
48
49     Image {
50         id: image2
51         smooth: true
52         width: (35*parent.height)/107 +1
53         height: parent.height
54         anchors.right: parent.right
55         source: "qrc:/button/buttonR.png"
56         fillMode:Image.Stretch
57     }
58
59     states: [
60         State {
61             name: "pressed";
62             when: (mouseArea.pressed == true && button.enabled == true);
63
64             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" }
65             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" }
66             PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" }
67         },
68         State {
69             name: "disabled";
70             when: (button.enabled == false);
71
72             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" }
73             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" }
74             PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" }
75         }
76     ]
77 }