blob: a7aecd0cede88d578cd24602126c6bb5bc1150eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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) * 100) + "%"
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()
}
}
}
}
}
|