--amend
This commit is contained in:
parent
b9c1a8a54f
commit
507843be21
2 changed files with 213 additions and 233 deletions
|
|
@ -139,8 +139,7 @@ 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 {
|
||||
|
|
@ -194,16 +193,13 @@ 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
|
||||
})
|
||||
}
|
||||
|
|
@ -217,8 +213,7 @@ 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
|
||||
|
|
@ -259,8 +254,7 @@ 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}`
|
||||
}
|
||||
|
|
@ -282,7 +276,7 @@ NPanel {
|
|||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||
spacing: Style.marginS * scaling
|
||||
|
||||
// Status badges
|
||||
// Connected badge
|
||||
Rectangle {
|
||||
visible: modelData.connected
|
||||
color: Color.mPrimary
|
||||
|
|
@ -299,6 +293,7 @@ NPanel {
|
|||
}
|
||||
}
|
||||
|
||||
// Saved badge - clickable
|
||||
Rectangle {
|
||||
visible: modelData.cached && !modelData.connected
|
||||
color: Color.mSurfaceVariant
|
||||
|
|
@ -308,6 +303,18 @@ NPanel {
|
|||
border.color: Color.mOutline
|
||||
border.width: Math.max(1, Style.borderS * scaling)
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
onEntered: parent.color = Qt.darker(Color.mSurfaceVariant, 1.1)
|
||||
onExited: parent.color = Color.mSurfaceVariant
|
||||
onClicked: {
|
||||
expandedNetwork = expandedNetwork === modelData.ssid ? "" : modelData.ssid
|
||||
showPasswordPrompt = false
|
||||
}
|
||||
}
|
||||
|
||||
NText {
|
||||
id: savedLabel
|
||||
anchors.centerIn: parent
|
||||
|
|
@ -317,17 +324,6 @@ NPanel {
|
|||
}
|
||||
}
|
||||
|
||||
NIconButton {
|
||||
visible: modelData.existing || modelData.cached
|
||||
icon: "more_vert"
|
||||
tooltipText: "Options"
|
||||
sizeRatio: 0.7
|
||||
onClicked: {
|
||||
expandedNetwork = expandedNetwork === modelData.ssid ? "" : modelData.ssid
|
||||
showPasswordPrompt = false
|
||||
}
|
||||
}
|
||||
|
||||
// Action buttons
|
||||
RowLayout {
|
||||
spacing: Style.marginXS * scaling
|
||||
|
|
@ -337,8 +333,7 @@ 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)) {
|
||||
|
|
@ -389,8 +384,12 @@ NPanel {
|
|||
|
||||
TextInput {
|
||||
id: passwordInputField
|
||||
anchors.fill: parent
|
||||
anchors.margins: Style.marginM * scaling
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: Style.marginM * scaling
|
||||
anchors.rightMargin: Style.marginM * scaling
|
||||
height: parent.height - (Style.marginS * scaling * 2)
|
||||
text: passwordInput
|
||||
font.pointSize: Style.fontSizeS * scaling
|
||||
color: Color.mOnSurface
|
||||
|
|
@ -423,6 +422,7 @@ NPanel {
|
|||
icon: "check"
|
||||
fontSize: Style.fontSizeXS * scaling
|
||||
enabled: passwordInput.length > 0
|
||||
outlined: !enabled
|
||||
onClicked: {
|
||||
if (passwordInput) {
|
||||
NetworkService.submitPassword(passwordPromptSsid, passwordInput)
|
||||
|
|
@ -435,7 +435,7 @@ NPanel {
|
|||
NIconButton {
|
||||
icon: "close"
|
||||
tooltipText: "Cancel"
|
||||
sizeRatio: 0.7
|
||||
sizeRatio: 0.9
|
||||
onClicked: {
|
||||
showPasswordPrompt = false
|
||||
expandedNetwork = ""
|
||||
|
|
@ -445,27 +445,24 @@ NPanel {
|
|||
}
|
||||
}
|
||||
|
||||
// Options menu (forget network)
|
||||
Rectangle {
|
||||
visible: expandedNetwork === modelData.ssid && !showPasswordPrompt && (modelData.existing
|
||||
|| modelData.cached)
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: visible ? 40 * scaling : 0
|
||||
color: Color.mSurfaceVariant
|
||||
radius: Style.radiusS * scaling
|
||||
|
||||
// Forget network option - appears when saved badge is clicked
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Style.marginS * scaling
|
||||
spacing: Style.marginM * scaling
|
||||
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 }
|
||||
|
||||
NButton {
|
||||
Layout.fillWidth: true
|
||||
id: forgetButton
|
||||
text: "Forget Network"
|
||||
icon: "delete"
|
||||
fontSize: Style.fontSizeXS * scaling
|
||||
icon: "delete_outline"
|
||||
fontSize: Style.fontSizeXXS * scaling
|
||||
backgroundColor: Color.mError
|
||||
outlined: !hovered
|
||||
textColor: !forgetButton.hovered ? Color.mError : Color.mOnTertiary
|
||||
outlined: !forgetButton.hovered
|
||||
Layout.preferredHeight: 28 * scaling
|
||||
onClicked: {
|
||||
NetworkService.forgetNetwork(modelData.ssid)
|
||||
expandedNetwork = ""
|
||||
|
|
@ -476,14 +473,12 @@ NPanel {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No networks found
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -71,23 +71,15 @@ 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"
|
||||
}
|
||||
|
|
@ -98,8 +90,7 @@ Singleton {
|
|||
|
||||
// Enhanced refresh with retry logic
|
||||
function refreshNetworks() {
|
||||
if (isLoading)
|
||||
return
|
||||
if (isLoading) return
|
||||
|
||||
isLoading = true
|
||||
retryCount = 0
|
||||
|
|
@ -400,9 +391,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
|
||||
|
|
@ -451,12 +442,9 @@ Singleton {
|
|||
const lines = text.split("\n").filter(l => l.trim())
|
||||
|
||||
for (const line of lines) {
|
||||
const [ = line.split(":")
|
||||
const [name, type] = line.split(":")
|
||||
if (name && type === "802-11-wireless") {
|
||||
profiles[name] = {
|
||||
"ssid": name,
|
||||
"type": type
|
||||
}
|
||||
profiles[name] = { ssid: name, type: type }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -488,12 +476,10 @@ Singleton {
|
|||
|
||||
for (const line of lines) {
|
||||
const parts = line.split(":")
|
||||
if (parts.length < 4)
|
||||
continue
|
||||
if (parts.length < 4) continue
|
||||
|
||||
const [ = parts
|
||||
if (!ssid)
|
||||
continue
|
||||
const [ssid, security, signalStr, inUse] = parts
|
||||
if (!ssid) continue
|
||||
|
||||
const signal = parseInt(signalStr) || 0
|
||||
const connected = inUse === "*"
|
||||
|
|
@ -507,12 +493,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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -544,8 +530,7 @@ Singleton {
|
|||
onStreamFinished: {
|
||||
root.ethernet = text.split("\n").some(line => {
|
||||
const parts = line.split(":")
|
||||
return parts[1] === "ethernet"
|
||||
&& parts[2] === "connected"
|
||||
return parts[1] === "ethernet" && parts[2] === "connected"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue