small change
[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     function press() { mouseArea.pressed }
11     border { left: 10; top: 10; right: 10; bottom: 10 }
12
13     MouseArea {
14         id: mouseArea
15         anchors.centerIn: parent;
16         width:  parent.width;
17         height: parent.height;
18         onClicked: {
19             button.clicked();
20         }
21     }
22
23     Text {
24         z:1
25         id: buttonText
26         anchors.centerIn: parent;
27         font.pixelSize: parent.height * .5
28         elide: Text.ElideRight;
29         style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
30     }
31
32     Image {
33         id: image1
34         width: (35*parent.height)/107 +1
35         height: parent.height
36         anchors.left: parent.left
37         source: "qrc:/button/buttonLeft.png"
38         smooth: true
39         fillMode:Image.Stretch
40     }
41
42     Image {
43         id: image3
44         smooth: true
45         height: parent.height
46         anchors.right: image2.left
47         anchors.rightMargin: -1
48         anchors.left: image1.right
49         anchors.leftMargin: -1
50         source: "qrc:/button/buttonCenter.png"
51         fillMode:Image.Stretch
52     }
53
54     Image {
55         id: image2
56         smooth: true
57         width: (35*parent.height)/107 +1
58         height: parent.height
59         anchors.right: parent.right
60         source: "qrc:/button/buttonR.png"
61         fillMode:Image.Stretch
62     }
63
64     states: [
65         State {
66             name: "pressed";
67             when: (mouseArea.pressed == true && button.enabled == true);
68
69             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" }
70             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" }
71             PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" }
72         },
73         State {
74             name: "disabled";
75             when: (button.enabled == false);
76
77             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" }
78             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" }
79             PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" }
80         }
81     ]
82 }