Working choose time dialog
[chessclock] / qml / MainPage.qml
1 import QtQuick 1.1
2 import com.meego 1.0
3 import QtQuick 1.0
4 import com.nokia.extras 1.0
5
6
7 Page {
8     id: mainPage
9     tools: commonTools
10
11
12
13
14
15
16 //    Label {
17 //        id: label
18 //        anchors.centerIn: parent
19 //        text: qsTr("Hello world!")
20 //        visible: false
21 //    }
22
23
24     Image
25     {
26         id: bigLogo
27 //        anchors.fill: parent
28 //        anchors.left: menuList.right
29
30         source: ":/rc/pic/logo.png"
31     }
32
33     ListModel
34     {
35         id: menuModel
36
37         ListElement
38         {
39             name: "Normal clock"
40             askAddition: false
41             logoFile: ":/rc/pic/oldclock.png"
42
43
44         }
45
46         ListElement
47         {
48             name: "Addition before"
49             askAddition: true
50             logoFile: ":/rc/pic/addbefore.png"
51         }
52
53         ListElement
54         {
55             name: "Addition after"
56             askAddition: true
57             logoFile: ":/rc/pic/addafter.png"
58         }
59
60         ListElement
61         {
62             name: "Delay"
63             askAddition: true
64             logoFile: ":/rc/pic/pausebefore.png"
65         }
66
67         ListElement
68         {
69             name: "Delay after"
70             askAddition: true
71             logoFile: ":/rc/pic/pauseafter.png"
72         }
73
74         ListElement
75         {
76             name:"Hour Glass"
77             askAddition: false
78             logoFile:":/rc/pic/hourglass.png"
79         }
80
81     }
82
83
84     ListView
85     {
86         id: menuList
87
88         anchors.left: bigLogo.right
89         anchors.right: parent.right
90         anchors.top: parent.top
91         anchors.bottom: parent.bottom
92
93
94          model: menuModel
95
96          delegate: Row
97          {
98             Image
99             {
100                 source: logoFile
101
102                 MouseArea
103                 {
104                     anchors.fill: parent
105                     onClicked: {newGameDialog.name = name; newGameDialog.askAddition = askAddition; newGameDialog.open()}
106                 }
107             }
108
109             Text
110             {
111                 text: name
112                 font.pointSize: 40
113                 anchors.topMargin: 12
114                 color: "white"
115
116                 MouseArea
117                 {
118                     anchors.fill: parent
119                     onClicked: {newGameDialog.name = name; newGameDialog.askAddition = askAddition; newGameDialog.open()}
120                 }
121             }
122
123         }
124     }
125
126
127
128
129
130     Dialog
131     {
132         id:newGameDialog
133
134         property string name
135         property bool askAddition
136
137
138
139         title:Label
140         {
141             color:"white"
142             font.pointSize: 64
143             text: newGameDialog.name
144         }
145
146
147         content:
148             Grid
149             {
150                 columns: 3
151
152                 Row
153                 {
154                     id: rowRow
155                     spacing: 10
156 //                    anchors.top: parent.top
157 //                    anchors.horizontalCenter: parent.horizontalCenter
158
159                     Text
160                     {
161  //                     width: rowRow.width - rowRow.spacing - switchComponent.width - whiteSmall.width - blackSmall.width
162  //                     height: switchComponent.height
163                         verticalAlignment: Text.AlignVCenter
164                         text: "Equal times"
165                         color: "white"
166                         font.pointSize: 26
167                     }
168
169                     Switch
170                     {
171                         id: switchComponent
172                     }
173                 }
174                 Image
175                 {
176                     id: whiteSmall
177                     source: ":/rc/pic/white_small.png"
178                 }
179
180                 Image
181                 {
182                     id: blackSmall
183                     source: ":/rc/pic/black_small.png"
184                 }
185
186                 Text
187                 {
188                     id: initialTimeText
189                     text: "Initial time"
190                     color: "white"
191                     font.pointSize: 26
192 //                    anchors.top: rowRow.bottom
193 //                    anchors.horizontalCenter: parent.horizontalCenter
194 //                    visible: true
195                 }
196
197
198                 TextField
199                 {
200                     id: whiteInitialTime
201                     readOnly: true
202
203                     MouseArea
204                     {
205                         anchors.fill: parent
206                         onClicked: {timePicker.timeType = "initial";  timePicker.player = "white"; timePicker.open()}
207                     }
208                 }
209
210
211
212                 TextField
213                 {
214                     id: blackInitialTime
215                     readOnly: true
216
217                     MouseArea
218                     {
219                     anchors.fill: parent
220                     onClicked: {timePicker.timeType = "initial";  timePicker.player = "black"; timePicker.open()}
221                     }
222                 }
223
224
225
226                 Text
227                 {
228                     id: additionalTimeText
229                     text: "Additional time"
230                     color: "white"
231                     font.pointSize: 26
232                     visible: newGameDialog.askAddition
233 //                    anchors.top: initialTimeText.bottom
234 //                    anchors.horizontalCenter: parent.horizontalCenter
235                 }
236
237
238
239                 TextField
240                 {
241                     id: whiteAdditionalTime
242                     readOnly: true
243
244                     MouseArea
245                     {
246                         anchors.fill: parent
247                         onClicked: {timePicker.timeType = "additional";  timePicker.player = "white"; timePicker.open()}                    }
248                 }
249
250                 TextField
251                 {
252                     id: blackAdditionalTime
253                     readOnly: true
254
255                     MouseArea
256                     {
257                         anchors.fill: parent
258                         onClicked: {timePicker.timeType = "additional";  timePicker.player = "black"; timePicker.open()}
259                     }
260         }
261
262
263
264                 Text
265                 {
266                     text:  "Turns per addition"
267                     color: "white"
268                     font.pointSize: 26
269                     visible: newGameDialog.askAddition
270 //                    anchors.top: additionalTimeText.bottom
271 //                    anchors.horizontalCenter: parent.horizontalCenter
272                 }
273                 TextField
274                 {
275                     id: whiteTurnsPerAddition
276                     inputMask: "D00"
277                     text: "1"
278                 }
279
280                 TextField
281                 {
282                     id: blackTurnsPerAddition
283                     inputMask: "D00"
284                     text: "1"
285                 }
286
287
288
289          }
290
291
292         buttons:
293
294             Button
295             {
296                 id: bOk
297                 text: "Start game"
298                 y: 45
299
300                 onClicked: newGameDialog.accept()
301             }
302     }
303
304     TimePickerDialog
305     {
306         id: timePicker
307
308         property string timeType
309         property string player
310         property string result
311
312
313         titleText: "Choose " + timeType + " time for " + player
314         rejectButtonText: "Cancel"
315         acceptButtonText: "Ok"
316         hourMode: DateTime.TwentyFourHours
317         onAccepted:
318         {
319             result = hour + " h " + minute + " min " + second + " s"
320             if (timeType == "initial")
321                 if (player == "white")
322                     whiteInitialTime.text = result
323                 else
324                     blackInitialTime.text = result
325
326             else if (player == "white")
327                     whiteAdditionalTime.text = result
328                 else
329                     blackAdditionalTime.text = result
330
331         }
332     }
333 }
334
335
336
337