Keep nudging Bluetooth discovery on while the panel is open
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
000fa2a972
commit
835181f112
@@ -318,7 +318,6 @@ Panel {
|
|||||||
|
|
||||||
onOpenedChanged: {
|
onOpenedChanged: {
|
||||||
if (opened) {
|
if (opened) {
|
||||||
if (adapter && adapter.enabled && !adapter.discovering) adapter.discovering = true
|
|
||||||
if (connectedDevices.length > 0) { focusSection = "connected"; selectedIndex = 0 }
|
if (connectedDevices.length > 0) { focusSection = "connected"; selectedIndex = 0 }
|
||||||
else if (knownDevices.length > 0) { focusSection = "known"; selectedIndex = 0 }
|
else if (knownDevices.length > 0) { focusSection = "known"; selectedIndex = 0 }
|
||||||
else if (discoveredDevices.length > 0) { focusSection = "discovered"; selectedIndex = 0 }
|
else if (discoveredDevices.length > 0) { focusSection = "discovered"; selectedIndex = 0 }
|
||||||
@@ -406,12 +405,16 @@ Panel {
|
|||||||
implicitWidth: button.implicitWidth
|
implicitWidth: button.implicitWidth
|
||||||
implicitHeight: button.implicitHeight
|
implicitHeight: button.implicitHeight
|
||||||
|
|
||||||
Connections {
|
// BlueZ rejects StartDiscovery while the adapter is still powering up, and
|
||||||
target: root.adapter || null
|
// discovery can also time out on its own. While the panel is open, keep
|
||||||
function onEnabledChanged() {
|
// nudging it back on so an enabled adapter is always scanning.
|
||||||
if (root.opened && root.adapter && root.adapter.enabled && !root.adapter.discovering)
|
Timer {
|
||||||
root.adapter.discovering = true
|
id: discoveryRetry
|
||||||
}
|
interval: 1000
|
||||||
|
repeat: true
|
||||||
|
triggeredOnStart: true
|
||||||
|
running: root.opened && root.adapter !== null && root.adapter.enabled && !root.adapter.discovering
|
||||||
|
onTriggered: root.adapter.discovering = true
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
@@ -464,9 +467,6 @@ Panel {
|
|||||||
function toggleBluetooth() {
|
function toggleBluetooth() {
|
||||||
if (!adapter) return
|
if (!adapter) return
|
||||||
adapter.enabled = !adapter.enabled
|
adapter.enabled = !adapter.enabled
|
||||||
if (adapter.enabled) Qt.callLater(function() {
|
|
||||||
if (root.adapter) root.adapter.discovering = true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BarIconButton {
|
BarIconButton {
|
||||||
@@ -682,8 +682,7 @@ Panel {
|
|||||||
&& (!root.adapter || !root.adapter.discovering || root.discoveredDevices.length === 0)
|
&& (!root.adapter || !root.adapter.discovering || root.discoveredDevices.length === 0)
|
||||||
text: !root.adapter ? "No Bluetooth adapter"
|
text: !root.adapter ? "No Bluetooth adapter"
|
||||||
: !root.adapter.enabled ? "Turn Bluetooth on to scan"
|
: !root.adapter.enabled ? "Turn Bluetooth on to scan"
|
||||||
: root.adapter.discovering ? "Scanning for devices…"
|
: "Scanning for devices…"
|
||||||
: "No paired devices. Reopen this panel to scan again."
|
|
||||||
color: Qt.darker(root.bar.foreground, 1.5)
|
color: Qt.darker(root.bar.foreground, 1.5)
|
||||||
font.family: root.bar.fontFamily
|
font.family: root.bar.fontFamily
|
||||||
font.pixelSize: Style.font.bodySmall
|
font.pixelSize: Style.font.bodySmall
|
||||||
|
|||||||
Reference in New Issue
Block a user