Files
2026-07-26 21:16:55 +02:00

70 lines
2.3 KiB
QML

import QtQuick
import Quickshell.Networking
import qs.config
import qs.components
import qs.services
// Right section: the wifi button. The network list lives in WifiPanel.qml as a
// separate layer surface.
Item {
id: root
required property var bar
readonly property WifiDevice device: Networking.devices.values.find(d => d.type === DeviceType.Wifi) ?? null
readonly property bool wifiOn: Networking.wifiEnabled && Networking.wifiHardwareEnabled
readonly property var network: root.device ? root.device.networks.values.find(n => n.connected) ?? null : null
// Machines with no wifi adapter, and sessions with no NetworkManager, get
// no button at all.
visible: Config.showWifi && root.device !== null
implicitWidth: button.implicitWidth
PanelButton {
id: button
anchors.verticalCenter: parent.verticalCenter
height: root.height - Theme.spacing
minContentWidth: Theme.iconSize
active: panel.visible
activeColor: Theme.accent
onClicked: Session.toggle("wifi", panel.screenName)
Row {
spacing: Theme.spacing
WifiGlyph {
size: Theme.iconSize
struck: !root.wifiOn
level: root.network ? Math.min(3, Math.floor(root.network.signalStrength * 4)) : 0
color: button.active ? Theme.background : !root.wifiOn ? Theme.textDim : root.network ? Theme.accent : Theme.text
dimColor: button.active ? Qt.rgba(Theme.background.r, Theme.background.g, Theme.background.b, 0.4) : Theme.border
}
// The network in use, which is the thing worth carrying on the
// panel. Capped so a long SSID cannot squeeze the window list.
Text {
height: Theme.iconSize
width: Math.min(implicitWidth, Config.wifiLabelMaxWidth)
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
visible: root.network !== null
text: root.network ? root.network.name : ""
color: button.active ? Theme.background : Theme.textDim
font.family: Theme.fontFamily
font.pixelSize: Theme.fontSizeSmall
font.bold: true
}
}
}
WifiPanel {
id: panel
bar: root.bar
}
}