table view
[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         smooth: true
37         fillMode:Image.Stretch
38     }
39
40     Image {
41         id: image3
42         smooth: true
43         height: parent.height
44         anchors.right: image2.left
45         anchors.rightMargin: -1
46         anchors.left: image1.right
47         anchors.leftMargin: -1
48         source: "qrc:/button/buttonCenter.png"
49         fillMode:Image.Stretch
50     }
51
52     Image {
53         id: image2
54         smooth: true
55         width: (35*parent.height)/107 +1
56         height: parent.height
57         anchors.right: parent.right
58         source: "qrc:/button/buttonR.png"
59         fillMode:Image.Stretch
60     }
61
62     states: [
63         State {
64             name: "pressed";
65             when: (mouseArea.pressed == true && button.enabled == true);
66
67             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" }
68             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" }
69             PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" }
70         },
71         State {
72             name: "disabled";
73             when: (button.enabled == false);
74
75             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" }
76             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" }
77             PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" }
78         }
79     ]
80 }