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
33 orientationLock: PageOrientation.LockLandscape
42 // anchors.centerIn: parent
43 // text: qsTr("Hello world!")
51 // anchors.fill: parent
52 // anchors.left: menuList.right
54 source: ":/rc/pic/logo.png"
64 timeControl: WrappedClocksWidget.NormalClock
66 askTurnsPerAddition: false
67 logoFile: ":/rc/pic/oldclock.png"
74 name: "Addition before"
75 timeControl: WrappedClocksWidget.AdditionBefore
77 askTurnsPerAddition: true
78 logoFile: ":/rc/pic/addbefore.png"
83 name: "Addition after"
84 timeControl: WrappedClocksWidget.AdditionAfter
86 askTurnsPerAddition: true
87 logoFile: ":/rc/pic/addafter.png"
93 timeControl: WrappedClocksWidget.Delay
95 askTurnsPerAddition: false
96 logoFile: ":/rc/pic/pausebefore.png"
102 timeControl: WrappedClocksWidget.DelayAfter
104 askTurnsPerAddition: false
105 logoFile: ":/rc/pic/pauseafter.png"
111 timeControl: WrappedClocksWidget.HourGlass
113 askTurnsPerAddition: false
114 logoFile:":/rc/pic/hourglass.png"
124 anchors.left: bigLogo.right
125 anchors.right: parent.right
126 anchors.top: parent.top
127 anchors.bottom: parent.bottom
143 newGameDialog.name = name
144 newGameDialog.timeControl = timeControl
145 newGameDialog.askAddition = askAddition
146 newGameDialog.askTurnsPerAddition = askTurnsPerAddition
156 anchors.topMargin: 12
164 newGameDialog.name = name
165 newGameDialog.timeControl = timeControl
166 newGameDialog.askAddition = askAddition
167 newGameDialog.askTurnsPerAddition = askTurnsPerAddition
185 property int timeControl //QML does not allow properties to be declared as enums...
186 property bool askAddition
187 property bool askTurnsPerAddition
191 clocksPage.timeControl = timeControl
192 clocksPage.whiteInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
193 clocksPage.blackInitialTime = 60*60*1000*blackInitialTime.hours+60*1000*blackInitialTime.minutes+1000*blackInitialTime.seconds
194 clocksPage.whiteAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
195 clocksPage.blackAdditionalTime = 60*60*1000*blackAdditionalTime.hours+60*1000*blackAdditionalTime.minutes+1000*blackAdditionalTime.seconds
196 clocksPage.whiteTurnsPerAddition = whiteTurnsPerAddition.text
197 clocksPage.blackTurnsPerAddition = blackTurnsPerAddition.text
198 pageStack.push(clocksPage)
206 text: newGameDialog.name
219 // anchors.top: parent.top
220 // anchors.horizontalCenter: parent.horizontalCenter
224 // width: rowRow.width - rowRow.spacing - switchComponent.width - whiteSmall.width - blackSmall.width
225 // height: switchComponent.height
226 verticalAlignment: Text.AlignVCenter
239 blackInitialTime.text = whiteInitialTime.text
240 blackAdditionalTime.text = whiteAdditionalTime.text
241 blackTurnsPerAddition.text = whiteTurnsPerAddition.text
250 source: ":/rc/pic/white_small.png"
256 source: ":/rc/pic/black_small.png"
265 // anchors.top: rowRow.bottom
266 // anchors.horizontalCenter: parent.horizontalCenter
280 text: {hours + " h " + minutes + " min " + seconds + " s"}
282 onTextChanged: {if (equalTimesSwitch.checked) blackInitialTime.text = text}
287 onClicked: {timePicker.timeType = "initial"; timePicker.player = "white"; timePicker.open()}
296 enabled: !equalTimesSwitch.checked
304 text: hours + " h " + minutes + " min " + seconds + " s"
311 onClicked: {timePicker.timeType = "initial"; timePicker.player = "black"; timePicker.open()}
319 id: additionalTimeText
320 text: "Additional time"
323 visible: newGameDialog.askAddition
324 // anchors.top: initialTimeText.bottom
325 // anchors.horizontalCenter: parent.horizontalCenter
332 id: whiteAdditionalTime
333 visible: newGameDialog.askAddition
340 text: hours + " h " + minutes + " min " + seconds + " s"
342 onTextChanged: {if (equalTimesSwitch.checked) blackAdditionalTime.text = text}
347 onClicked: {timePicker.timeType = "additional"; timePicker.player = "white"; timePicker.open()}
353 id: blackAdditionalTime
354 visible: newGameDialog.askAddition
355 enabled: !equalTimesSwitch.checked
362 text: hours + " h " + minutes + " min " + seconds + " s"
367 onClicked: {timePicker.timeType = "additional"; timePicker.player = "black"; timePicker.open()}
375 text: "Turns per addition"
378 visible: newGameDialog.askTurnsPerAddition
379 // anchors.top: additionalTimeText.bottom
380 // anchors.horizontalCenter: parent.horizontalCenter
384 id: whiteTurnsPerAddition
385 visible: newGameDialog.askTurnsPerAddition
390 onTextChanged: {if (equalTimesSwitch.checked) blackTurnsPerAddition.text = text}
395 id: blackTurnsPerAddition
396 visible: newGameDialog.askTurnsPerAddition
397 enabled: !equalTimesSwitch.checked
415 onClicked: newGameDialog.accept()
423 property string timeType
424 property string player
426 titleText: "Choose " + timeType + " time for " + player
427 rejectButtonText: "Cancel"
428 acceptButtonText: "Ok"
429 hourMode: DateTime.TwentyFourHours
432 if (timeType == "initial")
433 if (player == "white")
435 whiteInitialTime.hours = hour
436 whiteInitialTime.minutes = minute
437 whiteInitialTime.seconds = second
441 blackInitialTime.hours = hour
442 blackInitialTime.minutes = minute
443 blackInitialTime.seconds = second
445 else if (player == "white")
447 whiteAdditionalTime.hours = hour
448 whiteAdditionalTime.minutes = minute
449 whiteAdditionalTime.seconds = second
453 blackAdditionalTime.hours = hour
454 blackAdditionalTime.minutes = minute
455 blackAdditionalTime.seconds = second