1 /**************************************************************************
5 This file is part of Chess Clock software.
7 (This file) Copyright (c) Heli Hyvättinen 2011
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.
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.
20 **************************************************************************/
26 import com.nokia.extras 1.0
27 import ChessClocks 1.0
34 orientationLock: PageOrientation.LockLandscape
37 property int timeControl //QML does not allow properties to be declared as enums...
38 property bool askAddition
39 property bool askTurnsPerAddition
43 Settings {id: settings}
44 Component.onCompleted:
45 {test = settings.value("test") }
49 ToolIcon { iconId: "toolbar-back"; onClicked: pageStack.pop() }
58 anchors.horizontalCenter: parent.horizontalCenter
62 text: newGameDialogPage.name
70 anchors.top: title.bottom
74 // width: rowRow.width - rowRow.spacing - switchComponent.width - whiteSmall.width - blackSmall.width
75 // height: switchComponent.height
76 verticalAlignment: Text.AlignVCenter
89 whiteSmall.anchors.horizontalCenter = undefined
90 whiteSmall.anchors.right = whiteInitialTime.horizontalCenter
92 blackSmall.anchors.horizontalCenter = undefined
93 blackSmall.anchors.left = whiteInitialTime.horizontalCenter
101 whiteSmall.anchors.right = undefined
102 whiteSmall.anchors.horizontalCenter = whiteInitialTime.horizontalCenter
104 blackSmall.anchors.left = undefined
105 blackSmall.anchors.horizontalCenter = blackInitialTime.horizontalCenter
120 anchors.top: rowRow.bottom
122 source: ":/rc/pic/white_small.png"
124 Component.onCompleted:
126 if (equalTimesSwitch.checked)
127 anchors.right = whiteInitialTime.horizontalCenter
129 anchors.horizontalCenter = whiteInitialTime.horizontalCenter
138 anchors.top: rowRow.bottom
141 source: ":/rc/pic/black_small.png"
143 Component.onCompleted:
145 if (equalTimesSwitch.checked)
146 anchors.left = whiteInitialTime.horizontalCenter
148 anchors.horizontalCenter = blackInitialTime.horizontalCenter
158 anchors.verticalCenter: whiteInitialTime.verticalCenter
167 anchors.top: whiteSmall.bottom
168 anchors.left: whiteTurnsPerAddition.left
174 text: {hours + " h " + minutes + " min " + seconds + " s"}
180 onClicked: {timePicker.timeType = "initial"; timePicker.player = "white"; timePicker.open()}
189 visible: !equalTimesSwitch.checked
193 anchors.top: whiteSmall.bottom
194 anchors.left: blackTurnsPerAddition.left
200 text: hours + " h " + minutes + " min " + seconds + " s"
206 onClicked: {timePicker.timeType = "initial"; timePicker.player = "black"; timePicker.open()}
214 id: additionalTimeText
216 anchors.verticalCenter: whiteAdditionalTime.verticalCenter
218 text: "Additional time"
221 visible: newGameDialogPage.askAddition
222 // anchors.top: initialTimeText.bottom
223 // anchors.horizontalCenter: parent.horizontalCenter
230 id: whiteAdditionalTime
231 visible: newGameDialogPage.askAddition
234 anchors.top: whiteInitialTime.bottom
235 anchors.topMargin: 15
236 // anchors.left: additionalTimeText.right
237 anchors.left: whiteTurnsPerAddition.left
242 text: hours + " h " + minutes + " min " + seconds + " s"
248 onClicked: {timePicker.timeType = "additional"; timePicker.player = "white"; timePicker.open()}
254 id: blackAdditionalTime
255 visible: newGameDialogPage.askAddition && !equalTimesSwitch.checked
258 anchors.top: whiteAdditionalTime.top
259 anchors.left: blackTurnsPerAddition.left
265 text: hours + " h " + minutes + " min " + seconds + " s"
270 onClicked: {timePicker.timeType = "additional"; timePicker.player = "black"; timePicker.open()}
278 id: turnsPerAdditionText
279 text: "Turns per addition"
282 visible: newGameDialogPage.askTurnsPerAddition
283 anchors.verticalCenter: whiteTurnsPerAddition.verticalCenter
288 id: whiteTurnsPerAddition
289 visible: newGameDialogPage.askTurnsPerAddition
292 anchors.top: whiteAdditionalTime.bottom
293 anchors.topMargin: 15
294 anchors.left: turnsPerAdditionText.right
295 anchors.leftMargin: 25
302 onClicked: {turnsDialog.player = "white"; turnsDialog.open()}
309 id: blackTurnsPerAddition
310 visible: newGameDialogPage.askTurnsPerAddition && !equalTimesSwitch.checked
313 anchors.top: whiteTurnsPerAddition.top
314 anchors.left: whiteTurnsPerAddition.right
315 anchors.leftMargin: 25
322 onClicked: {turnsDialog.player = "black"; turnsDialog.open()}
333 anchors.top: whiteTurnsPerAddition.bottom
334 anchors.topMargin: 15
335 anchors.right: parent.right
339 clocksPage.timeControl = timeControl
341 clocksPage.whiteInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
342 clocksPage.whiteAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
343 clocksPage.whiteTurnsPerAddition = whiteTurnsPerAddition.text
345 if (equalTimesSwitch.checked)
347 clocksPage.blackInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
348 clocksPage.blackAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
349 clocksPage.blackTurnsPerAddition = whiteTurnsPerAddition.text
354 clocksPage.blackInitialTime = 60*60*1000*blackInitialTime.hours+60*1000*blackInitialTime.minutes+1000*blackInitialTime.seconds
355 clocksPage.blackAdditionalTime = 60*60*1000*blackAdditionalTime.hours+60*1000*blackAdditionalTime.minutes+1000*blackAdditionalTime.seconds
356 clocksPage.blackTurnsPerAddition = blackTurnsPerAddition.text
359 pageStack.push(clocksPage)
372 property string timeType
373 property string player
375 titleText: "Choose " + timeType + " time for " + player
376 rejectButtonText: "Cancel"
377 acceptButtonText: "Ok"
378 hourMode: DateTime.TwentyFourHours
381 if (timeType == "initial")
383 if (player == "white")
385 whiteInitialTime.hours = hour
386 whiteInitialTime.minutes = minute
387 whiteInitialTime.seconds = second
391 blackInitialTime.hours = hour
392 blackInitialTime.minutes = minute
393 blackInitialTime.seconds = second
396 else if (player == "white")
398 whiteAdditionalTime.hours = hour
399 whiteAdditionalTime.minutes = minute
400 whiteAdditionalTime.seconds = second
404 blackAdditionalTime.hours = hour
405 blackAdditionalTime.minutes = minute
406 blackAdditionalTime.seconds = second
427 Component.onCompleted:
429 for (var turn = 1; turn <= 99; turn++)
431 turnsList.append({"value" : turn});
443 property string player
445 titleText: "Choose turns per addition for " + player
446 acceptButtonText: "Ok"
447 rejectButtonText: "Cancel"
449 columns: [turnsColumn]
453 if (player == "white")
454 whiteTurnsPerAddition.text = turnsColumn.selectedIndex+1
455 else if (player == "black")
456 blackTurnsPerAddition.text = turnsColumn.selectedIndex+1