move material symbol in Network service to Icon

This commit is contained in:
end-4
2026-03-11 21:55:56 +01:00
parent 653dc9c95f
commit be87a1ae79
6 changed files with 23 additions and 22 deletions
@@ -3,6 +3,7 @@ pragma Singleton
// From https://github.com/caelestia-dots/shell (GPLv3)
import Quickshell
import qs.services
Singleton {
id: root
@@ -21,6 +22,24 @@ Singleton {
return "bluetooth";
}
function getNetworkMaterialSymbol() {
if (Network.ethernet) return "lan";
if (Network.wifiEnabled && Network.wifiStatus === "connected") {
const strength = Network.active?.strength ?? 0
if (strength > 83) return "signal_wifi_4_bar";
if (strength > 67) return "network_wifi";
if (strength > 50) return "network_wifi_3_bar";
if (strength > 33) return "network_wifi_2_bar";
if (strength > 17) return "network_wifi_1_bar";
return "signal_wifi_0_bar"
} else {
if (Network.wifiStatus === "connecting") return "signal_wifi_statusbar_not_connected";
if (Network.wifiStatus === "disconnected") return "wifi_find";
if (Network.wifiStatus === "disabled") return "signal_wifi_off";
return "signal_wifi_bad";
}
}
readonly property var weatherIconMap: ({
"113": "clear_day",
"116": "partly_cloudy_day",
@@ -8,7 +8,7 @@ QuickToggleModel {
name: Translation.tr("Internet")
statusText: Network.networkName
tooltipText: Translation.tr("%1 | Right-click to configure").arg(Network.networkName)
icon: Network.materialSymbol
icon: Icons.getNetworkMaterialSymbol()
toggled: Network.wifiStatus !== "disabled"
mainAction: () => Network.toggleWifi()
@@ -303,7 +303,7 @@ Item { // Bar content region
}
}
MaterialSymbol {
text: Network.materialSymbol
text: Icons.getNetworkMaterialSymbol()
iconSize: Appearance.font.pixelSize.larger
color: rightSidebarButton.colText
}
@@ -11,7 +11,7 @@ import Quickshell.Hyprland
QuickToggleButton {
toggled: Network.wifiStatus !== "disabled"
buttonIcon: Network.materialSymbol
buttonIcon: Icons.getNetworkMaterialSymbol()
onClicked: Network.toggleWifi()
altAction: () => {
Quickshell.execDetached(["bash", "-c", `${Network.ethernet ? Config.options.apps.networkEthernet : Config.options.apps.network}`])
@@ -280,7 +280,7 @@ Item { // Bar content region
}
}
MaterialSymbol {
text: Network.materialSymbol
text: Icons.getNetworkMaterialSymbol()
iconSize: Appearance.font.pixelSize.larger
color: rightSidebarButton.colText
}
@@ -34,24 +34,6 @@ Singleton {
property string networkName: ""
property int networkStrength
property string materialSymbol: root.ethernet
? "lan"
: (root.wifiEnabled && root.wifiStatus === "connected")
? (
(root.active?.strength ?? 0) > 83 ? "signal_wifi_4_bar" :
(root.active?.strength ?? 0) > 67 ? "network_wifi" :
(root.active?.strength ?? 0) > 50 ? "network_wifi_3_bar" :
(root.active?.strength ?? 0) > 33 ? "network_wifi_2_bar" :
(root.active?.strength ?? 0) > 17 ? "network_wifi_1_bar" :
"signal_wifi_0_bar"
)
: (root.wifiStatus === "connecting")
? "signal_wifi_statusbar_not_connected"
: (root.wifiStatus === "disconnected")
? "wifi_find"
: (root.wifiStatus === "disabled")
? "signal_wifi_off"
: "signal_wifi_bad"
// Control
function enableWifi(enabled = true): void {