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() }
52 anchors.horizontalCenter: parent.horizontalCenter
56 text: newGameDialogPage.name
64 anchors.top: title.bottom
68 // width: rowRow.width - rowRow.spacing - switchComponent.width - whiteSmall.width - blackSmall.width
69 // height: switchComponent.height
70 verticalAlignment: Text.AlignVCenter
83 whiteSmall.anchors.horizontalCenter = undefined
84 whiteSmall.anchors.right = whiteInitialTime.horizontalCenter
86 blackSmall.anchors.horizontalCenter = undefined
87 blackSmall.anchors.left = whiteInitialTime.horizontalCenter
95 whiteSmall.anchors.right = undefined
96 whiteSmall.anchors.horizontalCenter = whiteInitialTime.horizontalCenter
98 blackSmall.anchors.left = undefined
99 blackSmall.anchors.horizontalCenter = blackInitialTime.horizontalCenter
114 anchors.top: rowRow.bottom
116 source: ":/rc/pic/white_small.png"
118 Component.onCompleted:
120 if (equalTimesSwitch.checked)
121 anchors.right = whiteInitialTime.horizontalCenter
123 anchors.horizontalCenter = whiteInitialTime.horizontalCenter
132 anchors.top: rowRow.bottom
135 source: ":/rc/pic/black_small.png"
137 Component.onCompleted:
139 if (equalTimesSwitch.checked)
140 anchors.left = whiteInitialTime.horizontalCenter
142 anchors.horizontalCenter = blackInitialTime.horizontalCenter
152 anchors.verticalCenter: whiteInitialTime.verticalCenter
161 anchors.top: whiteSmall.bottom
162 anchors.left: whiteTurnsPerAddition.left
168 text: {hours + " h " + minutes + " min " + seconds + " s"}
174 onClicked: {timePicker.timeType = "initial"; timePicker.player = "white"; timePicker.open()}
183 visible: !equalTimesSwitch.checked
187 anchors.top: whiteSmall.bottom
188 anchors.left: blackTurnsPerAddition.left
194 text: hours + " h " + minutes + " min " + seconds + " s"
200 onClicked: {timePicker.timeType = "initial"; timePicker.player = "black"; timePicker.open()}
208 id: additionalTimeText
210 anchors.verticalCenter: whiteAdditionalTime.verticalCenter
212 text: "Additional time"
215 visible: newGameDialogPage.askAddition
216 // anchors.top: initialTimeText.bottom
217 // anchors.horizontalCenter: parent.horizontalCenter
224 id: whiteAdditionalTime
225 visible: newGameDialogPage.askAddition
228 anchors.top: whiteInitialTime.bottom
229 anchors.topMargin: 15
230 // anchors.left: additionalTimeText.right
231 anchors.left: whiteTurnsPerAddition.left
236 text: hours + " h " + minutes + " min " + seconds + " s"
242 onClicked: {timePicker.timeType = "additional"; timePicker.player = "white"; timePicker.open()}
248 id: blackAdditionalTime
249 visible: newGameDialogPage.askAddition && !equalTimesSwitch.checked
252 anchors.top: whiteAdditionalTime.top
253 anchors.left: blackTurnsPerAddition.left
259 text: hours + " h " + minutes + " min " + seconds + " s"
264 onClicked: {timePicker.timeType = "additional"; timePicker.player = "black"; timePicker.open()}
272 id: turnsPerAdditionText
273 text: "Turns per addition"
276 visible: newGameDialogPage.askTurnsPerAddition
277 anchors.verticalCenter: whiteTurnsPerAddition.verticalCenter
282 id: whiteTurnsPerAddition
283 visible: newGameDialogPage.askTurnsPerAddition
286 anchors.top: whiteAdditionalTime.bottom
287 anchors.topMargin: 15
288 anchors.left: turnsPerAdditionText.right
289 anchors.leftMargin: 25
296 onClicked: {turnsDialog.player = "white"; turnsDialog.open()}
303 id: blackTurnsPerAddition
304 visible: newGameDialogPage.askTurnsPerAddition && !equalTimesSwitch.checked
307 anchors.top: whiteTurnsPerAddition.top
308 anchors.left: whiteTurnsPerAddition.right
309 anchors.leftMargin: 25
316 onClicked: {turnsDialog.player = "black"; turnsDialog.open()}
327 anchors.top: whiteTurnsPerAddition.bottom
328 anchors.topMargin: 15
329 anchors.right: parent.right
333 clocksPage.timeControl = timeControl
335 clocksPage.whiteInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
336 clocksPage.whiteAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
337 clocksPage.whiteTurnsPerAddition = whiteTurnsPerAddition.text
339 if (equalTimesSwitch.checked)
341 clocksPage.blackInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
342 clocksPage.blackAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
343 clocksPage.blackTurnsPerAddition = whiteTurnsPerAddition.text
348 clocksPage.blackInitialTime = 60*60*1000*blackInitialTime.hours+60*1000*blackInitialTime.minutes+1000*blackInitialTime.seconds
349 clocksPage.blackAdditionalTime = 60*60*1000*blackAdditionalTime.hours+60*1000*blackAdditionalTime.minutes+1000*blackAdditionalTime.seconds
350 clocksPage.blackTurnsPerAddition = blackTurnsPerAddition.text
353 pageStack.push(clocksPage)
366 property string timeType
367 property string player
369 titleText: "Choose " + timeType + " time for " + player
370 rejectButtonText: "Cancel"
371 acceptButtonText: "Ok"
372 hourMode: DateTime.TwentyFourHours
375 if (timeType == "initial")
377 if (player == "white")
379 whiteInitialTime.hours = hour
380 whiteInitialTime.minutes = minute
381 whiteInitialTime.seconds = second
385 blackInitialTime.hours = hour
386 blackInitialTime.minutes = minute
387 blackInitialTime.seconds = second
390 else if (player == "white")
392 whiteAdditionalTime.hours = hour
393 whiteAdditionalTime.minutes = minute
394 whiteAdditionalTime.seconds = second
398 blackAdditionalTime.hours = hour
399 blackAdditionalTime.minutes = minute
400 blackAdditionalTime.seconds = second
421 Component.onCompleted:
423 for (var turn = 1; turn <= 99; turn++)
425 turnsList.append({"value" : turn});
437 property string player
439 titleText: "Choose turns per addition for " + player
440 acceptButtonText: "Ok"
441 rejectButtonText: "Cancel"
443 columns: [turnsColumn]
447 if (player == "white")
448 whiteTurnsPerAddition.text = turnsColumn.selectedIndex+1
449 else if (player == "black")
450 blackTurnsPerAddition.text = turnsColumn.selectedIndex+1