blob: c608d82d5ef44d309d3d5339f07a6c44040990f2 (
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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
}
}
}
|