-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
293 lines (259 loc) · 9.31 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQml.Models 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Controls.Material 2.2
import QtQuick.Controls.Styles 1.4
import QtMultimedia 5.9
ApplicationWindow {
visible: true
title: qsTr("Chess tournament viewer")
objectName: "appWindow"
Material.foreground: "White"
Audio {
id: playMusic
source: "qrc:///ding.wav"
volume: volumeSlider.volume
}
RowLayout{
anchors.fill: parent
anchors.margins: 10
implicitWidth: 1024
implicitHeight: 512
Item{
visible: false
id:showButton
Layout.maximumWidth: 20
width: 20
Button{
Layout.margins: 0
implicitHeight: 40
anchors.verticalCenter: parent.verticalCenter
x: -implicitWidth/2
rotation: 90
text:qsTr("Show")
onClicked: {tournamentColumn.visible = true;showButton.visible = false;}
}
}
ColumnLayout{
id:tournamentColumn
Item{
id: tournmanetListHeader
Layout.preferredHeight: 30
Layout.preferredWidth: tournamentList.width
Label{
anchors.centerIn: tournmanetListHeader
text: "Tournaments";
font.bold: true
}
}
RowLayout{
Layout.fillWidth: true
Layout.preferredWidth: tournamentList.width
implicitHeight: 40
Button{
implicitHeight: parent.height
implicitWidth: 90
id: control
text: qsTr("Refresh")
onClicked:tournamentController.refreshTournamentList()
opacity: tournamentController.canRefreshTournamentList?1:0.3
}
Button{
implicitHeight: parent.height
implicitWidth: 90
id: hideButton
text: qsTr("Hide")
onClicked:{tournamentColumn.visible = false;showButton.visible = true;}
anchors.right: parent.right
}
}
TournamentList{
id: tournamentList
Layout.fillHeight: true
Layout.preferredWidth: 250
}
}
Rectangle{
color:"white"
width: 2
Layout.fillHeight: true
height: parent.height
}
ColumnLayout{
Layout.fillWidth: true
Layout.fillHeight: true
//property var currentIndex
id:tournamentView
Label{
id:tournamentNameHeader
height: 35
width: Layout.fillWidth
}
RowLayout{
id:roundRow
height: 35
Label{
anchors.verticalCenter: roundRow.verticalCenter
text: "Rounds:"
}
RoundList{
id:roundsView
Layout.fillWidth: true
height: roundRow.height
anchors.verticalCenter: roundRow.verticalCenter
}
VolumeButton{
id:volumeOffButton
}
Slider {
anchors.verticalCenter: volumeOffButton.verticalCenter
id: volumeSlider
implicitWidth: 75
implicitHeight: 32
property real volume: QtMultimedia.convertVolume(volumeSlider.value,
QtMultimedia.LogarithmicVolumeScale,
QtMultimedia.LinearVolumeScale)
property real previousVolume: 0.1
}
Button{
implicitHeight: 50
implicitWidth: 90
id: button
text: qsTr("Refresh")
onClicked:tournamentController.refreshTournament(tournamentList.currentIndex)
opacity: tournamentController.canRefreshTournament?1:0.3
}
}
/*MatchTable{
Layout.fillWidth: true
Layout.fillHeight: true
}*/
ListModel{
id: gameSelectModel
}
RowLayout{
RowLayout{
id:gameSelectView
visible: false
Label{
anchors.verticalCenter: gameSelectView.verticalCenter
text: "Games: "
}
ListView{
id:gameSelectList
orientation: ListView.Horizontal
Layout.fillWidth: true
model:gameSelectModel
height: 30
delegate: ItemDelegate{
id: gameSelectControl
height: gameSelectList.height
width: 30
contentItem:
Label{
text: gameNumber
font.pixelSize: 20
verticalAlignment: Label.AlignVCenter
horizontalAlignment: Label.AlignHCenter
}
background: Rectangle{
color: if(index === gameSelectList.currentIndex){
return Material.color(Material.Amber);
}else{
if(gameSelectMA.containsMouse){
return Material.color(Material.Grey)
}
return "transparent"
}
border.width: 2
border.color:
if(matchSqlModel.currentGameNumber()===index+1
&& control.highlighted
){
return "#7af442";
}else{
return "transparent";
}
}
MouseArea {
id:gameSelectMA
anchors.fill: parent
onClicked: {
matchSqlModel.setCurrentGameNumber(gameNumber)
gameSelectList.currentIndex = index
}
hoverEnabled: true
}
}
}
}
Slider{
id:boardSizeSlider
stepSize: 8
from: 64
to: 1024
value: 128
}
}
MatchList{
id:matchesView
Layout.fillWidth: true
Layout.fillHeight: true
}
Connections{
target:matchSqlModel
onCurrentRoundLoaded:{
gameSelectView.visible = matchSqlModel.eventType() === "knockout"
gameSelectModel.clear();
for(var i=0;i<matchSqlModel.gamesPerMatch();++i){
gameSelectModel.append({"gameNumber":i+1});
}
gameSelectList.currentIndex = matchSqlModel.currentGameNumber()-1
}
}
}
}
Dialog{
visible: !chess24Login.loggedin
id: loginWrapper
contentItem:Rectangle{
color:Material.background
implicitWidth: 300
implicitHeight: 150
id: loginDialog
ColumnLayout{
anchors.margins: 10
anchors.centerIn: loginDialog
TextField{
implicitWidth: 250
id: username
KeyNavigation.tab: password
focus: true
placeholderText: "Chess24.com username/email"
}
TextField{
implicitWidth: 250
id: password
echoMode: TextField.PasswordEchoOnEdit | null
KeyNavigation.tab: username
placeholderText: "Chess24.com password"
}
RowLayout{
Button{
text: "Login"
onClicked:chess24Login.login(username.text,password.text)
}
Button{
text:"Cancel"
onClicked: loginWrapper.visible = false
}
}
}
onVisibleChanged: if(visible){
username.forceActiveFocus()
}
}
}
}