Fixed black times & thumbler dialog for turns per addition
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 15 Aug 2011 17:48:28 +0000 (20:48 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 15 Aug 2011 17:51:43 +0000 (20:51 +0300)
Black initial and additional times chosen in the time picker now
delivered to the new game dialog. Also the texts for black are no longer
updated when equal times is chosen, as it is not the text that is used
to get the values. (Planning to hide black items when equal times, so no
replacement.)

qml/MainPage.qml

index c1fd1ef..e615e68 100644 (file)
@@ -279,7 +279,6 @@ Page {
 
                     text: {hours + " h " + minutes + " min " + seconds + " s"}
 
-                    onTextChanged: {if (equalTimesSwitch.checked) blackInitialTime.text = text}
 
                     MouseArea
                     {
@@ -339,7 +338,6 @@ Page {
 
                     text: hours + " h " + minutes + " min " + seconds + " s"
 
-                    onTextChanged: {if (equalTimesSwitch.checked) blackAdditionalTime.text = text}
 
                     MouseArea
                     {
@@ -379,26 +377,36 @@ Page {
 //                    anchors.top: additionalTimeText.bottom
 //                    anchors.horizontalCenter: parent.horizontalCenter
                 }
+
                 TextField
                 {
                     id: whiteTurnsPerAddition
                     visible: newGameDialog.askTurnsPerAddition
-
-                    inputMask: "D00"
+                    readOnly: true;
                     text: "1"
 
-                    onTextChanged: {if (equalTimesSwitch.checked) blackTurnsPerAddition.text = text}
-                }
+                    MouseArea
+                    {
+                        anchors.fill: parent
+                        onClicked: {turnsDialog.player = "white";  turnsDialog.open()}
+                    }
 
-                TextField
-                {
-                    id: blackTurnsPerAddition
-                    visible: newGameDialog.askTurnsPerAddition
-                    enabled: !equalTimesSwitch.checked
-                    inputMask: "D00"
-                    text: "1"
                 }
 
+        TextField
+        {
+            id: blackTurnsPerAddition
+            visible: newGameDialog.askTurnsPerAddition
+            readOnly: true;
+            text: "1"
+
+            MouseArea
+            {
+                anchors.fill: parent
+                onClicked: {turnsDialog.player = "black";  turnsDialog.open()}
+            }
+
+        }
 
 
          }
@@ -430,6 +438,7 @@ Page {
         onAccepted:
         {
             if (timeType == "initial")
+            {
                 if (player == "white")
                 {
                     whiteInitialTime.hours = hour
@@ -442,6 +451,7 @@ Page {
                     blackInitialTime.minutes = minute
                     blackInitialTime.seconds = second
                 }
+            }
             else if (player == "white")
                 {
                     whiteAdditionalTime.hours = hour
@@ -460,6 +470,53 @@ Page {
 
 
 
+    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
+
+
+        }
+    }
 }