Added copyright and license info to QML files
[chessclock] / qml / MainPage.qml
index 7d27472..d7b3987 100644 (file)
@@ -1,3 +1,25 @@
+/**************************************************************************
+
+   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
@@ -134,6 +156,8 @@ Page {
         property string name
         property bool askAddition
 
+        onAccepted: pageStack.push(clocksPage)
+
 
 
         title:Label
@@ -168,7 +192,17 @@ Page {
 
                     Switch
                     {
-                        id: switchComponent
+                        id: equalTimesSwitch
+                        onCheckedChanged:
+                        {
+                            if (checked)
+                            {
+                                blackInitialTime.text = whiteInitialTime.text
+                                blackAdditionalTime.text = whiteAdditionalTime.text
+                                blackTurnsPerAddition.text = whiteTurnsPerAddition.text
+
+                            }
+                        }
                     }
                 }
                 Image
@@ -198,25 +232,33 @@ Page {
                 TextField
                 {
                     id: whiteInitialTime
-                    inputMask: "000"
                     readOnly: true
 
+                    onTextChanged: {if (equalTimesSwitch.checked) blackInitialTime.text = text}
+
                     MouseArea
                     {
                         anchors.fill: parent
-                        onClicked: initialTimePicker.open()
+                        onClicked: {timePicker.timeType = "initial";  timePicker.player = "white"; timePicker.open()}
                     }
-
                 }
 
 
 
-                Button
+                TextField
                 {
                     id: blackInitialTime
-                    text: "pick time"
-  //                  color: "white"
-                    onClicked: initialTimePicker.open()
+                    enabled: !equalTimesSwitch.checked
+
+                    readOnly: true
+
+
+
+                    MouseArea
+                    {
+                    anchors.fill: parent
+                    onClicked: {timePicker.timeType = "initial";  timePicker.player = "black"; timePicker.open()}
+                    }
                 }
 
 
@@ -233,34 +275,38 @@ Page {
                 }
 
 
+
                 TextField
                 {
                     id: whiteAdditionalTime
-                    inputMask: "000"
-                }
-
-                ListModel
-                {
-                    id: hoursList
-                    ListElement { value: 0}
-                    ListElement {value: 1}
-                    ListElement { value: 2}
-                }
+                    visible:  newGameDialog.askAddition
+                    readOnly: true
 
+                    onTextChanged: {if (equalTimesSwitch.checked) blackAdditionalTime.text = text}
 
+                    MouseArea
+                    {
+                        anchors.fill: parent
+                        onClicked: {timePicker.timeType = "additional";  timePicker.player = "white"; timePicker.open()}
+                    }
+                }
 
-        Slider
-        {
-            id: blackAdditionalTime
-            minimumValue: 0
-            maximumValue: 100
-            value: 1
-            stepSize: 1
-            valueIndicatorVisible: true
+                TextField
+                {
+                    id: blackAdditionalTime
+                    visible: newGameDialog.askAddition
+                    enabled: !equalTimesSwitch.checked
+                    readOnly: true
 
+                    MouseArea
+                    {
+                        anchors.fill: parent
+                        onClicked: {timePicker.timeType = "additional";  timePicker.player = "black"; timePicker.open()}
+                    }
         }
 
 
+
                 Text
                 {
                     text:  "Turns per addition"
@@ -273,20 +319,25 @@ Page {
                 TextField
                 {
                     id: whiteTurnsPerAddition
-                    inputMask: "000"
+                    visible: newGameDialog.askAddition
+
+                    inputMask: "D00"
+                    text: "1"
+
+                    onTextChanged: {if (equalTimesSwitch.checked) blackTurnsPerAddition.text = text}
                 }
 
-                Slider
+                TextField
                 {
                     id: blackTurnsPerAddition
-                    minimumValue: 0
-                    maximumValue: 100
-                    value: 1
-                    stepSize: 1
-                    valueIndicatorVisible: true
-
+                    visible: newGameDialog.askAddition
+                    enabled: !equalTimesSwitch.checked
+                    inputMask: "D00"
+                    text: "1"
                 }
 
+
+
          }
 
 
@@ -296,7 +347,7 @@ Page {
             {
                 id: bOk
                 text: "Start game"
-                y: 150
+                y: 45
 
                 onClicked: newGameDialog.accept()
             }
@@ -304,14 +355,33 @@ Page {
 
     TimePickerDialog
     {
-        id: initialTimePicker
-        titleText: "Choose initial time"
+        id: timePicker
+
+        property string timeType
+        property string player
+        property string result
+
+
+        titleText: "Choose " + timeType + " time for " + player
         rejectButtonText: "Cancel"
         acceptButtonText: "Ok"
         hourMode: DateTime.TwentyFourHours
-        onAccepted: blackInitialTime.text = hour + "h" + minute + "min" + second + "s"
-    }
+        onAccepted:
+        {
+            result = hour + " h " + minute + " min " + second + " s"
+            if (timeType == "initial")
+                if (player == "white")
+                    whiteInitialTime.text = result
+                else
+                    blackInitialTime.text = result
+
+            else if (player == "white")
+                    whiteAdditionalTime.text = result
+                else
+                    blackAdditionalTime.text = result
 
+        }
+    }
 }