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