table view
[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         smooth: true
27         anchors.centerIn: parent
28         width: iconWidth;
29         height: iconHeight;
30     }
31
32     Image {
33         id: image1
34         z: 1
35         smooth: true
36         width: (35*parent.height)/107 +1
37         height: parent.height
38         anchors.left: parent.left
39         source: "qrc:/button/buttonLeft.png"
40     }
41
42     Image {
43         id: image3
44         z: 1
45         smooth: true
46         height: parent.height
47         anchors.right: image2.left
48         anchors.rightMargin: -1
49         anchors.left: image1.right
50         anchors.leftMargin: -1
51         source: "qrc:/button/buttonCenter.png"
52
53     }
54
55
56     Image {
57         id: image2
58         z: 1
59         smooth: true
60         width: (35*parent.height)/107 +1
61         height: parent.height
62         anchors.right: parent.right
63         source: "qrc:/button/buttonR.png"
64     }
65
66
67     states: [
68         State {
69             name: "disable";
70             when: (rectangle.enabled == false);
71             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" }
72             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" }
73             PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" }
74         },
75         State {
76             name: "clicked";
77             when: (mouseArea.pressed == true && rectangle.enabled == true);
78             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" }
79             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" }
80             PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" }
81         }
82     ]
83 }