From 45646b6b5e5b725ae30124d74ed94f377978a01d Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Sat, 26 Jul 2025 19:05:09 -0400 Subject: [PATCH] add bluetooth menu (its fucked my lsp is dying --- constants/Icons.qml | 1 + .../components/bluetooth/BluetoothMenu.qml | 64 ++++++++++++++++--- .../bar/components/bluetooth/DeviceList.qml | 46 +++++++++++++ services/Bluetooth.qml | 21 ++++++ 4 files changed, 122 insertions(+), 10 deletions(-) create mode 100644 modules/bar/components/bluetooth/DeviceList.qml create mode 100644 services/Bluetooth.qml diff --git a/constants/Icons.qml b/constants/Icons.qml index cdfef99..4126c27 100644 --- a/constants/Icons.qml +++ b/constants/Icons.qml @@ -6,6 +6,7 @@ Singleton { property string bell: "\u{E05d}" property string bellRing: "\u{E224}" property string bluetooth: "\u{E060}" + property string bluetoothConnected: "\u{E1b8}" property string brickWall: "\u{E586}" property string coffee: "\u{E09a}" property string cpu: "\u{E0ad}" diff --git a/modules/bar/components/bluetooth/BluetoothMenu.qml b/modules/bar/components/bluetooth/BluetoothMenu.qml index 59e102b..ed896c3 100644 --- a/modules/bar/components/bluetooth/BluetoothMenu.qml +++ b/modules/bar/components/bluetooth/BluetoothMenu.qml @@ -1,29 +1,73 @@ +pragma ComponentBehavior: Bound + import qs.config +import qs.constants +import qs.services import qs.styled import QtQuick import QtQuick.Controls import QtQuick.Layouts -import Quickshell.Bluetooth +import Quickshell.Widgets StyledPopupWindow { id: root backgroundColor: Theme.palette.base300 - margins: 8 + margins: 16 radius: 8 - property BluetoothAdapter defaultAdapter: Bluetooth.defaultAdapter - content: ColumnLayout { + spacing: 8 + WrapperRectangle { + margin: 16 + color: Theme.palette.base200 + radius: 8 + Layout.fillWidth: true + RowLayout { + StyledText { + text: "Bluetooth" + } - RowLayout { - StyledText { - text: root.defaultAdapter.name + Switch { + checked: Bluetooth.defaultAdapter.enabled + onClicked: Bluetooth.defaultAdapter.enabled = checked + } } + } - Switch { - checked: root.defaultAdapter.enabled - onClicked: root.defaultAdapter.enabled = checked + WrapperRectangle { + margin: 16 + color: Theme.palette.base200 + radius: 8 + ColumnLayout { + spacing: 8 + + StyledText { + font.bold: true + text: "Connected Devices" + } + + DeviceList { + devices: Bluetooth.connectedDevices + } + + StyledText { + font.bold: true + text: "Paired Devices" + } + + DeviceList { + devices: Bluetooth.pairedDevices + } + + StyledText { + font.bold: true + text: "Available Devices" + } + + DeviceList { + devices: Bluetooth.availableDevices + } } } } diff --git a/modules/bar/components/bluetooth/DeviceList.qml b/modules/bar/components/bluetooth/DeviceList.qml new file mode 100644 index 0000000..fa21d27 --- /dev/null +++ b/modules/bar/components/bluetooth/DeviceList.qml @@ -0,0 +1,46 @@ +import qs.config +import qs.constants +import qs.services +import qs.styled +import QtQuick +import QtQuick.Layouts + +ColumnLayout { + id: root + required property var devices + + Repeater { + model: devices + delegate: Clickable { + id: device + required property var modelData + + implicitWidth: row.width + implicitHeight: row.height + Layout.fillWidth: true + + RowLayout { + id: row + + StyledText { + topPadding: 8 + bottomPadding: 8 + leftPadding: 8 + text: device.modelData.deviceName + } + StyledText { + font.family: Theme.lucide.font.family + font.pixelSize: 10 + font.bold: true + text: device.modelData.connected ? Icons.bluetoothConnected : Icons.bluetooth + + topPadding: 8 + bottomPadding: 8 + rightPadding: 8 + + color: device.containsMouse ? Theme.palette.base300 : Theme.palette.basecontent + } + } + } + } +} diff --git a/services/Bluetooth.qml b/services/Bluetooth.qml new file mode 100644 index 0000000..0904672 --- /dev/null +++ b/services/Bluetooth.qml @@ -0,0 +1,21 @@ +pragma Singleton + +import Quickshell +import Quickshell.Bluetooth + +Singleton { + id: root + + property BluetoothAdapter defaultAdapter: Bluetooth.defaultAdapter + property list connectedDevices: defaultAdapter.devices.values.filter(device => device.connected) + property list pairedDevices: defaultAdapter.devices.values.filter(device => device.paired) + property list availableDevices: defaultAdapter.devices.values.filter(device => !device.paired) + + function isConnected(BluetoothDevice: device) { + return device.state == BluetoothDeviceState.Connected; + } + + function isConnecting(BluetoothDevice: device) { + return device.state == BluetoothDeviceState.Connecting; + } +}