Network/Wi-Fi: Removed auto polling every 30sec. Factorized more code and cleaned logs
This commit is contained in:
parent
fc1ee9fb2f
commit
7860c41959
4 changed files with 21 additions and 33 deletions
|
|
@ -15,14 +15,6 @@ NIconButton {
|
||||||
|
|
||||||
sizeRatio: 0.8
|
sizeRatio: 0.8
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
Logger.log("WiFi", "Widget component completed")
|
|
||||||
Logger.log("WiFi", "NetworkService available:", !!NetworkService)
|
|
||||||
if (NetworkService) {
|
|
||||||
Logger.log("WiFi", "NetworkService.networks available:", !!NetworkService.networks)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
colorBg: Color.mSurfaceVariant
|
colorBg: Color.mSurfaceVariant
|
||||||
colorFg: Color.mOnSurface
|
colorFg: Color.mOnSurface
|
||||||
colorBorder: Color.transparent
|
colorBorder: Color.transparent
|
||||||
|
|
@ -44,7 +36,7 @@ NIconButton {
|
||||||
}
|
}
|
||||||
return connected ? NetworkService.signalIcon(signalStrength) : "wifi_find"
|
return connected ? NetworkService.signalIcon(signalStrength) : "wifi_find"
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error("WiFi", "Error getting icon:", error)
|
Logger.error("Wi-Fi", "Error getting icon:", error)
|
||||||
return "signal_wifi_bad"
|
return "signal_wifi_bad"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,22 +12,14 @@ ColumnLayout {
|
||||||
spacing: Style.marginL * scaling
|
spacing: Style.marginL * scaling
|
||||||
|
|
||||||
NToggle {
|
NToggle {
|
||||||
label: "WiFi Enabled"
|
label: "Enable Wi-Fi"
|
||||||
description: "Enable WiFi connectivity."
|
description: "Enable Wi-Fi connectivity."
|
||||||
checked: Settings.data.network.wifiEnabled
|
checked: Settings.data.network.wifiEnabled
|
||||||
onToggled: checked => {
|
onToggled: checked => NetworkService.setWifiEnabled(checked)
|
||||||
Settings.data.network.wifiEnabled = checked
|
|
||||||
NetworkService.setWifiEnabled(checked)
|
|
||||||
if (checked) {
|
|
||||||
ToastService.showNotice("WiFi", "Enabled")
|
|
||||||
} else {
|
|
||||||
ToastService.showNotice("WiFi", "Disabled")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NToggle {
|
NToggle {
|
||||||
label: "Bluetooth Enabled"
|
label: "Enable Bluetooth"
|
||||||
description: "Enable Bluetooth connectivity."
|
description: "Enable Bluetooth connectivity."
|
||||||
checked: Settings.data.network.bluetoothEnabled
|
checked: Settings.data.network.bluetoothEnabled
|
||||||
onToggled: checked => {
|
onToggled: checked => {
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ NPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
NText {
|
NText {
|
||||||
text: "Scanning for networks..."
|
text: "Searching for nearby networks..."
|
||||||
font.pointSize: Style.fontSizeNormal * scaling
|
font.pointSize: Style.fontSizeNormal * scaling
|
||||||
color: Color.mOnSurfaceVariant
|
color: Color.mOnSurfaceVariant
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
@ -584,7 +584,7 @@ NPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
NButton {
|
NButton {
|
||||||
text: "Scan Again"
|
text: "Scan again"
|
||||||
icon: "refresh"
|
icon: "refresh"
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
onClicked: NetworkService.scan()
|
onClicked: NetworkService.scan()
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,17 @@ Singleton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Settings.data.network
|
||||||
|
function onWifiEnabledChanged() {
|
||||||
|
if (Settings.data.network.wifiEnabled) {
|
||||||
|
ToastService.showNotice("Wi-Fi", "Enabled")
|
||||||
|
} else {
|
||||||
|
ToastService.showNotice("Wi-Fi", "Disabled")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
Logger.log("Network", "Service initialized")
|
Logger.log("Network", "Service initialized")
|
||||||
syncWifiState()
|
syncWifiState()
|
||||||
|
|
@ -57,16 +68,7 @@ Singleton {
|
||||||
saveDebounce.restart()
|
saveDebounce.restart()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Single refresh timer for periodic scans
|
// Delayed scan timer
|
||||||
Timer {
|
|
||||||
id: refreshTimer
|
|
||||||
interval: 30000
|
|
||||||
running: true
|
|
||||||
repeat: true
|
|
||||||
onTriggered: refresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delayed scan timer for WiFi enable
|
|
||||||
Timer {
|
Timer {
|
||||||
id: delayedScanTimer
|
id: delayedScanTimer
|
||||||
interval: 7000
|
interval: 7000
|
||||||
|
|
@ -100,6 +102,7 @@ Singleton {
|
||||||
scanning = true
|
scanning = true
|
||||||
lastError = ""
|
lastError = ""
|
||||||
scanProcess.running = true
|
scanProcess.running = true
|
||||||
|
Logger.log("Network", "Wi-Fi scan in progress...")
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect(ssid, password = "") {
|
function connect(ssid, password = "") {
|
||||||
|
|
@ -330,6 +333,7 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
// For logging purpose only
|
// For logging purpose only
|
||||||
|
Logger.log("Network", "Wi-Fi scan completed")
|
||||||
const oldSSIDs = Object.keys(root.networks)
|
const oldSSIDs = Object.keys(root.networks)
|
||||||
const newSSIDs = Object.keys(nets)
|
const newSSIDs = Object.keys(nets)
|
||||||
const newNetworks = newSSIDs.filter(ssid => !oldSSIDs.includes(ssid))
|
const newNetworks = newSSIDs.filter(ssid => !oldSSIDs.includes(ssid))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue