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