mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-27 06:52:50 -05:00
@@ -376,6 +376,9 @@ Rectangle {
|
|||||||
contentHeight: wifiColumn.height
|
contentHeight: wifiColumn.height
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
|
property var frozenNetworks: []
|
||||||
|
property bool menuOpen: false
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: wifiColumn
|
id: wifiColumn
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@@ -403,7 +406,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: sortedNetworks
|
model: wifiContent.menuOpen ? wifiContent.frozenNetworks : sortedNetworks
|
||||||
|
|
||||||
property var sortedNetworks: {
|
property var sortedNetworks: {
|
||||||
const ssid = NetworkService.currentWifiSSID
|
const ssid = NetworkService.currentWifiSSID
|
||||||
@@ -414,6 +417,9 @@ Rectangle {
|
|||||||
if (b.ssid === ssid) return 1
|
if (b.ssid === ssid) return 1
|
||||||
return b.signal - a.signal
|
return b.signal - a.signal
|
||||||
})
|
})
|
||||||
|
if (!wifiContent.menuOpen) {
|
||||||
|
wifiContent.frozenNetworks = sorted
|
||||||
|
}
|
||||||
return sorted
|
return sorted
|
||||||
}
|
}
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
@@ -494,11 +500,13 @@ Rectangle {
|
|||||||
if (networkContextMenu.visible) {
|
if (networkContextMenu.visible) {
|
||||||
networkContextMenu.close()
|
networkContextMenu.close()
|
||||||
} else {
|
} else {
|
||||||
|
wifiContent.menuOpen = true
|
||||||
networkContextMenu.currentSSID = modelData.ssid
|
networkContextMenu.currentSSID = modelData.ssid
|
||||||
networkContextMenu.currentSecured = modelData.secured
|
networkContextMenu.currentSecured = modelData.secured
|
||||||
networkContextMenu.currentConnected = modelData.ssid === NetworkService.currentWifiSSID
|
networkContextMenu.currentConnected = modelData.ssid === NetworkService.currentWifiSSID
|
||||||
networkContextMenu.currentSaved = modelData.saved
|
networkContextMenu.currentSaved = modelData.saved
|
||||||
networkContextMenu.currentSignal = modelData.signal
|
networkContextMenu.currentSignal = modelData.signal
|
||||||
|
networkContextMenu.currentAutoconnect = modelData.autoconnect || false
|
||||||
networkContextMenu.popup(optionsButton, -networkContextMenu.width + optionsButton.width, optionsButton.height + Theme.spacingXS)
|
networkContextMenu.popup(optionsButton, -networkContextMenu.width + optionsButton.width, optionsButton.height + Theme.spacingXS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -541,6 +549,11 @@ Rectangle {
|
|||||||
property bool currentConnected: false
|
property bool currentConnected: false
|
||||||
property bool currentSaved: false
|
property bool currentSaved: false
|
||||||
property int currentSignal: 0
|
property int currentSignal: 0
|
||||||
|
property bool currentAutoconnect: false
|
||||||
|
|
||||||
|
onClosed: {
|
||||||
|
wifiContent.menuOpen = false
|
||||||
|
}
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: Theme.popupBackground()
|
color: Theme.popupBackground()
|
||||||
@@ -606,6 +619,29 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
text: networkContextMenu.currentAutoconnect ? I18n.tr("Disable Autoconnect") : I18n.tr("Enable Autoconnect")
|
||||||
|
height: (networkContextMenu.currentSaved || networkContextMenu.currentConnected) && DMSService.apiVersion > 13 ? 32 : 0
|
||||||
|
visible: (networkContextMenu.currentSaved || networkContextMenu.currentConnected) && DMSService.apiVersion > 13
|
||||||
|
|
||||||
|
contentItem: StyledText {
|
||||||
|
text: parent.text
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.surfaceText
|
||||||
|
leftPadding: Theme.spacingS
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: parent.hovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : "transparent"
|
||||||
|
radius: Theme.cornerRadius / 2
|
||||||
|
}
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
NetworkService.setWifiAutoconnect(networkContextMenu.currentSSID, !networkContextMenu.currentAutoconnect)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: I18n.tr("Forget Network")
|
text: I18n.tr("Forget Network")
|
||||||
height: networkContextMenu.currentSaved || networkContextMenu.currentConnected ? 32 : 0
|
height: networkContextMenu.currentSaved || networkContextMenu.currentConnected ? 32 : 0
|
||||||
|
|||||||
@@ -869,4 +869,22 @@ Singleton {
|
|||||||
getState()
|
getState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setWifiAutoconnect(ssid, autoconnect) {
|
||||||
|
if (!networkAvailable || DMSService.apiVersion <= 13) return
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
ssid: ssid,
|
||||||
|
autoconnect: autoconnect
|
||||||
|
}
|
||||||
|
|
||||||
|
DMSService.sendRequest("network.wifi.setAutoconnect", params, response => {
|
||||||
|
if (response.error) {
|
||||||
|
ToastService.showError(I18n.tr("Failed to update autoconnect"))
|
||||||
|
} else {
|
||||||
|
ToastService.showInfo(autoconnect ? I18n.tr("Autoconnect enabled") : I18n.tr("Autoconnect disabled"))
|
||||||
|
Qt.callLater(() => getState())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,4 +283,10 @@ Singleton {
|
|||||||
activeService.cancelCredentials(token)
|
activeService.cancelCredentials(token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setWifiAutoconnect(ssid, autoconnect) {
|
||||||
|
if (activeService && activeService.setWifiAutoconnect) {
|
||||||
|
activeService.setWifiAutoconnect(ssid, autoconnect)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user