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
|
||||
|
||||
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
|
||||
colorFg: Color.mOnSurface
|
||||
colorBorder: Color.transparent
|
||||
|
|
@ -44,7 +36,7 @@ NIconButton {
|
|||
}
|
||||
return connected ? NetworkService.signalIcon(signalStrength) : "wifi_find"
|
||||
} catch (error) {
|
||||
Logger.error("WiFi", "Error getting icon:", error)
|
||||
Logger.error("Wi-Fi", "Error getting icon:", error)
|
||||
return "signal_wifi_bad"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,22 +12,14 @@ ColumnLayout {
|
|||
spacing: Style.marginL * scaling
|
||||
|
||||
NToggle {
|
||||
label: "WiFi Enabled"
|
||||
description: "Enable WiFi connectivity."
|
||||
label: "Enable Wi-Fi"
|
||||
description: "Enable Wi-Fi connectivity."
|
||||
checked: Settings.data.network.wifiEnabled
|
||||
onToggled: checked => {
|
||||
Settings.data.network.wifiEnabled = checked
|
||||
NetworkService.setWifiEnabled(checked)
|
||||
if (checked) {
|
||||
ToastService.showNotice("WiFi", "Enabled")
|
||||
} else {
|
||||
ToastService.showNotice("WiFi", "Disabled")
|
||||
}
|
||||
}
|
||||
onToggled: checked => NetworkService.setWifiEnabled(checked)
|
||||
}
|
||||
|
||||
NToggle {
|
||||
label: "Bluetooth Enabled"
|
||||
label: "Enable Bluetooth"
|
||||
description: "Enable Bluetooth connectivity."
|
||||
checked: Settings.data.network.bluetoothEnabled
|
||||
onToggled: checked => {
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ NPanel {
|
|||
}
|
||||
|
||||
NText {
|
||||
text: "Scanning for networks..."
|
||||
text: "Searching for nearby networks..."
|
||||
font.pointSize: Style.fontSizeNormal * scaling
|
||||
color: Color.mOnSurfaceVariant
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
|
@ -584,7 +584,7 @@ NPanel {
|
|||
}
|
||||
|
||||
NButton {
|
||||
text: "Scan Again"
|
||||
text: "Scan again"
|
||||
icon: "refresh"
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
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: {
|
||||
Logger.log("Network", "Service initialized")
|
||||
syncWifiState()
|
||||
|
|
@ -57,16 +68,7 @@ Singleton {
|
|||
saveDebounce.restart()
|
||||
}
|
||||
|
||||
// Single refresh timer for periodic scans
|
||||
Timer {
|
||||
id: refreshTimer
|
||||
interval: 30000
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: refresh()
|
||||
}
|
||||
|
||||
// Delayed scan timer for WiFi enable
|
||||
// Delayed scan timer
|
||||
Timer {
|
||||
id: delayedScanTimer
|
||||
interval: 7000
|
||||
|
|
@ -100,6 +102,7 @@ Singleton {
|
|||
scanning = true
|
||||
lastError = ""
|
||||
scanProcess.running = true
|
||||
Logger.log("Network", "Wi-Fi scan in progress...")
|
||||
}
|
||||
|
||||
function connect(ssid, password = "") {
|
||||
|
|
@ -330,6 +333,7 @@ Singleton {
|
|||
}
|
||||
|
||||
// For logging purpose only
|
||||
Logger.log("Network", "Wi-Fi scan completed")
|
||||
const oldSSIDs = Object.keys(root.networks)
|
||||
const newSSIDs = Object.keys(nets)
|
||||
const newNetworks = newSSIDs.filter(ssid => !oldSSIDs.includes(ssid))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue