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/BluetoothPage.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/BluetoothPage.qml')
| -rw-r--r-- | desktop/modules/bluetooth/BluetoothPage.qml | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/desktop/modules/bluetooth/BluetoothPage.qml b/desktop/modules/bluetooth/BluetoothPage.qml new file mode 100644 index 0000000..c608d82 --- /dev/null +++ b/desktop/modules/bluetooth/BluetoothPage.qml @@ -0,0 +1,127 @@ +// 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 QtQuick.Controls +import "../.." + +Column { + id: page + + required property var bt + signal back + + spacing: 14 + + // --- Adapter --- + + Item { + width: page.width + implicitHeight: Math.max(btLabel.implicitHeight, powerSwitch.implicitHeight) + + Text { + id: btLabel + anchors.verticalCenter: parent.verticalCenter + text: "Bluetooth" + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 1; bold: true } + color: Theme.text + } + + Switch { + id: powerSwitch + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + checked: page.bt.adapter ? page.bt.adapter.enabled : false + onToggled: if (page.bt.adapter) page.bt.adapter.enabled = checked + } + } + + Text { + width: page.width + visible: !(page.bt.adapter && page.bt.adapter.enabled) + text: "Bluetooth off" + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 } + color: Theme.subtext + } + + Item { + width: page.width + visible: page.bt.adapter && page.bt.adapter.enabled + implicitHeight: Math.max(visLabel.implicitHeight, visSwitch.implicitHeight) + + Text { + id: visLabel + anchors.verticalCenter: parent.verticalCenter + text: "Visible" + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 } + color: Theme.text + } + + Switch { + id: visSwitch + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + checked: page.bt.adapter ? page.bt.adapter.discoverable : false + onToggled: if (page.bt.adapter) page.bt.adapter.discoverable = checked + } + } + + Row { + width: page.width + visible: page.bt.adapter && page.bt.adapter.enabled + spacing: 8 + + Button { + text: page.bt.adapter && page.bt.adapter.discovering ? "Stop scan" : "Scan" + onClicked: if (page.bt.adapter) page.bt.adapter.discovering = !page.bt.adapter.discovering + } + } + + // --- Connected --- + + Text { + width: page.width + visible: page.bt.connectedDevices.length > 0 + text: "Connected" + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: true } + color: Theme.subtext + } + + Repeater { + model: page.bt.connectedDevices + + BluetoothRow { + required property var modelData + bt: page.bt + device: modelData + width: page.width + } + } + + // --- Paired --- + + Text { + width: page.width + visible: page.bt.pairedDevices.length > 0 + text: "Paired" + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: true } + color: Theme.subtext + } + + Repeater { + model: page.bt.pairedDevices + + BluetoothRow { + required property var modelData + bt: page.bt + device: modelData + width: page.width + } + } +} |
