9b66836a6edbd2ae87da7e6682350787d12f7561
[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     Rectangle {
62         id: shade
63         z: 4
64         anchors.centerIn: parent;
65         color: "black";
66         radius: 20;
67         opacity: 1;
68         width:  rectangle.width;
69         height: rectangle.height;
70     }
71
72     states: [
73         State {
74             name: "enable";
75             when: (mouseArea.pressed == false && rectangle.enabled == true);
76             PropertyChanges { target: shade;
77                               opacity: 0; }
78         },
79         State {
80             name: "disable";
81             when: (rectangle.enabled == false);
82             PropertyChanges { target: shade;
83                               color: "black";
84                               opacity: .5; }
85         },
86         State {
87             name: "clicked";
88             when: (mouseArea.pressed == true && rectangle.enabled == true);
89             PropertyChanges { target: shade;
90                               color: "#fffead"
91                               opacity: 0.5; }
92         }
93     ]
94 }