WiFi: auto formattings (removed es6 syntax for split to not break qmlfmt)
This commit is contained in:
parent
de92c989f2
commit
0567da94dd
2 changed files with 114 additions and 84 deletions
|
|
@ -139,7 +139,8 @@ NPanel {
|
|||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
visible: Settings.data.network.wifiEnabled && NetworkService.isLoading && Object.keys(NetworkService.networks).length === 0
|
||||
visible: Settings.data.network.wifiEnabled && NetworkService.isLoading && Object.keys(
|
||||
NetworkService.networks).length === 0
|
||||
spacing: Style.marginM * scaling
|
||||
|
||||
NBusyIndicator {
|
||||
|
|
@ -193,13 +194,16 @@ NPanel {
|
|||
// Network list
|
||||
Repeater {
|
||||
model: {
|
||||
if (!Settings.data.network.wifiEnabled || NetworkService.isLoading) return []
|
||||
if (!Settings.data.network.wifiEnabled || NetworkService.isLoading)
|
||||
return []
|
||||
|
||||
// Sort networks: connected first, then by signal strength
|
||||
const nets = Object.values(NetworkService.networks)
|
||||
return nets.sort((a, b) => {
|
||||
if (a.connected && !b.connected) return -1
|
||||
if (!a.connected && b.connected) return 1
|
||||
if (a.connected && !b.connected)
|
||||
return -1
|
||||
if (!a.connected && b.connected)
|
||||
return 1
|
||||
return b.signal - a.signal
|
||||
})
|
||||
}
|
||||
|
|
@ -213,7 +217,8 @@ NPanel {
|
|||
width: parent.width
|
||||
implicitHeight: networkContent.implicitHeight + (Style.marginM * scaling * 2)
|
||||
radius: Style.radiusM * scaling
|
||||
color: modelData.connected ? Qt.rgba(Color.mPrimary.r, Color.mPrimary.g, Color.mPrimary.b, 0.05) : Color.mSurface
|
||||
color: modelData.connected ? Qt.rgba(Color.mPrimary.r, Color.mPrimary.g, Color.mPrimary.b,
|
||||
0.05) : Color.mSurface
|
||||
border.width: Math.max(1, Style.borderS * scaling)
|
||||
border.color: modelData.connected ? Color.mPrimary : Color.mOutline
|
||||
clip: true
|
||||
|
|
@ -254,7 +259,8 @@ NPanel {
|
|||
|
||||
NText {
|
||||
text: {
|
||||
const security = modelData.security && modelData.security !== "--" ? modelData.security : "Open"
|
||||
const security = modelData.security
|
||||
&& modelData.security !== "--" ? modelData.security : "Open"
|
||||
const signal = `${modelData.signal}%`
|
||||
return `${signal} • ${security}`
|
||||
}
|
||||
|
|
@ -333,7 +339,8 @@ NPanel {
|
|||
visible: !modelData.connected && (expandedNetwork !== modelData.ssid || !showPasswordPrompt)
|
||||
outlined: !hovered
|
||||
fontSize: Style.fontSizeXS * scaling
|
||||
text: modelData.existing ? "Connect" : (NetworkService.isSecured(modelData.security) ? "Password" : "Connect")
|
||||
text: modelData.existing ? "Connect" : (NetworkService.isSecured(
|
||||
modelData.security) ? "Password" : "Connect")
|
||||
icon: "wifi"
|
||||
onClicked: {
|
||||
if (modelData.existing || !NetworkService.isSecured(modelData.security)) {
|
||||
|
|
@ -447,12 +454,15 @@ NPanel {
|
|||
|
||||
// Forget network option - appears when saved badge is clicked
|
||||
RowLayout {
|
||||
visible: (modelData.existing || modelData.cached) && expandedNetwork === modelData.ssid && !showPasswordPrompt
|
||||
visible: (modelData.existing || modelData.cached) && expandedNetwork === modelData.ssid
|
||||
&& !showPasswordPrompt
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: Style.marginXS * scaling
|
||||
spacing: Style.marginS * scaling
|
||||
|
||||
Item { Layout.fillWidth: true }
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NButton {
|
||||
id: forgetButton
|
||||
|
|
@ -478,7 +488,8 @@ NPanel {
|
|||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
visible: Settings.data.network.wifiEnabled && !NetworkService.isLoading && Object.keys(NetworkService.networks).length === 0
|
||||
visible: Settings.data.network.wifiEnabled && !NetworkService.isLoading && Object.keys(
|
||||
NetworkService.networks).length === 0
|
||||
spacing: Style.marginM * scaling
|
||||
|
||||
NIcon {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ Singleton {
|
|||
autoConnectTimer.start()
|
||||
}
|
||||
}
|
||||
onLoadFailed: function(error) {
|
||||
onLoadFailed: function (error) {
|
||||
Logger.log("Network", "No existing cache found, creating new one")
|
||||
// Initialize with empty data
|
||||
adapter.knownNetworks = ({})
|
||||
|
|
@ -71,15 +71,23 @@ Singleton {
|
|||
|
||||
// Signal strength icon mapping
|
||||
function signalIcon(signal) {
|
||||
const levels = [
|
||||
{ threshold: 80, icon: "network_wifi" },
|
||||
{ threshold: 60, icon: "network_wifi_3_bar" },
|
||||
{ threshold: 40, icon: "network_wifi_2_bar" },
|
||||
{ threshold: 20, icon: "network_wifi_1_bar" }
|
||||
]
|
||||
const levels = [{
|
||||
"threshold": 80,
|
||||
"icon": "network_wifi"
|
||||
}, {
|
||||
"threshold": 60,
|
||||
"icon": "network_wifi_3_bar"
|
||||
}, {
|
||||
"threshold": 40,
|
||||
"icon": "network_wifi_2_bar"
|
||||
}, {
|
||||
"threshold": 20,
|
||||
"icon": "network_wifi_1_bar"
|
||||
}]
|
||||
|
||||
for (const level of levels) {
|
||||
if (signal >= level.threshold) return level.icon
|
||||
if (signal >= level.threshold)
|
||||
return level.icon
|
||||
}
|
||||
return "signal_wifi_0_bar"
|
||||
}
|
||||
|
|
@ -90,7 +98,8 @@ Singleton {
|
|||
|
||||
// Enhanced refresh with retry logic
|
||||
function refreshNetworks() {
|
||||
if (isLoading) return
|
||||
if (isLoading)
|
||||
return
|
||||
|
||||
isLoading = true
|
||||
retryCount = 0
|
||||
|
|
@ -391,9 +400,9 @@ Singleton {
|
|||
// Update cache
|
||||
let known = adapter.knownNetworks
|
||||
known[ssid] = {
|
||||
profileName: ssid,
|
||||
lastConnected: Date.now(),
|
||||
autoConnect: true
|
||||
"profileName": ssid,
|
||||
"lastConnected": Date.now(),
|
||||
"autoConnect": true
|
||||
}
|
||||
adapter.knownNetworks = known
|
||||
adapter.lastConnected = ssid
|
||||
|
|
@ -442,9 +451,14 @@ Singleton {
|
|||
const lines = text.split("\n").filter(l => l.trim())
|
||||
|
||||
for (const line of lines) {
|
||||
const [name, type] = line.split(":")
|
||||
const parts = line.split(":")
|
||||
const name = parts[0]
|
||||
const type = parts[1]
|
||||
if (name && type === "802-11-wireless") {
|
||||
profiles[name] = { ssid: name, type: type }
|
||||
profiles[name] = {
|
||||
"ssid": name,
|
||||
"type": type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -476,10 +490,15 @@ Singleton {
|
|||
|
||||
for (const line of lines) {
|
||||
const parts = line.split(":")
|
||||
if (parts.length < 4) continue
|
||||
if (parts.length < 4)
|
||||
continue
|
||||
|
||||
const [ssid, security, signalStr, inUse] = parts
|
||||
if (!ssid) continue
|
||||
const ssid = parts[0]
|
||||
const security = parts[1]
|
||||
const signalStr = parts[2]
|
||||
const inUse = parts[3]
|
||||
if (!ssid)
|
||||
continue
|
||||
|
||||
const signal = parseInt(signalStr) || 0
|
||||
const connected = inUse === "*"
|
||||
|
|
@ -493,12 +512,12 @@ Singleton {
|
|||
// Merge with existing or create new
|
||||
if (!networksMap[ssid] || signal > networksMap[ssid].signal) {
|
||||
networksMap[ssid] = {
|
||||
ssid: ssid,
|
||||
security: security || "--",
|
||||
signal: signal,
|
||||
connected: connected,
|
||||
existing: ssid in scanProcess.existingProfiles,
|
||||
cached: ssid in adapter.knownNetworks
|
||||
"ssid": ssid,
|
||||
"security": security || "--",
|
||||
"signal": signal,
|
||||
"connected": connected,
|
||||
"existing": ssid in scanProcess.existingProfiles,
|
||||
"cached": ssid in adapter.knownNetworks
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue