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
49 text: newGameDialog.name
57 anchors.top: title.bottom
61 // width: rowRow.width - rowRow.spacing - switchComponent.width - whiteSmall.width - blackSmall.width
62 // height: switchComponent.height
63 verticalAlignment: Text.AlignVCenter
89 anchors.top: rowRow.bottom
90 source: ":/rc/pic/white_small.png"
98 anchors.top: rowRow.bottom
99 anchors.left: whiteSmall.right
101 source: ":/rc/pic/black_small.png"
110 anchors.top: whiteSmall.bottom
119 anchors.top: whiteSmall.bottom
120 anchors.left: initialTimeText.right
126 text: {hours + " h " + minutes + " min " + seconds + " s"}
132 onClicked: {timePicker.timeType = "initial"; timePicker.player = "white"; timePicker.open()}
141 enabled: !equalTimesSwitch.checked
145 anchors.top: whiteSmall.bottom
146 anchors.left: whiteInitialTime.right
152 text: hours + " h " + minutes + " min " + seconds + " s"
159 onClicked: {timePicker.timeType = "initial"; timePicker.player = "black"; timePicker.open()}
167 id: additionalTimeText
169 anchors.top: whiteInitialTime.bottom
171 text: "Additional time"
174 visible: newGameDialogPage.askAddition
175 // anchors.top: initialTimeText.bottom
176 // anchors.horizontalCenter: parent.horizontalCenter
183 id: whiteAdditionalTime
184 visible: newGameDialogPage.askAddition
187 anchors.top: whiteInitialTime.bottom
188 anchors.left: additionalTimeText.right
194 text: hours + " h " + minutes + " min " + seconds + " s"
200 onClicked: {timePicker.timeType = "additional"; timePicker.player = "white"; timePicker.open()}
206 id: blackAdditionalTime
207 visible: newGameDialogPage.askAddition
208 enabled: !equalTimesSwitch.checked
211 anchors.top: whiteInitialTime.bottom
212 anchors.left: whiteAdditionalTime.right
218 text: hours + " h " + minutes + " min " + seconds + " s"
223 onClicked: {timePicker.timeType = "additional"; timePicker.player = "black"; timePicker.open()}
231 id: turnsPerAdditionText
232 text: "Turns per addition"
235 visible: newGameDialogPage.askTurnsPerAddition
236 anchors.top: whiteAdditionalTime.bottom
241 id: whiteTurnsPerAddition
242 visible: newGameDialogPage.askTurnsPerAddition
245 anchors.top: whiteAdditionalTime.bottom
246 anchors.left: turnsPerAdditionText.right
253 onClicked: {turnsDialog.player = "white"; turnsDialog.open()}
260 id: blackTurnsPerAddition
261 visible: newGameDialogPage.askTurnsPerAddition
264 anchors.top: whiteAdditionalTime.bottom
265 anchors.left: whiteTurnsPerAddition.right
272 onClicked: {turnsDialog.player = "black"; turnsDialog.open()}
283 anchors.top: whiteTurnsPerAddition.bottom
287 clocksPage.timeControl = timeControl
289 clocksPage.whiteInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
290 clocksPage.whiteAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
291 clocksPage.whiteTurnsPerAddition = whiteTurnsPerAddition.text
293 if (equalTimesSwitch.checked)
295 clocksPage.blackInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
296 clocksPage.blackAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
297 clocksPage.blackTurnsPerAddition = whiteTurnsPerAddition.text
302 clocksPage.blackInitialTime = 60*60*1000*blackInitialTime.hours+60*1000*blackInitialTime.minutes+1000*blackInitialTime.seconds
303 clocksPage.blackAdditionalTime = 60*60*1000*blackAdditionalTime.hours+60*1000*blackAdditionalTime.minutes+1000*blackAdditionalTime.seconds
304 clocksPage.blackTurnsPerAddition = blackTurnsPerAddition.text
307 pageStack.push(clocksPage)
320 property string timeType
321 property string player
323 titleText: "Choose " + timeType + " time for " + player
324 rejectButtonText: "Cancel"
325 acceptButtonText: "Ok"
326 hourMode: DateTime.TwentyFourHours
329 if (timeType == "initial")
331 if (player == "white")
333 whiteInitialTime.hours = hour
334 whiteInitialTime.minutes = minute
335 whiteInitialTime.seconds = second
339 blackInitialTime.hours = hour
340 blackInitialTime.minutes = minute
341 blackInitialTime.seconds = second
344 else if (player == "white")
346 whiteAdditionalTime.hours = hour
347 whiteAdditionalTime.minutes = minute
348 whiteAdditionalTime.seconds = second
352 blackAdditionalTime.hours = hour
353 blackAdditionalTime.minutes = minute
354 blackAdditionalTime.seconds = second
375 Component.onCompleted:
377 for (var turn = 1; turn <= 99; turn++)
379 turnsList.append({"value" : turn});
391 property string player
393 titleText: "Choose turns per addition for " + player
394 acceptButtonText: "Ok"
395 rejectButtonText: "Cancel"
397 columns: [turnsColumn]
401 if (player == "white")
402 whiteTurnsPerAddition.text = turnsColumn.selectedIndex+1
403 else if (player == "black")
404 blackTurnsPerAddition.text = turnsColumn.selectedIndex+1