Asks confirmation upon quitting the game
[chessclock] / qml / ClocksPage.qml
index 6a34eba..f3664fa 100644 (file)
@@ -1,12 +1,95 @@
+/**************************************************************************
+
+   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.0
 import com.meego 1.0
-import QtQuick 1.1
+import QtQuick 1.1 
+import ChessClocks 1.0
+
+
 
 Page
 {
     id: clocksPage
-Rectangle {
-    width: 100
-    height: 62
-}
+
+    property int timeControl //properties cannot be declared as enumerations in QML
+                             //...must be a valid enum from WrappedClocksWidget
+    property int whiteInitialTime
+    property int blackInitialTime
+    property int whiteAdditionalTime
+    property int blackAdditionalTime
+    property int whiteTurnsPerAddition
+    property int blackTurnsPerAddition
+
+    orientationLock: PageOrientation.LockLandscape
+
+    onStatusChanged:
+    {
+        if (status == PageStatus.Activating)
+            wrappedClocksWidget.startGame(timeControl,whiteInitialTime,whiteAdditionalTime,whiteTurnsPerAddition,blackInitialTime,blackAdditionalTime,blackTurnsPerAddition)
+    }
+
+
+
+    tools: ToolBarLayout
+    {
+        ToolIcon
+        {
+            iconId: "toolbar-back"
+            onClicked:
+            {
+                confirmationDialog.open()
+            }
+        }
+
+        ToolIcon
+        {
+            iconId: "toolbar-mediacontrol-pause"
+            onClicked:
+                {
+                    wrappedClocksWidget.pause()
+                }
+        }
+
+        Item{}  //placeholder needed to put pause button in the middle
+    }
+
+
+
+
+    WrappedClocksWidget
+    {
+        id: wrappedClocksWidget
+    }
+
+
+    QueryDialog
+    {
+        id: confirmationDialog
+        titleText: "Quit?"
+        message:  "Are you sure you want to quit the game?"
+        acceptButtonText: "Quit"
+        rejectButtonText: "Continue play"
+
+        onAccepted: pageStack.pop()
+
+    }
 }