d27cec6a21230dd04031917a6ab49ca1f5019b7c
[mdictionary] / src / mdictionary / qml / GoogleDialog.qml
1 import Qt 4.7
2
3 Rectangle{
4     property bool newPlugin:false;
5
6     function setInfo(string){
7         infoLabel.text = string;
8     }
9     function setStartValues(startFrom, startTo, startFromIndex, startToIndex){
10         comboFrom.setStartValue(startFrom, startFromIndex)
11         comboTo.setStartValue(startTo, startToIndex)
12     }
13     function revertLang(){
14         var tmpidx = comboFrom.index
15         comboFrom.index = comboTo.index
16         comboTo.index = tmpidx
17
18         var tmpval = comboFrom.value
19         comboFrom.value = comboTo.value
20         comboTo.value = tmpval
21     }
22
23     function setNew(bool){
24         newPlugin=bool;
25     }
26
27     signal saveButtonClicked(string langFrom, string langTo);
28
29
30     id:rectangle1
31     height: infoLabel.height + fromLabel.height + toLabel.height + saveButton.height + 50
32     width: 200
33     color : myPalette.window;
34
35     SystemPalette {
36         id: myPalette;
37         colorGroup:SystemPalette.Active
38     }
39
40     Item {
41         id: comboField
42         anchors.bottomMargin: 6
43         anchors.rightMargin: 0
44         anchors.left: fromLabel.right
45         anchors.right: revertButton.left
46         anchors.bottom: saveButton.top
47         anchors.top: parent.top
48         anchors.leftMargin: 2
49         z:2;
50     }
51
52     Text {
53         id: infoLabel
54         height: paintedHeight+5;
55         anchors.right: parent.right
56         anchors.left: parent.left
57         anchors.top: parent.top
58         wrapMode: Text.Wrap;
59         transformOrigin: Item.Left
60         font.pixelSize: 12
61     }
62
63
64     Text {
65         id: fromLabel
66         text: qsTr("From: ")
67         height: paintedHeight+5;
68         anchors.top: infoLabel.bottom
69         anchors.left: parent.left
70         wrapMode: Text.Wrap;
71         transformOrigin: Item.Left
72         font.pixelSize: 12
73     }
74
75     Text {
76         id: toLabel
77         text: qsTr("To: ")
78         anchors.topMargin: 3
79         height: paintedHeight+5;
80         anchors.top: fromLabel.bottom
81         anchors.left: parent.left
82         wrapMode: Text.Wrap;
83         transformOrigin: Item.Left
84         font.pixelSize: 12
85     }
86
87     ComboBox{
88         id: comboFrom
89         model: comboBoxModel
90         anchors.right: revertButton.left
91         anchors.rightMargin: 5
92         anchors.left: fromLabel.right
93         anchors.leftMargin: 10
94         anchors.verticalCenter: fromLabel.verticalCenter
95
96         parentField: comboField
97         expanded: false
98         basicHeight: fromLabel.height
99         onExpandedChanged: {
100             if(expanded==true)
101                 z=2;
102             else
103                 z=0;
104         }
105     }
106
107     ComboBox{
108         id: comboTo
109         model:  comboBoxModel
110         anchors.right: revertButton.left
111         anchors.rightMargin: 5
112         anchors.left: fromLabel.right
113         anchors.leftMargin: 10
114         anchors.verticalCenter: toLabel.verticalCenter
115
116         parentField: comboField;
117         expanded: false
118         basicHeight: fromLabel.height
119
120         onExpandedChanged: {
121             if(expanded==true)
122                 z=2;
123             else
124                 z=0;
125         }
126     }
127
128     IconButton{
129         id: revertButton
130         width: height
131         height: fromLabel.height
132         anchors.top: fromLabel.bottom
133         anchors.topMargin: -8
134         anchors.right: parent.right
135         pathToIcon: "qrc:/button/revert.png"
136         onClicked: { rectangle1.revertLang() }
137     }
138
139     Button {
140         id: saveButton
141         height: 30
142         anchors.bottom: parent.bottom
143         anchors.right: parent.right
144         anchors.left: parent.left
145         onClicked: {
146             rectangle1.saveButtonClicked(comboFrom.value, comboTo.value);
147         }
148     }
149
150     MouseArea {
151         id: mouse_area1
152         anchors.fill: parent
153         z:-1
154         onClicked: {
155             comboTo.expanded=false;
156             comboFrom.expanded=false;
157         }
158     }
159
160
161
162     states: [
163         State {
164             name: "new"
165             when: newPlugin==true
166             PropertyChanges { target: saveButton; textInButton: qsTr("Add") }
167         },
168         State {
169             name: "edit"
170             when: newPlugin==false
171             PropertyChanges { target: saveButton; textInButton: qsTr("Save settings") }
172         }
173     ]
174 }
175
176
177 /*
178 Rectangle{
179     property bool newPlugin:false;
180
181     function setInfo(string){
182         infoLabel.text = string;
183     }
184     function setStartValues(startFrom, startTo, startFromIndex, startToIndex){
185         comboFrom.setStartValue(startFrom, startFromIndex)
186         comboTo.setStartValue(startTo, startToIndex)
187     }
188     function revertLang(){
189         var tmpidx = comboFrom.index
190         comboFrom.index = comboTo.index
191         comboTo.index = tmpidx
192
193         var tmpval = comboFrom.value
194         comboFrom.value = comboTo.value
195         comboTo.value = tmpval
196     }
197
198     function setNew(bool){
199         newPlugin=bool;
200     }
201
202     signal saveButtonClicked(string langFrom, string langTo);
203
204
205     id:rectangle1
206     height: infoLabel.height + fromLabel.height + toLabel.height + saveButton.height + 50
207     width: 200
208
209     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
210     color : myPalette.window;
211
212
213     Text {
214         id: infoLabel
215         height: paintedHeight+5;
216         anchors.right: parent.right
217         anchors.left: parent.left
218         anchors.top: parent.top
219         wrapMode: Text.Wrap;
220         transformOrigin: Item.Left
221         font.pixelSize: 12
222         z: 15
223     }
224
225     Text {
226         id: fromLabel
227         text: qsTr("From: ")
228         height: paintedHeight+5;
229         anchors.top: infoLabel.bottom
230         anchors.left: parent.left
231         wrapMode: Text.Wrap;
232         transformOrigin: Item.Left
233         font.pixelSize: 12
234     }
235
236     Text {
237         id: toLabel
238         text: qsTr("To: ")
239         height: paintedHeight+5;
240         anchors.top: fromLabel.bottom
241         anchors.left: parent.left
242         wrapMode: Text.Wrap;
243         transformOrigin: Item.Left
244         font.pixelSize: 12
245     }
246
247     ComboBox{
248         //parentField: rectangle1
249
250         id: comboFrom
251         model: comboBoxModel
252         anchors.left: parent.left
253         anchors.leftMargin: {
254             if (fromLabel.width < 30 && toLabel.width < 30){
255                 return 30
256             }
257             else if (fromLabel.width > toLabel.width){
258                 return fromLabel.width + 10
259             }
260             else {
261                 return toLabel.width + 10
262             }
263         }
264
265         anchors.top: infoLabel.bottom
266         anchors.right: revertButton.left
267         anchors.rightMargin: 10
268         expanded: false
269         basicHeight: fromLabel.height
270         expandedHeight: parent.height - comboFrom.x - saveButton.height -20
271     }
272
273     ComboBox{
274         //parentField: rectangle1;
275         id: comboTo
276         model:  comboBoxModel
277         anchors.left: parent.left
278         anchors.leftMargin: {
279             if (fromLabel.width < 30 && toLabel.width < 30){
280                 return 30
281             }
282             else if (fromLabel.width > toLabel.width){
283                 return fromLabel.width + 10
284             }
285             else {
286                 return toLabel.width + 10
287             }
288         }
289
290         anchors.right: revertButton.left
291         anchors.rightMargin: 10
292         anchors.top: comboFrom.bottom
293         expanded: false
294         basicHeight: fromLabel.height
295         expandedHeight: parent.height - comboTo.x - saveButton.height - 20 - fromLabel.height
296     }
297
298     IconButton{
299         id: revertButton
300         width: height
301         height: fromLabel.height
302         anchors.top: fromLabel.top
303         anchors.topMargin: fromLabel.height /2
304         anchors.right: parent.right
305         pathToIcon: "qrc:/button/revert.png"
306         onClicked: { rectangle1.revertLang() }
307     }
308
309     Button {
310         id: saveButton
311         height: 30
312         z: 1
313         anchors.bottom: parent.bottom
314         anchors.right: parent.right
315         anchors.left: parent.left
316         onClicked: {
317             rectangle1.saveButtonClicked(comboFrom.value, comboTo.value);
318         }
319     }
320
321     states: [
322         State {
323             name: "new"
324             when: newPlugin==true
325             PropertyChanges { target: saveButton; textInButton: qsTr("Add") }
326         },
327         State {
328             name: "edit"
329             when: newPlugin==false
330             PropertyChanges { target: saveButton; textInButton: qsTr("Save settings") }
331         }
332     ]
333 }
334 */
335