extract NetworkApplet, fold NetworkMenu into NetworkModule with pin support
This commit is contained in:
parent
87952b543c
commit
c9c71c0e29
5 changed files with 81 additions and 52 deletions
|
|
@ -1,45 +1,10 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
|
||||||
import "." as M
|
|
||||||
import "../services" as S
|
import "../services" as S
|
||||||
|
|
||||||
M.HoverPanel {
|
Column {
|
||||||
id: menuWindow
|
id: root
|
||||||
|
|
||||||
contentWidth: 250
|
required property color accentColor
|
||||||
panelNamespace: "nova-network"
|
|
||||||
panelTitle: "Wi-Fi"
|
|
||||||
titleActionsComponent: Component {
|
|
||||||
Item {
|
|
||||||
width: 20
|
|
||||||
height: 20
|
|
||||||
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: "\uF011"
|
|
||||||
color: S.NetworkService.wifiEnabled ? menuWindow.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()
|
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: S.NetworkService.networks
|
model: S.NetworkService.networks
|
||||||
|
|
@ -49,7 +14,7 @@ M.HoverPanel {
|
||||||
required property var modelData
|
required property var modelData
|
||||||
required property int index
|
required property int index
|
||||||
|
|
||||||
width: menuWindow.contentWidth
|
width: root.width
|
||||||
height: 32
|
height: 32
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
@ -66,7 +31,7 @@ M.HoverPanel {
|
||||||
anchors.leftMargin: 12
|
anchors.leftMargin: 12
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: entry.modelData.isWifi ? "\uF1EB" : "\uDB80\uDE00"
|
text: entry.modelData.isWifi ? "\uF1EB" : "\uDB80\uDE00"
|
||||||
color: entry.modelData.active ? menuWindow.accentColor : S.Theme.base05
|
color: entry.modelData.active ? root.accentColor : S.Theme.base05
|
||||||
font.pixelSize: S.Theme.fontSize + 1
|
font.pixelSize: S.Theme.fontSize + 1
|
||||||
font.family: S.Theme.iconFontFamily
|
font.family: S.Theme.iconFontFamily
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +43,7 @@ M.HoverPanel {
|
||||||
anchors.rightMargin: 4
|
anchors.rightMargin: 4
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: entry.modelData.name
|
text: entry.modelData.name
|
||||||
color: entry.modelData.active ? menuWindow.accentColor : S.Theme.base05
|
color: entry.modelData.active ? root.accentColor : S.Theme.base05
|
||||||
font.pixelSize: S.Theme.fontSize
|
font.pixelSize: S.Theme.fontSize
|
||||||
font.family: S.Theme.fontFamily
|
font.family: S.Theme.fontFamily
|
||||||
font.bold: entry.modelData.active
|
font.bold: entry.modelData.active
|
||||||
|
|
@ -107,7 +72,6 @@ M.HoverPanel {
|
||||||
S.NetworkService.disconnectNetwork(entry.modelData.uuid);
|
S.NetworkService.disconnectNetwork(entry.modelData.uuid);
|
||||||
else
|
else
|
||||||
S.NetworkService.connectNetwork(entry.modelData.uuid);
|
S.NetworkService.connectNetwork(entry.modelData.uuid);
|
||||||
menuWindow.keepOpen(500);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -115,7 +79,7 @@ M.HoverPanel {
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
visible: S.NetworkService.networks.length === 0
|
visible: S.NetworkService.networks.length === 0
|
||||||
width: menuWindow.contentWidth
|
width: root.width
|
||||||
height: 32
|
height: 32
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
@ -8,6 +8,7 @@ GpuApplet 1.0 GpuApplet.qml
|
||||||
HexWaveBackground 1.0 HexWaveBackground.qml
|
HexWaveBackground 1.0 HexWaveBackground.qml
|
||||||
MemoryApplet 1.0 MemoryApplet.qml
|
MemoryApplet 1.0 MemoryApplet.qml
|
||||||
MprisApplet 1.0 MprisApplet.qml
|
MprisApplet 1.0 MprisApplet.qml
|
||||||
|
NetworkApplet 1.0 NetworkApplet.qml
|
||||||
TemperatureApplet 1.0 TemperatureApplet.qml
|
TemperatureApplet 1.0 TemperatureApplet.qml
|
||||||
VolumeApplet 1.0 VolumeApplet.qml
|
VolumeApplet 1.0 VolumeApplet.qml
|
||||||
# keep-sorted end
|
# keep-sorted end
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,6 @@ PanelWindow {
|
||||||
// Connectivity
|
// Connectivity
|
||||||
M.BarGroup {
|
M.BarGroup {
|
||||||
M.NetworkModule {
|
M.NetworkModule {
|
||||||
bar: bar
|
|
||||||
visible: S.Modules.network.enable
|
visible: S.Modules.network.enable
|
||||||
}
|
}
|
||||||
M.BluetoothModule {
|
M.BluetoothModule {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import "." as M
|
import "." as M
|
||||||
import "../services" as S
|
import "../services" as S
|
||||||
|
import "../applets" as C
|
||||||
|
|
||||||
M.BarSection {
|
M.BarSection {
|
||||||
id: root
|
id: root
|
||||||
|
|
@ -10,6 +11,23 @@ M.BarSection {
|
||||||
|
|
||||||
readonly property string state: S.NetworkService.state
|
readonly property string state: S.NetworkService.state
|
||||||
|
|
||||||
|
property bool _pinned: false
|
||||||
|
readonly property bool _anyHover: root._hovered || hoverPanel.panelHovered
|
||||||
|
readonly property bool _showPanel: _anyHover || _pinned
|
||||||
|
|
||||||
|
on_AnyHoverChanged: {
|
||||||
|
if (_anyHover)
|
||||||
|
_unpinTimer.stop();
|
||||||
|
else if (_pinned)
|
||||||
|
_unpinTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: _unpinTimer
|
||||||
|
interval: 500
|
||||||
|
onTriggered: root._pinned = false
|
||||||
|
}
|
||||||
|
|
||||||
M.BarIcon {
|
M.BarIcon {
|
||||||
icon: {
|
icon: {
|
||||||
if (root.state === "wifi")
|
if (root.state === "wifi")
|
||||||
|
|
@ -22,23 +40,71 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
color: root.state === "disconnected" ? S.Theme.base08 : root.accentColor
|
color: root.state === "disconnected" ? S.Theme.base08 : root.accentColor
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
TapHandler {
|
||||||
|
onTapped: root._pinned = !root._pinned
|
||||||
|
}
|
||||||
}
|
}
|
||||||
M.BarLabel {
|
M.BarLabel {
|
||||||
visible: root.state === "wifi"
|
visible: root.state === "wifi"
|
||||||
label: S.NetworkService.essid
|
label: S.NetworkService.essid
|
||||||
color: root.state === "disconnected" ? S.Theme.base08 : root.accentColor
|
color: root.state === "disconnected" ? S.Theme.base08 : root.accentColor
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
TapHandler {
|
||||||
|
onTapped: root._pinned = !root._pinned
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
required property var bar
|
M.HoverPanel {
|
||||||
|
id: hoverPanel
|
||||||
readonly property bool _anyHover: root._hovered || networkMenu.panelHovered
|
showPanel: root._showPanel
|
||||||
|
|
||||||
M.NetworkMenu {
|
|
||||||
id: networkMenu
|
|
||||||
showPanel: root._anyHover
|
|
||||||
screen: QsWindow.window?.screen ?? null
|
screen: QsWindow.window?.screen ?? null
|
||||||
anchorItem: root
|
anchorItem: root
|
||||||
accentColor: root.accentColor
|
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()
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: S.NetworkService
|
||||||
|
function onNetworksChanged() {
|
||||||
|
hoverPanel.keepOpen(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
C.NetworkApplet {
|
||||||
|
width: hoverPanel.contentWidth
|
||||||
|
accentColor: root.accentColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ HoverPanel 1.0 HoverPanel.qml
|
||||||
IdleInhibitorModule 1.0 IdleInhibitorModule.qml
|
IdleInhibitorModule 1.0 IdleInhibitorModule.qml
|
||||||
MemoryModule 1.0 MemoryModule.qml
|
MemoryModule 1.0 MemoryModule.qml
|
||||||
MprisModule 1.0 MprisModule.qml
|
MprisModule 1.0 MprisModule.qml
|
||||||
NetworkMenu 1.0 NetworkMenu.qml
|
|
||||||
NetworkModule 1.0 NetworkModule.qml
|
NetworkModule 1.0 NetworkModule.qml
|
||||||
NotifCard 1.0 NotifCard.qml
|
NotifCard 1.0 NotifCard.qml
|
||||||
NotifCenter 1.0 NotifCenter.qml
|
NotifCenter 1.0 NotifCenter.qml
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue