93 lines
2.6 KiB
QML
93 lines
2.6 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import "." as M
|
|
import "../services" as S
|
|
import "../applets" as C
|
|
|
|
M.PinnableSection {
|
|
id: root
|
|
spacing: S.Theme.moduleSpacing
|
|
_panelHovered: hoverPanel.panelHovered
|
|
|
|
readonly property string state: S.NetworkService.state
|
|
|
|
M.BarIcon {
|
|
icon: {
|
|
if (root.state === "wifi")
|
|
return "\uF1EB";
|
|
if (root.state === "eth")
|
|
return "\uDB80\uDE00";
|
|
if (root.state === "linked")
|
|
return "\uDB85\uDE16";
|
|
return "\uDB82\uDCFD";
|
|
}
|
|
color: root.state === "disconnected" ? S.Theme.base08 : root.accentColor
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
TapHandler {
|
|
onTapped: root._pinned = !root._pinned
|
|
}
|
|
}
|
|
M.BarLabel {
|
|
visible: root.state === "wifi"
|
|
label: S.NetworkService.essid
|
|
color: root.state === "disconnected" ? S.Theme.base08 : root.accentColor
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
TapHandler {
|
|
onTapped: root._pinned = !root._pinned
|
|
}
|
|
}
|
|
|
|
Connections {
|
|
target: S.NetworkService
|
|
function onNetworksChanged() {
|
|
hoverPanel.keepOpen(500);
|
|
}
|
|
}
|
|
|
|
M.HoverPanel {
|
|
id: hoverPanel
|
|
showPanel: root._showPanel
|
|
screen: QsWindow.window?.screen ?? null
|
|
anchorItem: root
|
|
accentColor: root.accentColor
|
|
panelNamespace: "nova-network"
|
|
panelTitle: "Wi-Fi"
|
|
contentWidth: 250
|
|
titleActionsComponent: Component {
|
|
Item {
|
|
width: 20
|
|
height: 20
|
|
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: "\uF011"
|
|
color: S.NetworkService.wifiEnabled ? hoverPanel.accentColor : S.Theme.base04
|
|
font.pixelSize: S.Theme.fontSize
|
|
font.family: S.Theme.iconFontFamily
|
|
|
|
Behavior on color {
|
|
ColorAnimation {
|
|
duration: 100
|
|
}
|
|
}
|
|
}
|
|
|
|
HoverHandler {
|
|
cursorShape: Qt.PointingHandCursor
|
|
}
|
|
|
|
TapHandler {
|
|
onTapped: S.NetworkService.setWifi(!S.NetworkService.wifiEnabled)
|
|
}
|
|
}
|
|
}
|
|
|
|
onVisibleChanged: if (visible)
|
|
S.NetworkService.refresh()
|
|
|
|
C.NetworkApplet {
|
|
width: hoverPanel.contentWidth
|
|
accentColor: root.accentColor
|
|
}
|
|
}
|
|
}
|