aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/bluetooth/BluetoothRow.qml
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/modules/bluetooth/BluetoothRow.qml')
-rw-r--r--desktop/modules/bluetooth/BluetoothRow.qml85
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()
+ }
+ }
+ }
+ }
+}