blob: 2bb6cf64e42a7095a92003792094bcca58941f03 (
plain)
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import "." as WifiModule
Rectangle {
id: root
color: WifiModule.Style.backgroundColor
property string selectedSsid: ""
property bool showHiddenNetwork: false
property bool isConnecting: false
// Function to update language - called from C++
function updateLanguage() {
WifiModule.Translations.setLanguage(systemLocale)
}
// Initialize translations on load
Component.onCompleted: {
WifiModule.Translations.setLanguage(systemLocale)
}
ColumnLayout {
anchors.fill: parent
anchors.margins: WifiModule.Style.margin
spacing: WifiModule.Style.spacing
// Header
Label {
text: WifiModule.Translations.title
font.pixelSize: WifiModule.Style.fontSizeTitle
font.bold: true
color: WifiModule.Style.textColor
Layout.alignment: Qt.AlignHCenter
}
Label {
text: WifiModule.Translations.subtitle
font.pixelSize: WifiModule.Style.fontSizeSubtitle
color: WifiModule.Style.textSecondaryColor
wrapMode: Text.WordWrap
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
horizontalAlignment: Text.AlignHCenter
}
// Connection status banner
Rectangle {
Layout.fillWidth: true
height: 40
radius: WifiModule.Style.borderRadius
color: nm.connected ? WifiModule.Style.successColor : WifiModule.Style.progressColor
visible: nm.connected || isConnecting
RowLayout {
anchors.centerIn: parent
spacing: 10
BusyIndicator {
running: isConnecting && !nm.connected
visible: isConnecting && !nm.connected
Layout.preferredWidth: 24
Layout.preferredHeight: 24
}
Label {
text: nm.connected ? WifiModule.Translations.connected : WifiModule.Translations.connecting
color: WifiModule.Style.textColor
font.pixelSize: WifiModule.Style.fontSizeNormal
font.bold: true
}
}
}
// Network list
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true
color: WifiModule.Style.listBackgroundColor
radius: WifiModule.Style.borderRadiusLarge
border.color: WifiModule.Style.borderColor
border.width: 1
ColumnLayout {
anchors.fill: parent
anchors.margins: 1
spacing: 0
// List header with refresh button
Rectangle {
Layout.fillWidth: true
height: 44
color: WifiModule.Style.listHeaderColor
radius: WifiModule.Style.borderRadiusLarge
Rectangle {
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
height: 8
color: parent.color
}
RowLayout {
anchors.fill: parent
anchors.leftMargin: 12
anchors.rightMargin: 8
Label {
text: WifiModule.Translations.availableNetworks
color: WifiModule.Style.textColor
font.pixelSize: WifiModule.Style.fontSizeSmall
font.bold: true
}
Item { Layout.fillWidth: true }
Button {
text: WifiModule.Translations.refresh
Layout.preferredHeight: 32
onClicked: nm.scan()
background: Rectangle {
color: parent.hovered ? WifiModule.Style.buttonSecondaryHoverColor : WifiModule.Style.buttonSecondaryColor
radius: 4
}
contentItem: Label {
text: parent.text
color: WifiModule.Style.textColor
font.pixelSize: WifiModule.Style.fontSizeSmall
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
}
}
// WiFi list
ListView {
id: networkList
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
model: nm.networks
delegate: Rectangle {
width: networkList.width
height: WifiModule.Style.listItemHeight
color: modelData === selectedSsid ? WifiModule.Style.itemSelectedColor :
(mouseArea.containsMouse ? WifiModule.Style.itemHoverColor : "transparent")
RowLayout {
anchors.fill: parent
anchors.leftMargin: 16
anchors.rightMargin: 16
spacing: 12
Label {
text: ""
font.pixelSize: 18
}
Label {
text: modelData
color: WifiModule.Style.textColor
font.pixelSize: WifiModule.Style.fontSizeNormal
Layout.fillWidth: true
elide: Text.ElideRight
}
Label {
text: modelData === selectedSsid ? "✓" : ""
color: WifiModule.Style.successCheckColor
font.pixelSize: 16
font.bold: true
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
selectedSsid = modelData
showHiddenNetwork = false
ssidField.text = modelData
}
}
Rectangle {
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
anchors.rightMargin: 16
height: 1
color: WifiModule.Style.separatorColor
}
}
Label {
anchors.centerIn: parent
text: WifiModule.Translations.noNetworks
color: WifiModule.Style.textMutedColor
font.pixelSize: WifiModule.Style.fontSizeSmall
horizontalAlignment: Text.AlignHCenter
visible: nm.networks.length === 0
}
}
}
}
// Hidden network toggle
Rectangle {
Layout.fillWidth: true
height: WifiModule.Style.inputHeight
color: "#3d7839"
radius: WifiModule.Style.borderRadius
MouseArea {
anchors.fill: parent
onClicked: {
showHiddenNetwork = !showHiddenNetwork
if (showHiddenNetwork) {
selectedSsid = ""
ssidField.text = ""
ssidField.focus = true
}
}
}
RowLayout {
anchors.fill: parent
anchors.leftMargin: 16
anchors.rightMargin: 16
Label {
text: WifiModule.Translations.hiddenNetwork
color: WifiModule.Style.textColor
font.pixelSize: WifiModule.Style.fontSizeNormal
}
Item { Layout.fillWidth: true }
Rectangle {
width: 44
height: 24
radius: 12
color: showHiddenNetwork ? WifiModule.Style.toggleOnColor : WifiModule.Style.toggleOffColor
Rectangle {
width: 20
height: 20
radius: 10
color: WifiModule.Style.textColor
x: showHiddenNetwork ? 22 : 2
anchors.verticalCenter: parent.verticalCenter
Behavior on x {
NumberAnimation { duration: 150 }
}
}
}
}
}
// SSID field (for hidden networks)
TextField {
id: ssidField
Layout.fillWidth: true
placeholderText: WifiModule.Translations.ssidPlaceholder
visible: showHiddenNetwork
color: WifiModule.Style.textColor
placeholderTextColor: WifiModule.Style.inputPlaceholderColor
font.pixelSize: WifiModule.Style.fontSizeNormal
background: Rectangle {
color: WifiModule.Style.inputBackgroundColor
radius: WifiModule.Style.borderRadius
border.color: ssidField.focus ? WifiModule.Style.inputFocusBorderColor : WifiModule.Style.inputBorderColor
border.width: 1
}
}
// Password field
TextField {
id: passField
Layout.fillWidth: true
placeholderText: WifiModule.Translations.passwordPlaceholder
echoMode: TextInput.Password
color: WifiModule.Style.textColor
placeholderTextColor: WifiModule.Style.inputPlaceholderColor
font.pixelSize: WifiModule.Style.fontSizeNormal
enabled: selectedSsid !== "" || showHiddenNetwork
opacity: 1
background: Rectangle {
color: passField.enabled ? WifiModule.Style.inputBackgroundColor : WifiModule.Style.inputDisabledColor
radius: WifiModule.Style.borderRadius
border.color: passField.focus ? WifiModule.Style.inputFocusBorderColor : WifiModule.Style.inputBorderColor
border.width: 1
}
}
// Connect button
Button {
Layout.fillWidth: true
Layout.preferredHeight: WifiModule.Style.buttonHeight
text: WifiModule.Translations.connect
enabled: (selectedSsid !== "" || (showHiddenNetwork && ssidField.text !== "")) &&
passField.text !== "" && !isConnecting && !nm.connected
onClicked: {
isConnecting = true
var ssid = showHiddenNetwork ? ssidField.text : selectedSsid
nm.connectTo(ssid, passField.text)
}
background: Rectangle {
color: parent.enabled ? (parent.hovered ? WifiModule.Style.buttonPrimaryHoverColor : WifiModule.Style.buttonPrimaryColor) : WifiModule.Style.buttonDisabledColor
radius: WifiModule.Style.borderRadius
}
contentItem: Label {
text: parent.text
color: parent.enabled ? WifiModule.Style.textColor : WifiModule.Style.textDisabledColor
font.pixelSize: 15
font.bold: true
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
// Skip info
Label {
text: nm.connected ?
WifiModule.Translations.clickNextToContinue :
WifiModule.Translations.canSkipWithEthernet
color: WifiModule.Style.textMutedColor
font.pixelSize: WifiModule.Style.fontSizeTiny
Layout.alignment: Qt.AlignHCenter
horizontalAlignment: Text.AlignHCenter
}
}
// Connection state change handler
Connections {
target: nm
function onConnectionChanged() {
if (nm.connected) {
isConnecting = false
}
}
function onConnectionFailed(error) {
isConnecting = false
console.log("Connection failed: " + error)
}
}
// Timer to reset connecting state if it takes too long
Timer {
id: connectTimeout
interval: 30000
running: isConnecting
onTriggered: {
if (!nm.connected) {
isConnecting = false
}
}
}
}
|