Tier 0: render what the services already decided, honestly
Claude-Session: https://claude.ai/code/session_01Ms2FbjQy31TVf3CEvQhGM8
This commit is contained in:
@@ -6,6 +6,7 @@ import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import Quickshell.Bluetooth
|
||||
import qs.config
|
||||
import qs.services
|
||||
|
||||
Item {
|
||||
id: root
|
||||
@@ -16,7 +17,15 @@ Item {
|
||||
property alias maxHeight: list.maxHeight
|
||||
|
||||
readonly property var adapter: Bluetooth.defaultAdapter
|
||||
property bool discoveryOwned: false
|
||||
|
||||
// Discovery is held, not switched. This picker and the settings page both
|
||||
// list the same adapter, and each writing adapter.discovering from its own
|
||||
// visibility flag meant the last one to change its mind decided for both --
|
||||
// closing the settings page stopped discovery under this panel, which then
|
||||
// said "Searching…" over a radio that had stopped. Connectivity counts the
|
||||
// holds, owns the BlueZ write, and never stops a scan it did not start;
|
||||
// nothing here touches the adapter.
|
||||
readonly property string scanHold: "quicksettings-bluetooth"
|
||||
|
||||
implicitHeight: list.implicitHeight
|
||||
|
||||
@@ -32,29 +41,14 @@ Item {
|
||||
return list;
|
||||
}
|
||||
|
||||
function syncDiscovery(): void {
|
||||
if (!root.adapter)
|
||||
return;
|
||||
const shouldDiscover = root.active && root.adapter.enabled;
|
||||
if (shouldDiscover && !root.adapter.discovering) {
|
||||
root.adapter.discovering = true;
|
||||
root.discoveryOwned = true;
|
||||
} else if (!shouldDiscover && root.discoveryOwned && root.adapter.discovering) {
|
||||
root.adapter.discovering = false;
|
||||
root.discoveryOwned = false;
|
||||
}
|
||||
}
|
||||
|
||||
onActiveChanged: root.syncDiscovery()
|
||||
onAdapterChanged: {
|
||||
onActiveChanged: {
|
||||
if (root.active)
|
||||
root.syncDiscovery();
|
||||
Connectivity.acquireDiscovery(root.scanHold);
|
||||
else
|
||||
Connectivity.releaseDiscovery(root.scanHold);
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
if (root.adapter && root.discoveryOwned && root.adapter.discovering)
|
||||
root.adapter.discovering = false;
|
||||
}
|
||||
Component.onDestruction: Connectivity.releaseDiscovery(root.scanHold)
|
||||
|
||||
function stateText(device): string {
|
||||
if (device.pairing)
|
||||
|
||||
Reference in New Issue
Block a user