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 ToolButton { iconSource: "toolbar-back"; onClicked: pageStack.pop() }
54 text: newGameDialogPage.name
62 anchors.top: title.bottom
66 // width: rowRow.width - rowRow.spacing - switchComponent.width - whiteSmall.width - blackSmall.width
67 // height: switchComponent.height
68 verticalAlignment: Text.AlignVCenter
81 whiteSmall.anchors.horizontalCenter = undefined
82 whiteSmall.anchors.right = whiteInitialTime.horizontalCenter
84 blackSmall.anchors.horizontalCenter = undefined
85 blackSmall.anchors.left = whiteInitialTime.horizontalCenter
93 whiteSmall.anchors.right = undefined
94 whiteSmall.anchors.horizontalCenter = whiteInitialTime.horizontalCenter
96 blackSmall.anchors.left = undefined
97 blackSmall.anchors.horizontalCenter = blackInitialTime.horizontalCenter
112 anchors.top: rowRow.bottom
114 source: ":/rc/pic/white_small.png"
116 Component.onCompleted:
118 if (equalTimesSwitch.checked)
119 anchors.right = whiteInitialTime.horizontalCenter
121 anchors.horizontalCenter = whiteInitialTime.horizontalCenter
130 anchors.top: rowRow.bottom
133 source: ":/rc/pic/black_small.png"
135 Component.onCompleted:
137 if (equalTimesSwitch.checked)
138 anchors.left = whiteInitialTime.horizontalCenter
140 anchors.horizontalCenter = blackInitialTime.horizontalCenter
150 anchors.top: whiteSmall.bottom
159 anchors.top: whiteSmall.bottom
160 anchors.left: initialTimeText.right
166 text: {hours + " h " + minutes + " min " + seconds + " s"}
172 onClicked: {timePicker.timeType = "initial"; timePicker.player = "white"; timePicker.open()}
181 visible: !equalTimesSwitch.checked
185 anchors.top: whiteSmall.bottom
186 anchors.left: whiteInitialTime.right
192 text: hours + " h " + minutes + " min " + seconds + " s"
199 onClicked: {timePicker.timeType = "initial"; timePicker.player = "black"; timePicker.open()}
207 id: additionalTimeText
209 anchors.top: whiteInitialTime.bottom
211 text: "Additional time"
214 visible: newGameDialogPage.askAddition
215 // anchors.top: initialTimeText.bottom
216 // anchors.horizontalCenter: parent.horizontalCenter
223 id: whiteAdditionalTime
224 visible: newGameDialogPage.askAddition
227 anchors.top: whiteInitialTime.bottom
228 anchors.left: additionalTimeText.right
234 text: hours + " h " + minutes + " min " + seconds + " s"
240 onClicked: {timePicker.timeType = "additional"; timePicker.player = "white"; timePicker.open()}
246 id: blackAdditionalTime
247 visible: newGameDialogPage.askAddition && !equalTimesSwitch.checked
250 anchors.top: whiteInitialTime.bottom
251 anchors.left: whiteAdditionalTime.right
257 text: hours + " h " + minutes + " min " + seconds + " s"
262 onClicked: {timePicker.timeType = "additional"; timePicker.player = "black"; timePicker.open()}
270 id: turnsPerAdditionText
271 text: "Turns per addition"
274 visible: newGameDialogPage.askTurnsPerAddition
275 anchors.top: whiteAdditionalTime.bottom
280 id: whiteTurnsPerAddition
281 visible: newGameDialogPage.askTurnsPerAddition
284 anchors.top: whiteAdditionalTime.bottom
285 anchors.left: turnsPerAdditionText.right
292 onClicked: {turnsDialog.player = "white"; turnsDialog.open()}
299 id: blackTurnsPerAddition
300 visible: newGameDialogPage.askTurnsPerAddition && !equalTimesSwitch.checked
303 anchors.top: whiteAdditionalTime.bottom
304 anchors.left: whiteTurnsPerAddition.right
311 onClicked: {turnsDialog.player = "black"; turnsDialog.open()}
322 anchors.top: whiteTurnsPerAddition.bottom
323 anchors.right: parent.right
327 clocksPage.timeControl = timeControl
329 clocksPage.whiteInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
330 clocksPage.whiteAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
331 clocksPage.whiteTurnsPerAddition = whiteTurnsPerAddition.text
333 if (equalTimesSwitch.checked)
335 clocksPage.blackInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
336 clocksPage.blackAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
337 clocksPage.blackTurnsPerAddition = whiteTurnsPerAddition.text
342 clocksPage.blackInitialTime = 60*60*1000*blackInitialTime.hours+60*1000*blackInitialTime.minutes+1000*blackInitialTime.seconds
343 clocksPage.blackAdditionalTime = 60*60*1000*blackAdditionalTime.hours+60*1000*blackAdditionalTime.minutes+1000*blackAdditionalTime.seconds
344 clocksPage.blackTurnsPerAddition = blackTurnsPerAddition.text
347 pageStack.push(clocksPage)
360 property string timeType
361 property string player
363 titleText: "Choose " + timeType + " time for " + player
364 rejectButtonText: "Cancel"
365 acceptButtonText: "Ok"
366 hourMode: DateTime.TwentyFourHours
369 if (timeType == "initial")
371 if (player == "white")
373 whiteInitialTime.hours = hour
374 whiteInitialTime.minutes = minute
375 whiteInitialTime.seconds = second
379 blackInitialTime.hours = hour
380 blackInitialTime.minutes = minute
381 blackInitialTime.seconds = second
384 else if (player == "white")
386 whiteAdditionalTime.hours = hour
387 whiteAdditionalTime.minutes = minute
388 whiteAdditionalTime.seconds = second
392 blackAdditionalTime.hours = hour
393 blackAdditionalTime.minutes = minute
394 blackAdditionalTime.seconds = second
415 Component.onCompleted:
417 for (var turn = 1; turn <= 99; turn++)
419 turnsList.append({"value" : turn});
431 property string player
433 titleText: "Choose turns per addition for " + player
434 acceptButtonText: "Ok"
435 rejectButtonText: "Cancel"
437 columns: [turnsColumn]
441 if (player == "white")
442 whiteTurnsPerAddition.text = turnsColumn.selectedIndex+1
443 else if (player == "black")
444 blackTurnsPerAddition.text = turnsColumn.selectedIndex+1