diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-14 13:53:16 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-14 13:53:16 +0200 |
| commit | 863a2a25e775eaed187b7dc727a26278540421f4 (patch) | |
| tree | 0d04d05f35e4d336b2de3b4da5ba31ff5737ca1b /desktop/modules/bluetooth/BluetoothRow.qml | |
| parent | b5b369642fabe1209793138f2a725d375924330a (diff) | |
| download | quickshell-863a2a25e775eaed187b7dc727a26278540421f4.tar.gz quickshell-863a2a25e775eaed187b7dc727a26278540421f4.zip | |
feat(desktop): bluetooth module, tile and page
Native Quickshell.Bluetooth for adapter power, discoverable, scan,
connect, disconnect, trust and forget. Pairing is separate, because
quickshell ships no BlueZ agent.
The adapter is null for the first ~2s, so every access is navigated
safely rather than assuming a first paint.
Diffstat (limited to 'desktop/modules/bluetooth/BluetoothRow.qml')
| -rw-r--r-- | desktop/modules/bluetooth/BluetoothRow.qml | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/desktop/modules/bluetooth/BluetoothRow.qml b/desktop/modules/bluetooth/BluetoothRow.qml new file mode 100644 index 0000000..d92bd9a --- /dev/null +++ b/desktop/modules/bluetooth/BluetoothRow.qml @@ -0,0 +1,85 @@ +// Copyright (C) 2026 Danilo M. <danix@danix.xyz> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +import QtQuick +import "../.." + +// One tracked device. The actions shown depend on its state: connected, +// paired-but-idle, or found and not yet paired. +Rectangle { + id: row + + required property var bt + required property var device + + implicitHeight: col.implicitHeight + 16 + radius: 8 + color: device.connected ? Qt.alpha(Theme.accent, 0.10) : Qt.alpha(Theme.surface, 0.35) + + Column { + id: col + anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 } + spacing: 8 + + Item { + width: parent.width + implicitHeight: Math.max(nameText.implicitHeight, actions.implicitHeight) + + Text { + id: nameText + anchors { left: parent.left; right: actions.left; rightMargin: 8; verticalCenter: parent.verticalCenter } + elide: Text.ElideRight + text: row.device.name || row.device.deviceName || row.device.address + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: row.device.connected } + color: row.device.connected ? Theme.accent : Theme.text + } + + Row { + id: actions + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + spacing: 6 + + Text { + anchors.verticalCenter: parent.verticalCenter + visible: row.device.batteryAvailable ?? false + text: Math.round(row.device.battery ?? 0) + "%" + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 } + color: Theme.overlay + } + + Button { + visible: !row.device.connected && row.device.paired + text: "Connect" + onClicked: row.device.connect() + } + + Button { + visible: row.device.connected + text: "Disconnect" + onClicked: row.device.disconnect() + } + + Button { + visible: row.device.paired + text: row.device.trusted ? "Untrust" : "Trust" + onClicked: row.device.trusted = !row.device.trusted + } + + Button { + visible: row.device.paired + text: "Forget" + danger: true + onClicked: row.device.forget() + } + } + } + } +} |
