New game dialog is now a page
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Thu, 18 Aug 2011 14:38:24 +0000 (17:38 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Thu, 18 Aug 2011 14:38:24 +0000 (17:38 +0300)
Layout is a mess and back button is missing.

chessclock.pro
qml/MainPage.qml
qml/NewGameDialogPage.qml [new file with mode: 0644]
qml/main.qml
res.qrc

index cca7669..7217606 100644 (file)
@@ -83,6 +83,8 @@ OTHER_FILES += \
     qtc_packaging/debian_harmattan/changelog \
     qml/ClocksPage.qml \
     qml/AboutPage.qml \
+    qml/NewGameDialogPage.qml \
+    qml/NewgamedialogPage.qml
 
 
 RESOURCES += \
index 320a07b..c3f0bd0 100644 (file)
 
 import QtQuick 1.1
 import com.meego 1.0
-import QtQuick 1.0
-import com.nokia.extras 1.0
 import ChessClocks 1.0
 
 
+
 Page {
     id: mainPage
     tools: commonTools
     orientationLock: PageOrientation.LockLandscape
 
 
-
-
-
-
-//    Label {
-//        id: label
-//        anchors.centerIn: parent
-//        text: qsTr("Hello world!")
-//        visible: false
-//    }
-
-
     Image
     {
         id: bigLogo
@@ -140,12 +127,11 @@ Page {
                     anchors.fill: parent
                     onClicked:
                     {
-                        newGameDialog.name = name
-                        newGameDialog.timeControl = timeControl
-                        newGameDialog.askAddition = askAddition
-                        newGameDialog.askTurnsPerAddition = askTurnsPerAddition
-                        newGameDialog.open()
-                    }
+                        newGameDialogPage.name = name
+                        newGameDialogPage.timeControl = timeControl
+                        newGameDialogPage.askAddition = askAddition
+                        newGameDialogPage.askTurnsPerAddition = askTurnsPerAddition
+                        PageStack.push(newGameDialogPage)                     }
                 }
             }
 
@@ -161,11 +147,11 @@ Page {
                     anchors.fill: parent
                     onClicked:
                     {
-                        newGameDialog.name = name
-                        newGameDialog.timeControl = timeControl
-                        newGameDialog.askAddition = askAddition
-                        newGameDialog.askTurnsPerAddition = askTurnsPerAddition
-                        newGameDialog.open()
+                        newGameDialogPage.name = name
+                        newGameDialogPage.timeControl = timeControl
+                        newGameDialogPage.askAddition = askAddition
+                        newGameDialogPage.askTurnsPerAddition = askTurnsPerAddition
+                        pageStack.push(newGameDialogPage)
                     }
                 }
             }
@@ -173,389 +159,6 @@ Page {
         }
     }
 
-
-
-
-
-    Sheet
-    {
-        id:newGameDialog
-
-        property string name
-        property int timeControl //QML does not allow properties to be declared as enums...
-        property bool askAddition
-        property bool askTurnsPerAddition
-
-        onAccepted:
-        {
-            clocksPage.timeControl = timeControl
-
-            clocksPage.whiteInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
-            clocksPage.whiteAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
-            clocksPage.whiteTurnsPerAddition = whiteTurnsPerAddition.text
-
-            if (equalTimesSwitch.checked)
-            {
-                clocksPage.blackInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
-                clocksPage.blackAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
-                clocksPage.blackTurnsPerAddition = whiteTurnsPerAddition.text
-
-            }
-            else
-            {
-                clocksPage.blackInitialTime = 60*60*1000*blackInitialTime.hours+60*1000*blackInitialTime.minutes+1000*blackInitialTime.seconds
-                clocksPage.blackAdditionalTime = 60*60*1000*blackAdditionalTime.hours+60*1000*blackAdditionalTime.minutes+1000*blackAdditionalTime.seconds
-                clocksPage.blackTurnsPerAddition = blackTurnsPerAddition.text
-            }
-
-            pageStack.push(clocksPage)
-
-        }
-
-
-
-        acceptButtonText: "Start game"
-        rejectButtonText: "Cancel"
-
-        content:
-
-
-
-            Item
-            {
-
-                Label
-                {
-                    id: title
-
-                    color:"white"
-                    font.pointSize: 64
-                    text: newGameDialog.name
-                }
-
-                Row
-                {
-                    id: rowRow
-                    spacing: 10
-
-                    anchors.top: title.bottom
-
-                    Text
-                    {
-//                     width: rowRow.width - rowRow.spacing - switchComponent.width - whiteSmall.width - blackSmall.width
-//                     height: switchComponent.height
-                        verticalAlignment: Text.AlignVCenter
-                        text: "Equal times"
-                        color: "white"
-                        font.pointSize: 26
-                    }
-
-                    Switch
-                    {
-                        id: equalTimesSwitch
-                        onCheckedChanged:
-                        {
-                            if (checked)
-                            {
-                            }
-
-                        }
-                    }
-                }
-
-
-
-
-                Image
-                {
-                    id: whiteSmall
-
-                    anchors.top: rowRow.bottom
-                    source: ":/rc/pic/white_small.png"
-                }
-
-                Image
-                {
-
-                    id: blackSmall
-
-                    anchors.top: rowRow.bottom
-                    anchors.left: whiteSmall.right
-
-                    source: ":/rc/pic/black_small.png"
-                }
-
-                Text
-                {
-                    id: initialTimeText
-                    text: "Initial time"
-                    color: "white"
-                    font.pointSize: 26
-                    anchors.top: whiteSmall.bottom
-                  }
-
-
-                TextField
-                {
-                    id: whiteInitialTime
-                    readOnly: true
-
-                    anchors.top: whiteSmall.bottom
-                    anchors.left: initialTimeText.right
-
-                    property int hours
-                    property int minutes
-                    property int seconds
-
-                    text: {hours + " h " + minutes + " min " + seconds + " s"}
-
-
-                    MouseArea
-                    {
-                        anchors.fill: parent
-                        onClicked: {timePicker.timeType = "initial";  timePicker.player = "white"; timePicker.open()}
-                    }
-                }
-
-
-
-                TextField
-                {
-                    id: blackInitialTime
-                    enabled: !equalTimesSwitch.checked
-
-                    readOnly: true
-
-                    anchors.top: whiteSmall.bottom
-                    anchors.left:  whiteInitialTime.right
-
-                    property int hours
-                    property int minutes
-                    property int seconds
-
-                    text: hours + " h " + minutes + " min " + seconds + " s"
-
-
-
-                    MouseArea
-                    {
-                    anchors.fill: parent
-                    onClicked: {timePicker.timeType = "initial";  timePicker.player = "black"; timePicker.open()}
-                    }
-                }
-
-
-
-                Text
-                {
-                    id: additionalTimeText
-
-                    anchors.top: whiteInitialTime.bottom
-
-                    text: "Additional time"
-                    color: "white"
-                    font.pointSize: 26
-                    visible: newGameDialog.askAddition
-//                    anchors.top: initialTimeText.bottom
-//                    anchors.horizontalCenter: parent.horizontalCenter
-                }
-
-
-
-                TextField
-                {
-                    id: whiteAdditionalTime                                      
-                    visible:  newGameDialog.askAddition
-                    readOnly: true
-
-                    anchors.top: whiteInitialTime.bottom
-                    anchors.left: additionalTimeText.right
-
-                    property int hours
-                    property int minutes
-                    property int seconds
-
-                    text: hours + " h " + minutes + " min " + seconds + " s"
-
-
-                    MouseArea
-                    {
-                        anchors.fill: parent
-                        onClicked: {timePicker.timeType = "additional";  timePicker.player = "white"; timePicker.open()}
-                    }
-                }
-
-                TextField
-                {
-                    id: blackAdditionalTime
-                    visible: newGameDialog.askAddition
-                    enabled: !equalTimesSwitch.checked
-                    readOnly: true
-
-                    anchors.top: whiteInitialTime.bottom
-                    anchors.left: additionalTimeText.right
-
-                    property int hours
-                    property int minutes
-                    property int seconds
-
-                    text: hours + " h " + minutes + " min " + seconds + " s"
-
-                    MouseArea
-                    {
-                        anchors.fill: parent
-                        onClicked: {timePicker.timeType = "additional";  timePicker.player = "black"; timePicker.open()}
-                    }
-
-
-                }
-
-                Text
-                {
-                    id: turnsPerAdditionText
-                    text:  "Turns per addition"
-                    color: "white"
-                    font.pointSize: 26
-                    visible: newGameDialog.askTurnsPerAddition
-                    anchors.top: additionalTimeText.bottom
-                }
-
-                TextField
-                {
-                    id: whiteTurnsPerAddition
-                    visible: newGameDialog.askTurnsPerAddition
-                    readOnly: true;
-
-                    anchors.top: additionalTimeText.bottom
-                    anchors.left: turnsPerAdditionText.right
-
-                    text: "1"
-
-                    MouseArea
-                    {
-                        anchors.fill: parent
-                        onClicked: {turnsDialog.player = "white";  turnsDialog.open()}
-                    }
-
-                }
-
-                TextField
-                {
-                    id: blackTurnsPerAddition
-                    visible: newGameDialog.askTurnsPerAddition
-                    readOnly: true;
-
-                    anchors.top: additionalTimeText.bottom
-                    anchors.right: whiteTurnsPerAddition.left
-
-                    text: "1"
-
-                    MouseArea
-                    {
-                        anchors.fill: parent
-                        onClicked: {turnsDialog.player = "black";  turnsDialog.open()}
-                    }
-
-                }
-
-            }
-        }
-
-
-
-    TimePickerDialog
-    {
-        id: timePicker
-
-        property string timeType
-        property string player
-
-        titleText: "Choose " + timeType + " time for " + player
-        rejectButtonText: "Cancel"
-        acceptButtonText: "Ok"
-        hourMode: DateTime.TwentyFourHours
-        onAccepted:
-        {
-            if (timeType == "initial")
-            {
-                if (player == "white")
-                {
-                    whiteInitialTime.hours = hour
-                    whiteInitialTime.minutes = minute
-                    whiteInitialTime.seconds = second
-                }
-                else
-                {
-                    blackInitialTime.hours = hour
-                    blackInitialTime.minutes = minute
-                    blackInitialTime.seconds = second
-                }
-            }
-            else if (player == "white")
-                {
-                    whiteAdditionalTime.hours = hour
-                    whiteAdditionalTime.minutes = minute
-                    whiteAdditionalTime.seconds = second
-                }
-                else
-                {
-                    blackAdditionalTime.hours = hour
-                    blackAdditionalTime.minutes = minute
-                    blackAdditionalTime.seconds = second
-                }
-
-        }
-    }
-
-
-
-    TumblerColumn
-    {
-        id: turnsColumn
-        selectedIndex: 1
-        items: turnsList
-
-
-    }
-
-    ListModel
-    {
-        id: turnsList
-
-        Component.onCompleted:
-        {
-            for (var turn = 1; turn <= 99; turn++)
-                  {
-                     turnsList.append({"value" : turn});
-                  }
-
-        }
-
-    }
-
-
-    TumblerDialog
-    {
-        id: turnsDialog
-
-        property string player
-
-        titleText: "Choose turns per addition for " + player
-        acceptButtonText: "Ok"
-        rejectButtonText: "Cancel"
-
-        columns: [turnsColumn]
-
-        onAccepted:
-        {
-            if (player == "white")
-                whiteTurnsPerAddition.text = turnsColumn.selectedIndex+1
-            else if (player == "black")
-                blackTurnsPerAddition.text = turnsColumn.selectedIndex+1
-
-
-        }
-    }
 }
 
 
diff --git a/qml/NewGameDialogPage.qml b/qml/NewGameDialogPage.qml
new file mode 100644 (file)
index 0000000..2cde369
--- /dev/null
@@ -0,0 +1,406 @@
+/**************************************************************************
+
+   Chess Clock
+
+   This file is part of Chess Clock software.
+
+   (This file) Copyright (c) Heli Hyvättinen 2011
+
+   Chess Clock is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   Chess Clock is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+
+**************************************************************************/
+
+
+import QtQuick 1.1
+import com.meego 1.0
+import QtQuick 1.0
+import com.nokia.extras 1.0
+import ChessClocks 1.0
+
+
+Page {
+    id: newGameDialogPage
+    tools: commonTools
+    orientationLock: PageOrientation.LockLandscape
+
+    property string name
+    property int timeControl //QML does not allow properties to be declared as enums...
+    property bool askAddition
+    property bool askTurnsPerAddition
+
+
+
+           Label
+            {
+                id: title
+
+                color:"white"
+                font.pointSize: 64
+                text: newGameDialog.name
+            }
+
+            Row
+            {
+                id: rowRow
+                spacing: 10
+
+                anchors.top: title.bottom
+
+                Text
+                {
+//                     width: rowRow.width - rowRow.spacing - switchComponent.width - whiteSmall.width - blackSmall.width
+//                     height: switchComponent.height
+                    verticalAlignment: Text.AlignVCenter
+                    text: "Equal times"
+                    color: "white"
+                    font.pointSize: 26
+                }
+
+                Switch
+                {
+                    id: equalTimesSwitch
+                    onCheckedChanged:
+                    {
+                        if (checked)
+                        {
+                        }
+
+                    }
+                }
+            }
+
+
+
+
+            Image
+            {
+                id: whiteSmall
+
+                anchors.top: rowRow.bottom
+                source: ":/rc/pic/white_small.png"
+            }
+
+            Image
+            {
+
+                id: blackSmall
+
+                anchors.top: rowRow.bottom
+                anchors.left: whiteSmall.right
+
+                source: ":/rc/pic/black_small.png"
+            }
+
+            Text
+            {
+                id: initialTimeText
+                text: "Initial time"
+                color: "white"
+                font.pointSize: 26
+                anchors.top: whiteSmall.bottom
+              }
+
+
+            TextField
+            {
+                id: whiteInitialTime
+                readOnly: true
+
+                anchors.top: whiteSmall.bottom
+                anchors.left: initialTimeText.right
+
+                property int hours
+                property int minutes
+                property int seconds
+
+                text: {hours + " h " + minutes + " min " + seconds + " s"}
+
+
+                MouseArea
+                {
+                    anchors.fill: parent
+                    onClicked: {timePicker.timeType = "initial";  timePicker.player = "white"; timePicker.open()}
+                }
+            }
+
+
+
+            TextField
+            {
+                id: blackInitialTime
+                enabled: !equalTimesSwitch.checked
+
+                readOnly: true
+
+                anchors.top: whiteSmall.bottom
+                anchors.left:  whiteInitialTime.right
+
+                property int hours
+                property int minutes
+                property int seconds
+
+                text: hours + " h " + minutes + " min " + seconds + " s"
+
+
+
+                MouseArea
+                {
+                anchors.fill: parent
+                onClicked: {timePicker.timeType = "initial";  timePicker.player = "black"; timePicker.open()}
+                }
+            }
+
+
+
+            Text
+            {
+                id: additionalTimeText
+
+                anchors.top: whiteInitialTime.bottom
+
+                text: "Additional time"
+                color: "white"
+                font.pointSize: 26
+                visible: newGameDialog.askAddition
+//                    anchors.top: initialTimeText.bottom
+//                    anchors.horizontalCenter: parent.horizontalCenter
+            }
+
+
+
+            TextField
+            {
+                id: whiteAdditionalTime
+                visible:  newGameDialog.askAddition
+                readOnly: true
+
+                anchors.top: whiteInitialTime.bottom
+                anchors.left: additionalTimeText.right
+
+                property int hours
+                property int minutes
+                property int seconds
+
+                text: hours + " h " + minutes + " min " + seconds + " s"
+
+
+                MouseArea
+                {
+                    anchors.fill: parent
+                    onClicked: {timePicker.timeType = "additional";  timePicker.player = "white"; timePicker.open()}
+                }
+            }
+
+            TextField
+            {
+                id: blackAdditionalTime
+                visible: newGameDialog.askAddition
+                enabled: !equalTimesSwitch.checked
+                readOnly: true
+
+                anchors.top: whiteInitialTime.bottom
+                anchors.left: additionalTimeText.right
+
+                property int hours
+                property int minutes
+                property int seconds
+
+                text: hours + " h " + minutes + " min " + seconds + " s"
+
+                MouseArea
+                {
+                    anchors.fill: parent
+                    onClicked: {timePicker.timeType = "additional";  timePicker.player = "black"; timePicker.open()}
+                }
+
+
+            }
+
+            Text
+            {
+                id: turnsPerAdditionText
+                text:  "Turns per addition"
+                color: "white"
+                font.pointSize: 26
+                visible: newGameDialog.askTurnsPerAddition
+                anchors.top: additionalTimeText.bottom
+            }
+
+            TextField
+            {
+                id: whiteTurnsPerAddition
+                visible: newGameDialog.askTurnsPerAddition
+                readOnly: true;
+
+                anchors.top: additionalTimeText.bottom
+                anchors.left: turnsPerAdditionText.right
+
+                text: "1"
+
+                MouseArea
+                {
+                    anchors.fill: parent
+                    onClicked: {turnsDialog.player = "white";  turnsDialog.open()}
+                }
+
+            }
+
+            TextField
+            {
+                id: blackTurnsPerAddition
+                visible: newGameDialog.askTurnsPerAddition
+                readOnly: true;
+
+                anchors.top: additionalTimeText.bottom
+                anchors.right: whiteTurnsPerAddition.left
+
+                text: "1"
+
+                MouseArea
+                {
+                    anchors.fill: parent
+                    onClicked: {turnsDialog.player = "black";  turnsDialog.open()}
+                }
+
+            }
+
+
+            Button
+            {
+                id: okButton
+                text:  "Start game"
+                onClicked:
+                {
+                clocksPage.timeControl = timeControl
+
+                clocksPage.whiteInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
+                clocksPage.whiteAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
+                clocksPage.whiteTurnsPerAddition = whiteTurnsPerAddition.text
+
+                if (equalTimesSwitch.checked)
+                {
+                    clocksPage.blackInitialTime = 60*60*1000*whiteInitialTime.hours+60*1000*whiteInitialTime.minutes+1000*whiteInitialTime.seconds
+                    clocksPage.blackAdditionalTime = 60*60*1000*whiteAdditionalTime.hours+60*1000*whiteAdditionalTime.minutes+1000*whiteAdditionalTime.seconds
+                    clocksPage.blackTurnsPerAddition = whiteTurnsPerAddition.text
+
+                }
+                else
+                {
+                    clocksPage.blackInitialTime = 60*60*1000*blackInitialTime.hours+60*1000*blackInitialTime.minutes+1000*blackInitialTime.seconds
+                    clocksPage.blackAdditionalTime = 60*60*1000*blackAdditionalTime.hours+60*1000*blackAdditionalTime.minutes+1000*blackAdditionalTime.seconds
+                    clocksPage.blackTurnsPerAddition = blackTurnsPerAddition.text
+                }
+
+                pageStack.push(clocksPage)
+
+            }
+
+            }
+
+
+
+
+TimePickerDialog
+{
+    id: timePicker
+
+    property string timeType
+    property string player
+
+    titleText: "Choose " + timeType + " time for " + player
+    rejectButtonText: "Cancel"
+    acceptButtonText: "Ok"
+    hourMode: DateTime.TwentyFourHours
+    onAccepted:
+    {
+        if (timeType == "initial")
+        {
+            if (player == "white")
+            {
+                whiteInitialTime.hours = hour
+                whiteInitialTime.minutes = minute
+                whiteInitialTime.seconds = second
+            }
+            else
+            {
+                blackInitialTime.hours = hour
+                blackInitialTime.minutes = minute
+                blackInitialTime.seconds = second
+            }
+        }
+        else if (player == "white")
+            {
+                whiteAdditionalTime.hours = hour
+                whiteAdditionalTime.minutes = minute
+                whiteAdditionalTime.seconds = second
+            }
+            else
+            {
+                blackAdditionalTime.hours = hour
+                blackAdditionalTime.minutes = minute
+                blackAdditionalTime.seconds = second
+            }
+
+    }
+}
+
+
+
+TumblerColumn
+{
+    id: turnsColumn
+    selectedIndex: 1
+    items: turnsList
+
+
+}
+
+ListModel
+{
+    id: turnsList
+
+    Component.onCompleted:
+    {
+        for (var turn = 1; turn <= 99; turn++)
+              {
+                 turnsList.append({"value" : turn});
+              }
+
+    }
+
+}
+
+
+TumblerDialog
+{
+    id: turnsDialog
+
+    property string player
+
+    titleText: "Choose turns per addition for " + player
+    acceptButtonText: "Ok"
+    rejectButtonText: "Cancel"
+
+    columns: [turnsColumn]
+
+    onAccepted:
+    {
+        if (player == "white")
+            whiteTurnsPerAddition.text = turnsColumn.selectedIndex+1
+        else if (player == "black")
+            blackTurnsPerAddition.text = turnsColumn.selectedIndex+1
+
+
+    }
+}
+
+}
index ad21857..d2bbd54 100644 (file)
@@ -36,6 +36,8 @@ PageStackWindow {
 
     ClocksPage{id: clocksPage}
 
+    NewGameDialogPage{id: newGameDialogPage}
+
     ToolBarLayout {
         id: commonTools
         visible: true
diff --git a/res.qrc b/res.qrc
index 539837f..fa37be8 100644 (file)
--- a/res.qrc
+++ b/res.qrc
@@ -4,5 +4,6 @@
         <file>qml/MainPage.qml</file>
         <file>qml/ClocksPage.qml</file>
         <file>qml/AboutPage.qml</file>
+        <file>qml/NewGameDialogPage.qml</file>
     </qresource>
 </RCC>