-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMenuScreen.qml
More file actions
331 lines (293 loc) · 7.39 KB
/
MenuScreen.qml
File metadata and controls
331 lines (293 loc) · 7.39 KB
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
import QtQuick 2.1
import BasicUIControls 1.0
import qb.components 1.0
Screen {
id: root
screenTitle: qsTr("Sonos Instellingen")
onHidden: {
screenStateController.screenColorDimmedIsReachable = true;
}
onShown: {
showSonosIconToggle.isSwitchedOn = app.showSonosIcon;
voetbalToggle.isSwitchedOn = app.playFootballScores;
if (app.playFootballScores) {
if (app.sonosNameVoetbalApp.length < 2) app.sonosNameVoetbalApp = "Klik om een zone te selekteren voor de standen";
}
addCustomTopRightButton("Check Connection");
poortnummerLabel.inputText = app.poortnummer;
ipadresLabel.inputText = app.ipadresLabel;
}
onCustomButtonClicked: {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
var response = JSON.parse(xmlhttp.responseText);
if (response.length > 0) {
app.sonosName = response[0]["coordinator"]["roomName"];
hide();
if (response.length > 1) {
app.mediaSelectZone.show();
}
}
}
}
}
xmlhttp.open("GET", "http://"+app.connectionPath+"/zones");
xmlhttp.send();
}
//Next part is to have the possibility to use the keyboard for the Hostname/IP Address field and also for the portnumber!
QtObject {
id: p
property int _IP_KEYBOARD: 1
property int _PORTNUMBER_KEYBOARD: 2
}
function openKeyboard(location) {
if (location === p._PORTNUMBER_KEYBOARD) {
qkeyboard.open(qsTr("voer hier de poort in"), poortnummerLabel.inputText, savePoortnummer);
} else {
if (ipadresLabel.inputText)
qkeyboard.open(qsTr("Voer hier uw hostname of ip-adres in"), ipadresLabel.inputText, saveIpadres);
else
qkeyboard.open(qsTr("Voer hier uw hostname of ip-adres in"), "", saveIpadres);
}
}
function saveIpadres(text) {
if (text) {
app.ipadresLabel = text;
ipadresLabel.inputText = text;
savepath();
}
}
function savePoortnummer(text) {
if (text) {
app.poortnummer = text;
poortnummerLabel.inputText = text;
savepath();
}
}
function savepath(){
app.connectionPath = ipadresLabel.inputText + ":" + poortnummerLabel.inputText;
app.saveSettings();
}
Column {
id: labelContainer
anchors {
top: parent.top
topMargin: 20
left: parent.left
leftMargin: 44
right: parent.right
rightMargin: 27
}
spacing: 6
Item {
width: parent.width
height: childrenRect.height
Text {
id: titleText
anchors {
left: parent.left
}
font {
pixelSize: qfont.bodyText
family: qfont.regular.name
}
wrapMode: Text.WordWrap
text: "Configureer hier de instellingen voor Sonos-http-api server:"
}
}
Item {
width: parent.width
height: childrenRect.height
EditTextLabel4421 {
id: ipadresLabel
height: editipAdresButton.height
width: isNxt ? 800 : 600
leftText: qsTr("Hostname of ip-adres")
leftTextAvailableWidth:isNxt ? 500 : 400
onClicked: {
openKeyboard(p._IP_KEYBOARD);
}
}
IconButton {
id: editipAdresButton
width: 40
anchors {
bottom: ipadresLabel.bottom
right: parent.right
}
iconSource: "qrc:/tsc/edit.png"
onClicked: {
openKeyboard(p._IP_KEYBOARD);
}
}
}
Item {
width: parent.width
height: childrenRect.height
EditTextLabel4421 {
id: poortnummerLabel
height: editportNumberButton.height
width: isNxt ? 800 : 600
leftText: qsTr("Poortnummer (default is 5005)")
leftTextAvailableWidth:isNxt ? 500 : 400
onClicked: {
openKeyboard(p._PORTNUMBER_KEYBOARD);
}
}
IconButton {
id: editportNumberButton
width: 40
anchors {
bottom: poortnummerLabel.bottom
right: parent.right
}
iconSource: "qrc:/tsc/edit.png"
onClicked: {
openKeyboard(p._PORTNUMBER_KEYBOARD);
}
}
}
}
//here stops the first function of the keyboards!
//Next part is to give someone the option for having a systray icon (in the right upper corner)
Text {
id: systrayText
anchors {
left: parent.left
leftMargin: 44
top: labelContainer.bottom
topMargin: 20
}
font {
pixelSize: qfont.bodyText
family: qfont.regular.name
}
wrapMode: Text.WordWrap
text: app.spotifyStatus + "Sonos icoon zichtbaar op systray?"
}
OnOffToggle {
id: showSonosIconToggle
height: 36
anchors {
left: systrayText.left
top: systrayText.bottom
topMargin: 5
}
leftIsSwitchedOn: false
onSelectedChangedByUser: {
if (isSwitchedOn) {
app.saveshowSonosIcon("Yes")
} else {
app.saveshowSonosIcon("No")
}
}
}
//Next part is to allow new results from live matches of your favourite teams to be played over the Sonos speakers.
Text {
id: voetbalText
anchors {
left: parent.left
leftMargin: 44
top: showSonosIconToggle.bottom
topMargin: 20
}
font {
pixelSize: qfont.bodyText
family: qfont.regular.name
}
wrapMode: Text.WordWrap
text: "Voetbal tussenstanden afspelen (configureren via voetbal app)?"
}
OnOffToggle {
id: voetbalToggle
height: 36
anchors {
left: voetbalText.left
top: voetbalText.bottom
topMargin: 5
}
leftIsSwitchedOn: false
onSelectedChangedByUser: {
if (isSwitchedOn) {
app.saveplayScores("Yes")
if (app.sonosNameVoetbalApp.length < 2) app.sonosNameVoetbalApp = "Klik om een zone te selekteren voor de standen"
} else {
app.saveplayScores("No")
}
}
}
StandardButton {
id: btnZone
text: app.sonosNameVoetbalApp
fontPixelSize: isNxt ? 25 : 20
anchors {
bottom: voetbalToggle.bottom
left: voetbalToggle.right
leftMargin: isNxt ? 25 : 20
}
onClicked: {
if (app.mediaSelectZone) {
app.zoneToSelect = "sonosNameVoetbalApp";
app.mediaSelectZone.show();
}
}
visible: voetbalToggle.isSwitchedOn
}
//Next part is to link Spotify accounts to this app for music playback on Sonos.
StandardButton {
id: editSpotifyUsersButton
width: isNxt ? 300 : 240
radius: 5
text: "Edit Spotify accounts"
fontPixelSize: isNxt ? 25 : 20
color: colors.background
anchors {
top: btnZone.bottom
topMargin: 20
left: voetbalText.left
}
visible: (app.spotifyStatus == "configured")
onClicked: {
if (app.spotifyEditUsersScreen)
app.spotifyEditUsersScreen.show();
}
}
TextEdit {
id: explainerText
width: isNxt ? 625 : 500
height: isNxt ? 300 : 240
wrapMode: Text.WordWrap
textFormat: TextEdit.RichText
readOnly:true
text: "Om Spotify playlists te kunnen afspelen op de Sonos speakers moeten de gebruikersnamen van de spotify accounts worden ingevoerd. Deze kan je vinden in de account informatie op de Spotify app, een Spotify gebruikersnaam is typisch 34 karakters lang. Om een playlist hier te kunnen tonen moet de playlist openbaar zijn gemaakt en aan je Spotify profiel zijn toegevoegd."
font.family: qfont.semiBold.name
font.pixelSize: isNxt ? 20 : 16
anchors {
top: editSpotifyUsersButton.top
topMargin: isNxt ? -40 : -32
left: editSpotifyUsersButton.right
leftMargin: 10
}
visible: (app.spotifyStatus == "configured")
}
StandardButton {
id: editSpotifyCredentialsButton
width: isNxt ? 375 : 300
radius: 5
text: "Enable Spotify integratie"
fontPixelSize: isNxt ? 25 : 20
color: colors.background
anchors {
top: btnZone.bottom
topMargin: 20
left: voetbalText.left
}
visible: (app.spotifyStatus !== "configured")
onClicked: {
if (app.spotifyCredentialsScreen)
app.spotifyCredentialsScreen.show();
}
}
}