qml - webView widget
[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     function setText(string) { textInButton = string; }
10     border { left: 10; top: 10; right: 10; bottom: 10 }
11
12     MouseArea {
13         id: mouseArea
14         anchors.centerIn: parent;
15         width:  parent.width;
16         height: parent.height;
17         onClicked: {
18             button.clicked();
19         }
20     }
21
22     Text {
23         z:1
24         id: buttonText
25         anchors.centerIn: parent;
26         font.pixelSize: parent.height * .5
27         style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
28     }
29
30     Rectangle {
31         id: shade
32         anchors.centerIn: parent;
33         radius: parent.height*.4;
34         color: "black";
35         opacity: 0
36         width:  parent.width;
37         height: parent.height;
38     }
39
40     Image {
41         id: image1
42         width: (35*parent.height)/107 +1
43         height: parent.height
44         anchors.left: parent.left
45         source: "qrc:/button/buttonLeft.png"
46         fillMode:Image.Stretch
47     }
48
49     Image {
50         id: image3
51         smooth: true
52         width: parent.width - ((70*parent.height)/107) +1;
53         height: parent.height
54         anchors.horizontalCenter: parent.horizontalCenter
55         source: "qrc:/button/buttonCenter.png"
56         fillMode:Image.Stretch
57     }
58
59     Image {
60         id: image2
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         fillMode:Image.Stretch
67     }
68
69     states: [
70         State {
71             name: "pressed"; when: mouseArea.pressed == true
72             PropertyChanges { target: shade; opacity: 0.4 }
73             PropertyChanges { target: image1; opacity: 0.5 }
74             PropertyChanges { target: image3; opacity: 0.5 }
75             PropertyChanges { target: image2; opacity: 0.5 }
76         }
77     ]
78
79
80
81 /*    MouseArea {
82         id: mouseArea
83         anchors.centerIn: parent;
84         width:  ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)) - ((70*parent.height)/107)
85         height: parent.height
86         onClicked: {
87             button.clicked();
88         }
89     }
90
91     Text {
92         z:1
93         id: buttonText
94         anchors.centerIn: parent;
95         font.pixelSize: parent.height * .5
96         style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
97         PropertyChanges {
98             target: button;
99             width: (button.width> buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.8)
100         }
101     }
102
103     Rectangle {
104         id: shade
105         anchors.centerIn: parent;
106         radius: parent.height*.4;
107         color: "black";
108         opacity: 0
109         width:  ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60))
110         height: parent.height
111     }
112
113     Image {
114         id: image1
115         width: (35*parent.height)/107 +1
116         height: parent.height
117         anchors.left: parent.left
118         anchors.leftMargin: (parent.width - ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)))/2
119         source: "qrc:/button/buttonLeft.png"
120     }
121
122     Image {
123         id: image3
124         smooth: true
125         width: (((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)) - ((70*parent.height)/107))+1
126         height: parent.height
127         anchors.horizontalCenter: parent.horizontalCenter
128         source: "qrc:/button/buttonCenter.png"
129     }
130
131     Image {
132         id: image2
133         smooth: true
134         width: (35*parent.height)/107 +1
135         height: parent.height
136         anchors.right: parent.right
137         anchors.rightMargin: (parent.width - ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)))/2
138         source: "qrc:/button/buttonR.png"
139     }
140
141     states: [
142         State {
143             name: "pressed"; when: mouseArea.pressed == true
144             PropertyChanges { target: shade; opacity: 0.4 }
145             PropertyChanges { target: image1; opacity: 0.5 }
146             PropertyChanges { target: image3; opacity: 0.5 }
147             PropertyChanges { target: image2; opacity: 0.5 }
148         }
149     ]
150     */
151 }