summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/Bluetooth.qml45
-rw-r--r--services/Hyprland.qml28
2 files changed, 42 insertions, 31 deletions
diff --git a/services/Bluetooth.qml b/services/Bluetooth.qml
index 7cdd457..4092212 100644
--- a/services/Bluetooth.qml
+++ b/services/Bluetooth.qml
@@ -9,7 +9,7 @@ Singleton {
property bool powered
property bool discovering
- property list<Device> devices: []
+ readonly property list<Device> devices: []
Process {
running: true
@@ -41,27 +41,38 @@ Singleton {
stdout: SplitParser {
onRead: data => {
const devices = JSON.parse(data);
- root.devices = devices.map(d => deviceComp.createObject(root, {
- name: d.Name,
- alias: d.Alias,
- address: d.Address,
- icon: d.Icon,
- connected: d.Connected === "yes",
- paired: d.Paired === "yes",
- trusted: d.Trusted === "yes"
- })).filter(d => d);
+ const rDevices = root.devices;
+
+ const len = rDevices.length;
+ for (let i = 0; i < len; i++) {
+ const device = rDevices[i];
+ if (!devices.find(d => d.address === device?.Address))
+ rDevices.splice(i, 1);
+ }
+
+ for (const device of devices) {
+ const match = rDevices.find(d => d.address === device.Address);
+ if (match) {
+ match.lastIpcObject = device;
+ } else {
+ rDevices.push(deviceComp.createObject(root, {
+ lastIpcObject: device
+ }));
+ }
+ }
}
}
}
component Device: QtObject {
- property string name
- property string alias
- property string address
- property string icon
- property bool connected
- property bool paired
- property bool trusted
+ required property var lastIpcObject
+ readonly property string name: lastIpcObject.Name
+ readonly property string alias: lastIpcObject.Alias
+ readonly property string address: lastIpcObject.Address
+ readonly property string icon: lastIpcObject.Icon
+ readonly property bool connected: lastIpcObject.Connected === "yes"
+ readonly property bool paired: lastIpcObject.Paired === "yes"
+ readonly property bool trusted: lastIpcObject.Trusted === "yes"
}
Component {
diff --git a/services/Hyprland.qml b/services/Hyprland.qml
index 286bee3..481ee7c 100644
--- a/services/Hyprland.qml
+++ b/services/Hyprland.qml
@@ -82,20 +82,20 @@ Singleton {
component Client: QtObject {
required property var lastIpcObject
- property string address: lastIpcObject.address
- property string wmClass: lastIpcObject.class
- property string title: lastIpcObject.title
- property string initialClass: lastIpcObject.initialClass
- property string initialTitle: lastIpcObject.initialTitle
- property int x: lastIpcObject.at[0]
- property int y: lastIpcObject.at[1]
- property int width: lastIpcObject.size[0]
- property int height: lastIpcObject.size[1]
- property HyprlandWorkspace workspace: Hyprland.workspaces.values.find(w => w.id === lastIpcObject.workspace.id) ?? null
- property bool floating: lastIpcObject.floating
- property bool fullscreen: lastIpcObject.fullscreen
- property int pid: lastIpcObject.pid
- property int focusHistoryId: lastIpcObject.focusHistoryID
+ readonly property string address: lastIpcObject.address
+ readonly property string wmClass: lastIpcObject.class
+ readonly property string title: lastIpcObject.title
+ readonly property string initialClass: lastIpcObject.initialClass
+ readonly property string initialTitle: lastIpcObject.initialTitle
+ readonly property int x: lastIpcObject.at[0]
+ readonly property int y: lastIpcObject.at[1]
+ readonly property int width: lastIpcObject.size[0]
+ readonly property int height: lastIpcObject.size[1]
+ readonly property HyprlandWorkspace workspace: Hyprland.workspaces.values.find(w => w.id === lastIpcObject.workspace.id) ?? null
+ readonly property bool floating: lastIpcObject.floating
+ readonly property bool fullscreen: lastIpcObject.fullscreen
+ readonly property int pid: lastIpcObject.pid
+ readonly property int focusHistoryId: lastIpcObject.focusHistoryID
}
Component {