Merge branch 'qml' of ssh://drop.maemo.org/git/mdictionary into qml
[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     }
47
48     Image {
49         id: image3
50         smooth: true
51         width: parent.width - ((70*parent.height)/107) +1;
52         height: parent.height
53         anchors.horizontalCenter: parent.horizontalCenter
54         source: "qrc:/button/buttonCenter.png"
55     }
56
57     Image {
58         id: image2
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     states: [
67         State {
68             name: "pressed"; when: mouseArea.pressed == true
69             PropertyChanges { target: shade; opacity: 0.4 }
70             PropertyChanges { target: image1; opacity: 0.5 }
71             PropertyChanges { target: image3; opacity: 0.5 }
72             PropertyChanges { target: image2; opacity: 0.5 }
73         }
74     ]
75
76
77
78 /*    MouseArea {
79         id: mouseArea
80         anchors.centerIn: parent;
81         width:  ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)) - ((70*parent.height)/107)
82         height: parent.height
83         onClicked: {
84             button.clicked();
85         }
86     }
87
88     Text {
89         z:1
90         id: buttonText
91         anchors.centerIn: parent;
92         font.pixelSize: parent.height * .5
93         style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
94         PropertyChanges {
95             target: button;
96             width: (button.width> buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.8)
97         }
98     }
99
100     Rectangle {
101         id: shade
102         anchors.centerIn: parent;
103         radius: parent.height*.4;
104         color: "black";
105         opacity: 0
106         width:  ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60))
107         height: parent.height
108     }
109
110     Image {
111         id: image1
112         width: (35*parent.height)/107 +1
113         height: parent.height
114         anchors.left: parent.left
115         anchors.leftMargin: (parent.width - ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)))/2
116         source: "qrc:/button/buttonLeft.png"
117     }
118
119     Image {
120         id: image3
121         smooth: true
122         width: (((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)) - ((70*parent.height)/107))+1
123         height: parent.height
124         anchors.horizontalCenter: parent.horizontalCenter
125         source: "qrc:/button/buttonCenter.png"
126     }
127
128     Image {
129         id: image2
130         smooth: true
131         width: (35*parent.height)/107 +1
132         height: parent.height
133         anchors.right: parent.right
134         anchors.rightMargin: (parent.width - ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)))/2
135         source: "qrc:/button/buttonR.png"
136     }
137
138     states: [
139         State {
140             name: "pressed"; when: mouseArea.pressed == true
141             PropertyChanges { target: shade; opacity: 0.4 }
142             PropertyChanges { target: image1; opacity: 0.5 }
143             PropertyChanges { target: image3; opacity: 0.5 }
144             PropertyChanges { target: image2; opacity: 0.5 }
145         }
146     ]
147     */
148 }