add qml-elements
[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
10     Image {
11         id: image
12         z:1;
13         anchors.centerIn: parent
14         width: rectangle.width;
15         height: rectangle.height;
16     }
17
18
19     MouseArea {
20         id: mouseArea
21         anchors.centerIn: parent;
22         width: rectangle.width + (70*parent.height)/107;
23         height: rectangle.height;
24         onClicked: {
25             rectangle.clicked();
26         }
27     }
28
29     Image {
30         id: image1
31         width: (35*parent.height)/107
32         height: parent.height
33         anchors.left: parent.left
34         anchors.leftMargin: - (35*parent.height)/107
35         source: "qrc:/button/buttonLeft.png"
36     }
37
38     Image {
39         id: image3
40         width: parent.width
41         height: parent.height
42         anchors.horizontalCenter: parent.horizontalCenter
43         source: "qrc:/button/buttonCenter.png"
44     }
45
46
47     Image {
48         id: image2
49         width: (35*parent.height)/107
50         height: parent.height
51         anchors.right: parent.right
52         anchors.rightMargin:  - (35*parent.height)/107
53         source: "qrc:/button/buttonR.png"
54     }
55
56     Rectangle {
57         id: shade
58         anchors.centerIn: parent;
59         color: "black";
60         radius: 20;
61         opacity: 1;
62         width:  rectangle.width+(70*parent.height)/107;
63         height: rectangle.height;
64     }
65
66     states: [
67         State {
68             name: "enable";
69             when: (mouseArea.pressed == false && rectangle.enabled == true);
70             PropertyChanges { target: shade;
71                               opacity: 0; }
72         },
73         State {
74             name: "disable";
75             when: (rectangle.enabled == false);
76             PropertyChanges { target: shade;
77                               color: "black";
78                               opacity: .5; }
79         },
80         State {
81             name: "clicked";
82             when: (mouseArea.pressed == true && rectangle.enabled == true);
83             PropertyChanges { target: shade;
84                               color: "#fffead"
85                               opacity: 0.5; }
86         }
87     ]
88 }