Initial commit of the Quickshell desktop suite: bar, dock, launcher, settings, Control Center, dashboard, OSD, lock screen, desktop widgets, plugin host with the vendored Noctalia/Omarchy compatibility layer, helpers, packaging, tests and phase documentation. Includes the optimization work so far: usage widgets and dashboard gauges no longer animate continuously, desktop widgets pause while covered, system controls stop flickering on background polls, dock app matching uses an indexed catalog, and workspace ghosts are created only for occupied slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
1.8 KiB
QML
55 lines
1.8 KiB
QML
pragma Singleton
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Bluetooth
|
|
|
|
Singleton {
|
|
id: root
|
|
property var backend: Bluetooth
|
|
property string adapterId: ""
|
|
readonly property var adapters: backend.adapters.values
|
|
readonly property var adapter: adapters.find(a => a.adapterId === adapterId) || backend.defaultAdapter
|
|
readonly property var devices: adapter ? adapter.devices.values : []
|
|
readonly property bool canToggle: !!adapter && adapter.state !== BluetoothAdapterState.Blocked
|
|
readonly property bool enabled: !!adapter && adapter.enabled
|
|
readonly property string summary: devices.filter(d => d.connected).map(d => d.name).join(", ") || (enabled ? "On" : "Off")
|
|
property string error: ""
|
|
property var pending: null
|
|
function toggle() {
|
|
if (!adapter || adapter.state === BluetoothAdapterState.Blocked)
|
|
return false;
|
|
error = "";
|
|
adapter.enabled = !enabled;
|
|
return true;
|
|
}
|
|
function connectDevice(device) {
|
|
if (!device || !device.paired || !enabled || pending)
|
|
return false;
|
|
error = "";
|
|
pending = device;
|
|
timeout.restart();
|
|
if (device.connected)
|
|
device.disconnect();
|
|
else
|
|
device.connect();
|
|
return true;
|
|
}
|
|
Connections {
|
|
target: root.pending
|
|
function onStateChanged() {
|
|
if (root.pending && (root.pending.state === BluetoothDeviceState.Connected || root.pending.state === BluetoothDeviceState.Disconnected)) {
|
|
timeout.stop();
|
|
root.pending = null;
|
|
}
|
|
}
|
|
}
|
|
Timer {
|
|
id: timeout
|
|
interval: 15000
|
|
onTriggered: {
|
|
root.error = "No connection confirmation received. Open the Bluetooth manager for details.";
|
|
root.pending = null;
|
|
}
|
|
}
|
|
}
|