101 lines
2.8 KiB
QML
101 lines
2.8 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import "." as M
|
|
import "../services" as S
|
|
import "../applets" as C
|
|
|
|
M.BarSection {
|
|
id: root
|
|
spacing: S.Theme.moduleSpacing
|
|
opacity: S.Modules.bluetooth.enable && S.BluetoothService.state !== "unavailable" ? 1 : 0
|
|
visible: opacity > 0
|
|
tooltip: ""
|
|
|
|
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 {
|
|
icon: "\uF294"
|
|
color: S.BluetoothService.state === "off" ? S.Theme.base04 : root.accentColor
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
TapHandler {
|
|
onTapped: root._pinned = !root._pinned
|
|
}
|
|
}
|
|
M.BarLabel {
|
|
visible: S.BluetoothService.state === "connected"
|
|
label: S.BluetoothService.device + (S.BluetoothService.batteryPct >= 0 ? " " + S.BluetoothService.batteryPct + "%" : "")
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
TapHandler {
|
|
onTapped: root._pinned = !root._pinned
|
|
}
|
|
}
|
|
|
|
Connections {
|
|
target: S.BluetoothService
|
|
function onDevicesChanged() {
|
|
hoverPanel.keepOpen(500);
|
|
}
|
|
}
|
|
|
|
M.HoverPanel {
|
|
id: hoverPanel
|
|
showPanel: root._showPanel
|
|
screen: QsWindow.window?.screen ?? null
|
|
anchorItem: root
|
|
accentColor: root.accentColor
|
|
panelNamespace: "nova-bluetooth"
|
|
panelTitle: "Bluetooth"
|
|
contentWidth: 250
|
|
titleActionsComponent: Component {
|
|
Item {
|
|
width: 20
|
|
height: 20
|
|
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: "\uF011"
|
|
color: S.BluetoothService.enabled ? 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.BluetoothService.setPower(!S.BluetoothService.enabled)
|
|
}
|
|
}
|
|
}
|
|
|
|
onVisibleChanged: if (visible)
|
|
S.BluetoothService.refresh()
|
|
|
|
C.BluetoothApplet {
|
|
width: hoverPanel.contentWidth
|
|
accentColor: root.accentColor
|
|
}
|
|
}
|
|
}
|