Fix button graphics when button was pressed or disabled. Add disabled state to button...
[mdictionary] / src / mdictionary / qml / IconButton.qml
1 import Qt 4.7
2
3 Rectangle {
4     id: rectangle
5
6     property alias pathToIcon: image.source;
7
8     signal clicked;
9     radius: 50
10
11     MouseArea {
12         id: mouseArea
13         anchors.centerIn: parent;
14         width: rectangle.width
15         height: rectangle.height;
16         onClicked: {
17             rectangle.clicked();
18         }
19     }
20
21     Image {
22         id: image
23         z:4;
24         anchors.centerIn: parent
25         width: rectangle.width;
26         height: rectangle.height;
27     }
28
29     Image {
30         id: image1
31         z: 1
32         smooth: true
33         width: (35*parent.height)/107 +1
34         height: parent.height
35         anchors.left: parent.left
36         source: "qrc:/button/buttonLeft.png"
37     }
38
39     Image {
40         id: image3
41         z: 1
42         smooth: true
43         width: parent.width - (70*parent.height)/107 +1
44         height: parent.height
45         anchors.horizontalCenter: parent.horizontalCenter
46         source: "qrc:/button/buttonCenter.png"
47
48     }
49
50
51     Image {
52         id: image2
53         z: 1
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     }
60
61
62     states: [
63         State {
64             name: "disable";
65             when: (rectangle.enabled == false);
66             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" }
67             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" }
68             PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" }
69         },
70         State {
71             name: "clicked";
72             when: (mouseArea.pressed == true && rectangle.enabled == true);
73             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" }
74             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" }
75             PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" }
76         }
77     ]
78 }