-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSpotifyEditUsersScreen.qml
More file actions
230 lines (192 loc) · 5.3 KB
/
SpotifyEditUsersScreen.qml
File metadata and controls
230 lines (192 loc) · 5.3 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
import QtQuick 2.1
import qb.components 1.0
import BasicUIControls 1.0;
Screen {
id: spotifyEditUsersScreen
screenTitle: "Beheren Spotify account lijst"
onShown: {
initSourcesList();
}
function initSourcesList() {
spotifyUserGroupModel.clear();
for (var i = 0; i < app.spotifyUserIDs.length; i++) {
spotifyUserGroupModel.append({name: app.spotifyUserNames[i], userid: app.spotifyUserIDs[i]});
}
}
function saveSpotifyNameLabel(text) {
if (text) {
spotifyNameLabel.inputText = text;
}
}
function saveSpotifyUserID(text) {
if (text) {
spotifyUserIDLabel.inputText = text;
}
}
Text {
id: headerText
text: "Toevoegen nieuw Spotify account aan deze app:"
font.family: qfont.semiBold.name
font.pixelSize: isNxt ? 20 : 16
anchors {
top: parent.top
left: parent.left
leftMargin: isNxt ? 38 : 30
}
}
EditTextLabel4421 {
id: spotifyNameLabel
width: isNxt ? 550 : 440
height: isNxt ? 44 : 35
leftTextAvailableWidth: isNxt ? 300 : 240
leftText: "Naam Spotify account:"
x: isNxt ? 38 : 30
y: 10
anchors {
top: parent.top
topMargin: isNxt ? 30 : 24
}
onClicked: {
qkeyboard.open("Voer de displaynaam in van het nieuwe spoptify account", spotifyNameLabel.inputText, saveSpotifyNameLabel)
}
}
IconButton {
id: spotifyNameButton
width: isNxt ? 50 : 40
iconSource: "qrc:/tsc/edit.png"
anchors {
left: spotifyNameLabel.right
leftMargin: 6
top: spotifyNameLabel.top
}
bottomClickMargin: 3
onClicked: {
qkeyboard.open("Voer de displaynaam in van het nieuwe spotify account", spotifyNameLabel.inputText, saveSpotifyNameLabel)
}
}
Text {
id: infoText1
text: "Naam van het account op de Toon"
font.family: qfont.semiBold.name
font.pixelSize: isNxt ? 20 : 16
anchors {
top: spotifyNameButton.top
left: spotifyNameButton.right
leftMargin: isNxt ? 38 : 30
}
}
EditTextLabel4421 {
id: spotifyUserIDLabel
width: spotifyNameLabel.width
height: isNxt ? 44 : 35
leftTextAvailableWidth: isNxt ? 300 : 240
leftText: "Spotify gebruikersnaam:"
anchors {
left: spotifyNameLabel.left
top: spotifyNameLabel.bottom
topMargin: 6
}
onClicked: {
qkeyboard.open("Voer de Spotify gebruikersnaam in (34 karakters):", spotifyUserIDLabel.inputText, saveSpotifyUserID)
}
}
IconButton {
id: spotifyUserIDButton;
width: isNxt ? 50 : 40
iconSource: "qrc:/tsc/edit.png"
anchors {
left: spotifyUserIDLabel.right
leftMargin: 6
top: spotifyUserIDLabel.top
}
topClickMargin: 3
onClicked: {
qkeyboard.open("Voer de Spotify gebruikersnaam in (34 karakters):", spotifyUserIDLabel.inputText, saveSpotifyUserID)
}
}
Text {
id: infoText2
text: "typisch 34 karakters lang"
font.family: qfont.semiBold.name
font.pixelSize: isNxt ? 20 : 16
anchors {
top: spotifyUserIDButton.top
left: spotifyUserIDButton.right
leftMargin: isNxt ? 38 : 30
}
}
StandardButton {
id: addNewSpotifyAccountButton
width: isNxt ? 275 : 220
height: isNxt ? 44 : 35
radius: 5
text: "Toevoegen Account"
fontPixelSize: isNxt ? 25 : 20
color: colors.background
visible : ((spotifyUserIDLabel.inputText.length > 2) && (spotifyNameLabel.inputText.length > 2))
anchors {
top: spotifyUserIDButton.top
left: spotifyUserIDButton.right
leftMargin: isNxt ? 15 : 12
}
onClicked: { //validate userid before adding
console.log("********* Spotify add user Bearer:"+ app.spotifyToken["access_token"]);
var xmlhttpSpot = new XMLHttpRequest();
xmlhttpSpot.onreadystatechange=function() {
if (xmlhttpSpot.readyState == 4) {
console.log("********* Spotify add user status:"+ xmlhttpSpot.status);
if ((xmlhttpSpot.status == 404) || (xmlhttpSpot.status == 400)) {
qdialog.showDialog(qdialog.SizeLarge, "Foutmelding", "Spotify account niet gevonden, controleer de gebruikersnaam (string van 34 karakters)." , "Sluiten");
}
if (xmlhttpSpot.status == 200) { //add user
var tempNames = app.spotifyUserNames;
var tempIDs = app.spotifyUserIDs;
tempNames.push(spotifyNameLabel.inputText);
tempIDs.push(spotifyUserIDLabel.inputText);
app.spotifyUserNames= tempNames;
app.spotifyUserIDs= tempIDs;
app.saveSettings();
initSourcesList();
}
}
}
xmlhttpSpot.open("GET", "https://api.spotify.com/v1/users/" + spotifyUserIDLabel.inputText + "/playlists");
xmlhttpSpot.setRequestHeader("Authorization", 'Bearer ' + app.spotifyToken["access_token"]);
xmlhttpSpot.send();
}
}
Text {
id: gridText
text: "Klik op een bestaand account om uit deze app te verwijderen:"
font.family: qfont.semiBold.name
font.pixelSize: isNxt ? 20 : 16
anchors {
top: spotifyUserIDLabel.bottom
topMargin: isNxt ? 25 : 20
left: spotifyUserIDLabel.left
}
}
ControlGroup {
id: spotifyUserGroup
exclusive: false
}
GridView {
id: spotifyUserGroupGridView
model: spotifyUserGroupModel
delegate: SpotifyEditUsersScreenDelegate {onRefreshUsersList: initSourcesList()}
interactive: false
flow: GridView.TopToBottom
cellWidth: isNxt ? 320 : 250
cellHeight: isNxt ? 44 : 36
height: isNxt ? parent.height - 150 : parent.height - 120
width: parent.width
anchors {
top: spotifyUserIDLabel.bottom
topMargin: isNxt ? 50 : 40
left: spotifyUserIDLabel.left
}
}
ListModel {
id: spotifyUserGroupModel
}
}