qrc and serachBarWidget
[mdictionary] / src / mdictionary / qml / Button.qml
1 import Qt 4.7
2
3 BorderImage {
4     id: button
5     property alias textInButton: buttonText.text
6     signal clicked
7     opacity: 1
8
9     border { left: 10; top: 10; right: 10; bottom: 10 }
10
11     MouseArea {
12         id: mouseArea
13         anchors.centerIn: parent;
14         width:  ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)) - ((70*parent.height)/107)
15         height: parent.height
16         onClicked: {
17             button.clicked();
18         }
19     }
20
21     Text {
22         z:1
23         id: buttonText
24         anchors.centerIn: parent;
25         font.pixelSize: parent.height * .5
26         style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
27     }
28
29     Rectangle {
30         id: shade
31         anchors.centerIn: parent;
32         radius: parent.height*.4;
33         color: "black";
34         opacity: 0
35         width:  ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60))
36         height: parent.height
37     }
38
39     Image {
40         id: image1
41         smooth: true
42         width: (35*parent.height)/107 +1
43         height: parent.height
44         anchors.left: parent.left
45         anchors.leftMargin: (parent.width - ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)))/2
46         source: "qrc:/button/buttonLeft.png"
47     }
48
49     Image {
50         id: image3
51         smooth: true
52         width: (((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)) - ((70*parent.height)/107))+1
53         height: parent.height
54         anchors.horizontalCenter: parent.horizontalCenter
55         source: "qrc:/button/buttonCenter.png"
56     }
57
58     Image {
59         id: image2
60         smooth: true
61         width: (35*parent.height)/107 +1
62         height: parent.height
63         anchors.right: parent.right
64         anchors.rightMargin: (parent.width - ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)))/2
65         source: "qrc:/button/buttonR.png"
66     }
67
68     states: [
69         State {
70             name: "pressed"; when: mouseArea.pressed == true
71             PropertyChanges { target: shade; opacity: 0.4 }
72             PropertyChanges { target: image1; opacity: 0.5 }
73             PropertyChanges { target: image3; opacity: 0.5 }
74             PropertyChanges { target: image2; opacity: 0.5 }
75         }
76     ]
77 }