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