Added copyright and license info to QML files
[chessclock] / qml / MainPage.qml
1 /**************************************************************************
2
3    Chess Clock
4
5    This file is part of Chess Clock software.
6
7    (This file) Copyright (c) Heli Hyvättinen 2011
8
9    Chess Clock is free software: you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation, either version 3 of the License, or
12    (at your option) any later version.
13
14    Chess Clock is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19
20 **************************************************************************/
21
22
23 import QtQuick 1.1
24 import com.meego 1.0
25 import QtQuick 1.0
26 import com.nokia.extras 1.0
27
28
29 Page {
30     id: mainPage
31     tools: commonTools
32
33
34
35
36
37
38 //    Label {
39 //        id: label
40 //        anchors.centerIn: parent
41 //        text: qsTr("Hello world!")
42 //        visible: false
43 //    }
44
45
46     Image
47     {
48         id: bigLogo
49 //        anchors.fill: parent
50 //        anchors.left: menuList.right
51
52         source: ":/rc/pic/logo.png"
53     }
54
55     ListModel
56     {
57         id: menuModel
58
59         ListElement
60         {
61             name: "Normal clock"
62             askAddition: false
63             logoFile: ":/rc/pic/oldclock.png"
64
65
66         }
67
68         ListElement
69         {
70             name: "Addition before"
71             askAddition: true
72             logoFile: ":/rc/pic/addbefore.png"
73         }
74
75         ListElement
76         {
77             name: "Addition after"
78             askAddition: true
79             logoFile: ":/rc/pic/addafter.png"
80         }
81
82         ListElement
83         {
84             name: "Delay"
85             askAddition: true
86             logoFile: ":/rc/pic/pausebefore.png"
87         }
88
89         ListElement
90         {
91             name: "Delay after"
92             askAddition: true
93             logoFile: ":/rc/pic/pauseafter.png"
94         }
95
96         ListElement
97         {
98             name:"Hour Glass"
99             askAddition: false
100             logoFile:":/rc/pic/hourglass.png"
101         }
102
103     }
104
105
106     ListView
107     {
108         id: menuList
109
110         anchors.left: bigLogo.right
111         anchors.right: parent.right
112         anchors.top: parent.top
113         anchors.bottom: parent.bottom
114
115
116          model: menuModel
117
118          delegate: Row
119          {
120             Image
121             {
122                 source: logoFile
123
124                 MouseArea
125                 {
126                     anchors.fill: parent
127                     onClicked: {newGameDialog.name = name; newGameDialog.askAddition = askAddition; newGameDialog.open()}
128                 }
129             }
130
131             Text
132             {
133                 text: name
134                 font.pointSize: 40
135                 anchors.topMargin: 12
136                 color: "white"
137
138                 MouseArea
139                 {
140                     anchors.fill: parent
141                     onClicked: {newGameDialog.name = name; newGameDialog.askAddition = askAddition; newGameDialog.open()}
142                 }
143             }
144
145         }
146     }
147
148
149
150
151
152     Dialog
153     {
154         id:newGameDialog
155
156         property string name
157         property bool askAddition
158
159         onAccepted: pageStack.push(clocksPage)
160
161
162
163         title:Label
164         {
165             color:"white"
166             font.pointSize: 64
167             text: newGameDialog.name
168         }
169
170
171         content:
172             Grid
173             {
174                 columns: 3
175
176                 Row
177                 {
178                     id: rowRow
179                     spacing: 10
180 //                    anchors.top: parent.top
181 //                    anchors.horizontalCenter: parent.horizontalCenter
182
183                     Text
184                     {
185  //                     width: rowRow.width - rowRow.spacing - switchComponent.width - whiteSmall.width - blackSmall.width
186  //                     height: switchComponent.height
187                         verticalAlignment: Text.AlignVCenter
188                         text: "Equal times"
189                         color: "white"
190                         font.pointSize: 26
191                     }
192
193                     Switch
194                     {
195                         id: equalTimesSwitch
196                         onCheckedChanged:
197                         {
198                             if (checked)
199                             {
200                                 blackInitialTime.text = whiteInitialTime.text
201                                 blackAdditionalTime.text = whiteAdditionalTime.text
202                                 blackTurnsPerAddition.text = whiteTurnsPerAddition.text
203
204                             }
205                         }
206                     }
207                 }
208                 Image
209                 {
210                     id: whiteSmall
211                     source: ":/rc/pic/white_small.png"
212                 }
213
214                 Image
215                 {
216                     id: blackSmall
217                     source: ":/rc/pic/black_small.png"
218                 }
219
220                 Text
221                 {
222                     id: initialTimeText
223                     text: "Initial time"
224                     color: "white"
225                     font.pointSize: 26
226 //                    anchors.top: rowRow.bottom
227 //                    anchors.horizontalCenter: parent.horizontalCenter
228 //                    visible: true
229                 }
230
231
232                 TextField
233                 {
234                     id: whiteInitialTime
235                     readOnly: true
236
237                     onTextChanged: {if (equalTimesSwitch.checked) blackInitialTime.text = text}
238
239                     MouseArea
240                     {
241                         anchors.fill: parent
242                         onClicked: {timePicker.timeType = "initial";  timePicker.player = "white"; timePicker.open()}
243                     }
244                 }
245
246
247
248                 TextField
249                 {
250                     id: blackInitialTime
251                     enabled: !equalTimesSwitch.checked
252
253                     readOnly: true
254
255
256
257                     MouseArea
258                     {
259                     anchors.fill: parent
260                     onClicked: {timePicker.timeType = "initial";  timePicker.player = "black"; timePicker.open()}
261                     }
262                 }
263
264
265
266                 Text
267                 {
268                     id: additionalTimeText
269                     text: "Additional time"
270                     color: "white"
271                     font.pointSize: 26
272                     visible: newGameDialog.askAddition
273 //                    anchors.top: initialTimeText.bottom
274 //                    anchors.horizontalCenter: parent.horizontalCenter
275                 }
276
277
278
279                 TextField
280                 {
281                     id: whiteAdditionalTime
282                     visible:  newGameDialog.askAddition
283                     readOnly: true
284
285                     onTextChanged: {if (equalTimesSwitch.checked) blackAdditionalTime.text = text}
286
287                     MouseArea
288                     {
289                         anchors.fill: parent
290                         onClicked: {timePicker.timeType = "additional";  timePicker.player = "white"; timePicker.open()}
291                     }
292                 }
293
294                 TextField
295                 {
296                     id: blackAdditionalTime
297                     visible: newGameDialog.askAddition
298                     enabled: !equalTimesSwitch.checked
299                     readOnly: true
300
301                     MouseArea
302                     {
303                         anchors.fill: parent
304                         onClicked: {timePicker.timeType = "additional";  timePicker.player = "black"; timePicker.open()}
305                     }
306         }
307
308
309
310                 Text
311                 {
312                     text:  "Turns per addition"
313                     color: "white"
314                     font.pointSize: 26
315                     visible: newGameDialog.askAddition
316 //                    anchors.top: additionalTimeText.bottom
317 //                    anchors.horizontalCenter: parent.horizontalCenter
318                 }
319                 TextField
320                 {
321                     id: whiteTurnsPerAddition
322                     visible: newGameDialog.askAddition
323
324                     inputMask: "D00"
325                     text: "1"
326
327                     onTextChanged: {if (equalTimesSwitch.checked) blackTurnsPerAddition.text = text}
328                 }
329
330                 TextField
331                 {
332                     id: blackTurnsPerAddition
333                     visible: newGameDialog.askAddition
334                     enabled: !equalTimesSwitch.checked
335                     inputMask: "D00"
336                     text: "1"
337                 }
338
339
340
341          }
342
343
344         buttons:
345
346             Button
347             {
348                 id: bOk
349                 text: "Start game"
350                 y: 45
351
352                 onClicked: newGameDialog.accept()
353             }
354     }
355
356     TimePickerDialog
357     {
358         id: timePicker
359
360         property string timeType
361         property string player
362         property string result
363
364
365         titleText: "Choose " + timeType + " time for " + player
366         rejectButtonText: "Cancel"
367         acceptButtonText: "Ok"
368         hourMode: DateTime.TwentyFourHours
369         onAccepted:
370         {
371             result = hour + " h " + minute + " min " + second + " s"
372             if (timeType == "initial")
373                 if (player == "white")
374                     whiteInitialTime.text = result
375                 else
376                     blackInitialTime.text = result
377
378             else if (player == "white")
379                     whiteAdditionalTime.text = result
380                 else
381                     blackAdditionalTime.text = result
382
383         }
384     }
385 }
386
387
388
389