Testing ways to get user input
[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
140         title:Label
141         {
142             color:"white"
143             font.pointSize: 40
144             text: newGameDialog.name
145         }
146
147
148         content:
149             Grid
150             {
151                 columns: 3
152
153                 Row
154                 {
155                     id: rowRow
156                     spacing: 10
157 //                    anchors.top: parent.top
158 //                    anchors.horizontalCenter: parent.horizontalCenter
159
160                     Text
161                     {
162  //                     width: rowRow.width - rowRow.spacing - switchComponent.width - whiteSmall.width - blackSmall.width
163  //                     height: switchComponent.height
164                         verticalAlignment: Text.AlignVCenter
165                         text: "Equal times"
166                         color: "white"
167                         font.pointSize: 26
168                     }
169
170                     Switch
171                     {
172                         id: switchComponent
173                     }
174                 }
175                 Image
176                 {
177                     id: whiteSmall
178                     source: ":/rc/pic/white_small.png"
179                 }
180
181                 Image
182                 {
183                     id: blackSmall
184                     source: ":/rc/pic/black_small.png"
185                 }
186
187                 Text
188                 {
189                     id: initialTimeText
190                     text: "Initial time"
191                     color: "white"
192                     font.pointSize: 26
193 //                    anchors.top: rowRow.bottom
194 //                    anchors.horizontalCenter: parent.horizontalCenter
195 //                    visible: true
196                 }
197
198
199                 TextField
200                 {
201                     id: whiteInitialTime
202                     inputMask: "000"
203                 }
204
205
206
207                 Button
208                 {
209                     id: blackInitialTime
210                     text: "pick time"
211   //                  color: "white"
212                     onClicked: initialTimePicker.open()
213                 }
214
215
216
217                 Text
218                 {
219                     id: additionalTimeText
220                     text: "Additional time"
221                     color: "white"
222                     font.pointSize: 26
223                     visible: newGameDialog.askAddition
224 //                    anchors.top: initialTimeText.bottom
225 //                    anchors.horizontalCenter: parent.horizontalCenter
226                 }
227
228
229                 TextField
230                 {
231                     id: whiteAdditionalTime
232                     inputMask: "000"
233                 }
234
235                 ListModel
236                 {
237                     id: hoursList
238                     ListElement { value: 0}
239                     ListElement {value: 1}
240                     ListElement { value: 2}
241                 }
242
243                 TumblerColumn
244                 {
245
246                     id: hours
247                     selectedIndex: 0
248                     items: hoursList
249
250                     //for (var day = 1; day <= 31; day++) {hoursList.append({"value" : day});
251                 }
252
253 //                TumblerColumn
254 //                {
255 //                    id: minutes
256 //                    selectedIndex: 0
257 //                    items: [0,1,2]
258 //                    //for (var day = 1; day <= 31; day++) {minutesList.append({"value" : day});
259 //                }
260
261 //                TumblerColumn
262 //                {
263 //                    id: seconds
264 //                    selectedIndex:0
265 //                    items: [0,1,2]
266 //                    //for (var day = 1; day <= 31; day++) {daysList.append({"value" : day});
267 //                }
268
269 //                Tumbler
270 //                {
271 //                    columns:[hours]
272 //                }
273
274         Slider
275         {
276             id: blackAdditionalTime
277             minimumValue: 0
278             maximumValue: 100
279             value: 1
280             stepSize: 1
281             valueIndicatorVisible: true
282
283         }
284
285
286                 Text
287                 {
288                     text:  "Turns per addition"
289                     color: "white"
290                     font.pointSize: 26
291                     visible: newGameDialog.askAddition
292 //                    anchors.top: additionalTimeText.bottom
293 //                    anchors.horizontalCenter: parent.horizontalCenter
294                 }
295                 TextField
296                 {
297                     id: whiteTurnsPerAddition
298                     inputMask: "000"
299                 }
300
301                 Slider
302                 {
303                     id: blackTurnsPerAddition
304                     minimumValue: 0
305                     maximumValue: 100
306                     value: 1
307                     stepSize: 1
308                     valueIndicatorVisible: true
309
310                 }
311
312          }
313
314
315         buttons:
316
317             Button
318             {
319                 id: bOk
320                 text: "Start game"
321                 y: 150
322
323                 onClicked: newGameDialog.accept()
324             }
325     }
326
327     TimePickerDialog
328     {
329         id: initialTimePicker
330         titleText: "Choose initial time"
331     }
332
333 }
334
335
336
337