54 lines
1.7 KiB
QML
54 lines
1.7 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import "." as M
|
|
import "../services" as S
|
|
|
|
M.BarSection {
|
|
id: root
|
|
spacing: S.Theme.moduleSpacing
|
|
opacity: S.Modules.bluetooth.enable && S.BluetoothService.state !== "unavailable" ? 1 : 0
|
|
visible: opacity > 0
|
|
tooltip: {
|
|
if (S.BluetoothService.state === "off")
|
|
return "Bluetooth: off";
|
|
if (S.BluetoothService.state === "connected")
|
|
return "Bluetooth: " + S.BluetoothService.device + (S.BluetoothService.batteryPct >= 0 ? "\nBattery: " + S.BluetoothService.batteryPct + "%" : "");
|
|
return "Bluetooth: on";
|
|
}
|
|
|
|
M.BarIcon {
|
|
icon: "\uF294"
|
|
color: S.BluetoothService.state === "off" ? S.Theme.base04 : root.accentColor
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
TapHandler {
|
|
onTapped: {
|
|
M.FlyoutState.visible = false;
|
|
btLoader.active = true;
|
|
}
|
|
}
|
|
}
|
|
M.BarLabel {
|
|
visible: S.BluetoothService.state === "connected"
|
|
label: S.BluetoothService.device + (S.BluetoothService.batteryPct >= 0 ? " " + S.BluetoothService.batteryPct + "%" : "")
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
TapHandler {
|
|
onTapped: {
|
|
M.FlyoutState.visible = false;
|
|
btLoader.active = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
required property var bar
|
|
|
|
LazyLoader {
|
|
id: btLoader
|
|
active: false
|
|
M.BluetoothMenu {
|
|
accentColor: root.accentColor
|
|
screen: QsWindow.window?.screen ?? null
|
|
anchorX: root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0)
|
|
onDismissed: btLoader.active = false
|
|
}
|
|
}
|
|
}
|