1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-24 12:05:21 -04:00

fix(network): show WiFi connection progress (#2684)

This commit is contained in:
NihilDigit
2026-06-23 21:19:37 +08:00
committed by GitHub
parent bed6622530
commit a98c4f6c54
3 changed files with 59 additions and 13 deletions
@@ -565,6 +565,7 @@ Rectangle {
required property int index required property int index
readonly property bool isConnected: modelData.ssid === NetworkService.currentWifiSSID readonly property bool isConnected: modelData.ssid === NetworkService.currentWifiSSID
readonly property bool isConnecting: NetworkService.isWifiConnecting && NetworkService.connectingSSID === modelData.ssid
readonly property bool isPinned: root.getPinnedNetworks().includes(modelData.ssid) readonly property bool isPinned: root.getPinnedNetworks().includes(modelData.ssid)
readonly property string networkName: modelData.ssid || I18n.tr("Unknown Network") readonly property string networkName: modelData.ssid || I18n.tr("Unknown Network")
readonly property int signalStrength: modelData.signal || 0 readonly property int signalStrength: modelData.signal || 0
@@ -583,7 +584,17 @@ Rectangle {
anchors.leftMargin: Theme.spacingM anchors.leftMargin: Theme.spacingM
spacing: Theme.spacingS spacing: Theme.spacingS
DankSpinner {
size: Theme.iconSize - 4
strokeWidth: 2
color: Theme.warning
running: wifiDelegate.isConnecting
visible: wifiDelegate.isConnecting
anchors.verticalCenter: parent.verticalCenter
}
DankIcon { DankIcon {
visible: !wifiDelegate.isConnecting
name: { name: {
if (wifiDelegate.signalStrength >= 50) if (wifiDelegate.signalStrength >= 50)
return "wifi"; return "wifi";
@@ -603,7 +614,7 @@ Rectangle {
StyledText { StyledText {
text: wifiDelegate.networkName text: wifiDelegate.networkName
font.pixelSize: Theme.fontSizeMedium font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceText color: wifiDelegate.isConnected ? Theme.primary : Theme.surfaceText
font.weight: wifiDelegate.isConnected ? Font.Medium : Font.Normal font.weight: wifiDelegate.isConnected ? Font.Medium : Font.Normal
elide: Text.ElideRight elide: Text.ElideRight
width: parent.width width: parent.width
@@ -613,9 +624,9 @@ Rectangle {
spacing: Theme.spacingXS spacing: Theme.spacingXS
StyledText { StyledText {
text: wifiDelegate.isConnected ? I18n.tr("Connected") + " \u2022" : (modelData.secured ? I18n.tr("Secured") + " \u2022" : I18n.tr("Open") + " \u2022") text: wifiDelegate.isConnecting ? I18n.tr("Connecting...") + " \u2022" : (wifiDelegate.isConnected ? I18n.tr("Connected") + " \u2022" : (modelData.secured ? I18n.tr("Secured") + " \u2022" : I18n.tr("Open") + " \u2022"))
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText color: wifiDelegate.isConnecting ? Theme.warning : Theme.surfaceVariantText
} }
StyledText { StyledText {
@@ -651,6 +662,7 @@ Rectangle {
networkContextMenu.currentSecured = modelData.secured; networkContextMenu.currentSecured = modelData.secured;
networkContextMenu.currentEnterprise = modelData.enterprise; networkContextMenu.currentEnterprise = modelData.enterprise;
networkContextMenu.currentConnected = wifiDelegate.isConnected; networkContextMenu.currentConnected = wifiDelegate.isConnected;
networkContextMenu.currentConnecting = wifiDelegate.isConnecting;
networkContextMenu.currentSaved = modelData.saved; networkContextMenu.currentSaved = modelData.saved;
networkContextMenu.currentSignal = modelData.signal; networkContextMenu.currentSignal = modelData.signal;
networkContextMenu.currentAutoconnect = modelData.autoconnect || false; networkContextMenu.currentAutoconnect = modelData.autoconnect || false;
@@ -743,7 +755,8 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
anchors.rightMargin: optionsButton.width + pinWifiRow.width + (qrCodeButton.visible ? qrCodeButton.width : 0) + Theme.spacingS * 5 + Theme.spacingM anchors.rightMargin: optionsButton.width + pinWifiRow.width + (qrCodeButton.visible ? qrCodeButton.width : 0) + Theme.spacingS * 5 + Theme.spacingM
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor enabled: !NetworkService.isWifiConnecting || wifiDelegate.isConnected
cursorShape: enabled ? Qt.PointingHandCursor : Qt.BusyCursor
onPressed: mouse => wifiRipple.trigger(mouse.x, mouse.y) onPressed: mouse => wifiRipple.trigger(mouse.x, mouse.y)
onClicked: function (event) { onClicked: function (event) {
if (wifiDelegate.isConnected) { if (wifiDelegate.isConnected) {
@@ -768,6 +781,7 @@ Rectangle {
property bool currentSecured: false property bool currentSecured: false
property bool currentEnterprise: false property bool currentEnterprise: false
property bool currentConnected: false property bool currentConnected: false
property bool currentConnecting: false
property bool currentSaved: false property bool currentSaved: false
property int currentSignal: 0 property int currentSignal: 0
property bool currentAutoconnect: false property bool currentAutoconnect: false
@@ -786,13 +800,14 @@ Rectangle {
} }
MenuItem { MenuItem {
text: networkContextMenu.currentConnected ? I18n.tr("Disconnect") : I18n.tr("Connect") text: networkContextMenu.currentConnecting ? I18n.tr("Connecting...") : (networkContextMenu.currentConnected ? I18n.tr("Disconnect") : I18n.tr("Connect"))
height: 32 height: 32
enabled: !networkContextMenu.currentConnecting
contentItem: StyledText { contentItem: StyledText {
text: parent.text text: parent.text
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText color: parent.enabled ? Theme.surfaceText : Theme.surfaceVariantText
leftPadding: Theme.spacingS leftPadding: Theme.spacingS
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
+34 -7
View File
@@ -465,6 +465,7 @@ Item {
required property int index required property int index
readonly property bool isConnected: modelData.ssid === NetworkService.currentWifiSSID readonly property bool isConnected: modelData.ssid === NetworkService.currentWifiSSID
readonly property bool isConnecting: NetworkService.isWifiConnecting && NetworkService.connectingSSID === modelData.ssid
readonly property bool isPinned: root.getPinnedWifiNetworks().includes(modelData.ssid) readonly property bool isPinned: root.getPinnedWifiNetworks().includes(modelData.ssid)
readonly property bool isExpanded: root.expandedWifiSsid === modelData.ssid readonly property bool isExpanded: root.expandedWifiSsid === modelData.ssid
@@ -499,7 +500,17 @@ Item {
anchors.rightMargin: Theme.spacingS anchors.rightMargin: Theme.spacingS
spacing: Theme.spacingS spacing: Theme.spacingS
DankSpinner {
size: 20
strokeWidth: 2
color: Theme.warning
running: isConnecting
visible: isConnecting
anchors.verticalCenter: parent.verticalCenter
}
DankIcon { DankIcon {
visible: !isConnecting
name: { name: {
const s = modelData.signal || 0; const s = modelData.signal || 0;
if (s >= 50) if (s >= 50)
@@ -552,9 +563,9 @@ Item {
spacing: Theme.spacingXS spacing: Theme.spacingXS
StyledText { StyledText {
text: isConnected ? I18n.tr("Connected") : (modelData.secured ? I18n.tr("Secured") : I18n.tr("Open")) text: isConnecting ? I18n.tr("Connecting...") : (isConnected ? I18n.tr("Connected") : (modelData.secured ? I18n.tr("Secured") : I18n.tr("Open")))
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: isConnected ? Theme.primary : Theme.surfaceVariantText color: isConnecting ? Theme.warning : (isConnected ? Theme.primary : Theme.surfaceVariantText)
} }
StyledText { StyledText {
@@ -672,7 +683,8 @@ Item {
anchors.fill: parent anchors.fill: parent
anchors.rightMargin: wifiNetworkActions.width + Theme.spacingM anchors.rightMargin: wifiNetworkActions.width + Theme.spacingM
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor enabled: !NetworkService.isWifiConnecting || isConnected
cursorShape: enabled ? Qt.PointingHandCursor : Qt.BusyCursor
onClicked: { onClicked: {
WifiConnectionActions.connectToNetwork(modelData, { WifiConnectionActions.connectToNetwork(modelData, {
connected: isConnected, connected: isConnected,
@@ -859,6 +871,7 @@ Item {
required property int index required property int index
readonly property bool isConnected: modelData.ssid === NetworkService.currentWifiSSID readonly property bool isConnected: modelData.ssid === NetworkService.currentWifiSSID
readonly property bool isConnecting: NetworkService.isWifiConnecting && NetworkService.connectingSSID === modelData.ssid
readonly property bool isPinned: root.getPinnedWifiNetworks().includes(modelData.ssid) readonly property bool isPinned: root.getPinnedWifiNetworks().includes(modelData.ssid)
readonly property bool isOutOfRange: modelData.outOfRange || false readonly property bool isOutOfRange: modelData.outOfRange || false
readonly property bool isExpanded: !isOutOfRange && root.expandedSavedWifiSsid === modelData.ssid readonly property bool isExpanded: !isOutOfRange && root.expandedSavedWifiSsid === modelData.ssid
@@ -894,7 +907,17 @@ Item {
anchors.rightMargin: Theme.spacingS anchors.rightMargin: Theme.spacingS
spacing: Theme.spacingS spacing: Theme.spacingS
DankSpinner {
size: 20
strokeWidth: 2
color: Theme.warning
running: isConnecting
visible: isConnecting
anchors.verticalCenter: parent.verticalCenter
}
DankIcon { DankIcon {
visible: !isConnecting
name: { name: {
if (isOutOfRange) if (isOutOfRange)
return "wifi_off"; return "wifi_off";
@@ -941,6 +964,8 @@ Item {
StyledText { StyledText {
text: { text: {
if (isConnecting)
return I18n.tr("Connecting...");
const parts = [isConnected ? I18n.tr("Connected") : (modelData.secured ? I18n.tr("Secured") : I18n.tr("Open"))]; const parts = [isConnected ? I18n.tr("Connected") : (modelData.secured ? I18n.tr("Secured") : I18n.tr("Open"))];
parts.push(isOutOfRange ? I18n.tr("Unavailable") : (modelData.signal || 0) + "%"); parts.push(isOutOfRange ? I18n.tr("Unavailable") : (modelData.signal || 0) + "%");
if (modelData.hidden || false) if (modelData.hidden || false)
@@ -948,7 +973,7 @@ Item {
return parts.join(" • "); return parts.join(" • ");
} }
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: isConnected ? Theme.primary : Theme.surfaceVariantText color: isConnecting ? Theme.warning : (isConnected ? Theme.primary : Theme.surfaceVariantText)
width: parent.width width: parent.width
elide: Text.ElideRight elide: Text.ElideRight
} }
@@ -1028,7 +1053,8 @@ Item {
anchors.fill: parent anchors.fill: parent
anchors.rightMargin: savedWifiActions.width + Theme.spacingM anchors.rightMargin: savedWifiActions.width + Theme.spacingM
hoverEnabled: true hoverEnabled: true
cursorShape: isOutOfRange ? Qt.ArrowCursor : Qt.PointingHandCursor enabled: !NetworkService.isWifiConnecting || isConnected
cursorShape: isOutOfRange ? Qt.ArrowCursor : (enabled ? Qt.PointingHandCursor : Qt.BusyCursor)
onClicked: { onClicked: {
if (isOutOfRange) if (isOutOfRange)
return; return;
@@ -1162,14 +1188,15 @@ Item {
} }
MenuItem { MenuItem {
text: isConnected ? I18n.tr("Disconnect") : I18n.tr("Connect") text: isConnecting ? I18n.tr("Connecting...") : (isConnected ? I18n.tr("Disconnect") : I18n.tr("Connect"))
height: isOutOfRange ? 0 : 32 height: isOutOfRange ? 0 : 32
visible: !isOutOfRange visible: !isOutOfRange
enabled: !isConnecting
contentItem: StyledText { contentItem: StyledText {
text: parent.text text: parent.text
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText color: parent.enabled ? Theme.surfaceText : Theme.surfaceVariantText
leftPadding: Theme.spacingS leftPadding: Theme.spacingS
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@@ -467,6 +467,8 @@ Singleton {
return; return;
pendingConnectionSSID = ssid; pendingConnectionSSID = ssid;
pendingConnectionStartTime = Date.now(); pendingConnectionStartTime = Date.now();
isConnecting = true;
connectingSSID = ssid;
connectionError = ""; connectionError = "";
connectionStatus = "connecting"; connectionStatus = "connecting";
credentialsRequested = false; credentialsRequested = false;
@@ -510,6 +512,8 @@ Singleton {
connectionError = response.error; connectionError = response.error;
lastConnectionError = response.error; lastConnectionError = response.error;
pendingConnectionSSID = ""; pendingConnectionSSID = "";
isConnecting = false;
connectingSSID = "";
connectionStatus = "failed"; connectionStatus = "failed";
ToastService.showError(I18n.tr("Failed to start connection to %1").arg(ssid)); ToastService.showError(I18n.tr("Failed to start connection to %1").arg(ssid));
} }