2c2dcb82453b2b0344f53be5a2b943040bbb9e26
[chessclock] / qml / ClocksPage.qml
1 /**************************************************************************
2
3    Chess Clock
4
5    This file is part of Chess Clock software.
6
7    (This file) Copyright (c) Heli Hyvättinen 2011
8
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.
13
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.
18
19
20 **************************************************************************/
21
22 import QtQuick 1.0
23 import com.meego 1.0
24 import QtQuick 1.1 
25 import ChessClocks 1.0
26
27
28
29 Page
30 {
31     id: clocksPage
32
33
34     property int timeControl //properties cannot be declared as enumerations in QML
35                              //...must be a valid enum from WrappedClocksWidget
36     property int whiteInitialTime
37     property int blackInitialTime
38     property int whiteAdditionalTime
39     property int blackAdditionalTime
40     property int whiteTurnsPerAddition
41     property int blackTurnsPerAddition
42
43     orientationLock: PageOrientation.LockLandscape
44
45     onStatusChanged:
46     {
47         if (status == PageStatus.Activating)
48             wrappedClocksWidget.startGame(timeControl,whiteInitialTime,whiteAdditionalTime,whiteTurnsPerAddition,blackInitialTime,blackAdditionalTime,blackTurnsPerAddition)
49     }
50
51     property bool appActive: applicationActive
52
53     onAppActiveChanged:
54     {
55         if (appActive == false)
56             wrappedClocksWidget.pause()
57     }
58
59     tools: ToolBarLayout
60     {
61         ToolIcon
62         {
63             iconId: "toolbar-back"
64             onClicked:
65             {
66                 wrappedClocksWidget.pause()
67                 confirmationDialog.open()
68             }
69         }
70
71         ToolIcon
72         {
73             id: pauseButton
74             iconId: "toolbar-mediacontrol-pause"
75             onClicked:
76                 {
77                     wrappedClocksWidget.pause()
78                     visible = false
79                 }
80         }
81
82         Item{}  //placeholder needed to put pause button in the middle
83
84
85     }
86
87
88
89
90     WrappedClocksWidget
91     {
92         id: wrappedClocksWidget
93         onUnPaused: pauseButton.visible = true
94     }
95
96
97     QueryDialog
98     {
99         id: confirmationDialog
100         titleText: "Quit?"
101         message:  "Are you sure you want to quit the game?"
102         acceptButtonText: "Quit"
103         rejectButtonText: "Continue play"
104
105         onAccepted:
106         {
107            pageStack.pop()
108         }
109
110     }
111 }