hyprland: use qtobjects
This commit is contained in:
parent
2be8327d16
commit
7358e10bcb
1 changed files with 31 additions and 22 deletions
|
|
@ -8,12 +8,12 @@ import QtQuick
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property ListModel clients: ListModel {}
|
property list<Client> clients: []
|
||||||
readonly property var workspaces: Hyprland.workspaces
|
readonly property var workspaces: Hyprland.workspaces
|
||||||
readonly property var monitors: Hyprland.monitors
|
readonly property var monitors: Hyprland.monitors
|
||||||
property var activeClient: null
|
readonly property Client activeClient: Client {}
|
||||||
property HyprlandWorkspace activeWorkspace: focusedMonitor?.activeWorkspace ?? null
|
readonly property HyprlandWorkspace activeWorkspace: focusedMonitor?.activeWorkspace ?? null
|
||||||
property HyprlandMonitor focusedMonitor: Hyprland.monitors.values.find(m => m.lastIpcObject.focused) ?? null
|
readonly property HyprlandMonitor focusedMonitor: Hyprland.monitors.values.find(m => m.lastIpcObject.focused) ?? null
|
||||||
|
|
||||||
function reload() {
|
function reload() {
|
||||||
Hyprland.refreshWorkspaces();
|
Hyprland.refreshWorkspaces();
|
||||||
|
|
@ -43,15 +43,9 @@ Singleton {
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
onRead: data => {
|
onRead: data => {
|
||||||
const clients = JSON.parse(data);
|
const clients = JSON.parse(data);
|
||||||
root.clients.clear();
|
root.clients = clients.map(c => clientComp.createObject(root, {
|
||||||
for (const client of clients) {
|
lastIpcObject: c
|
||||||
root.clients.append({
|
})).filter(c => c);
|
||||||
lastIpcObject: client,
|
|
||||||
address: client.address,
|
|
||||||
class: client.class,
|
|
||||||
title: client.title
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -60,15 +54,30 @@ Singleton {
|
||||||
id: getActiveClient
|
id: getActiveClient
|
||||||
command: ["sh", "-c", "hyprctl -j activewindow | jq -c"]
|
command: ["sh", "-c", "hyprctl -j activewindow | jq -c"]
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
onRead: data => {
|
onRead: data => root.activeClient.lastIpcObject = JSON.parse(data)
|
||||||
const client = JSON.parse(data);
|
|
||||||
root.activeClient = {
|
|
||||||
lastIpcObject: client,
|
|
||||||
address: client.address,
|
|
||||||
class: client.class,
|
|
||||||
title: client.title
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component Client: QtObject {
|
||||||
|
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] ?? 0
|
||||||
|
property int y: lastIpcObject?.at[1] ?? 0
|
||||||
|
property int width: lastIpcObject?.size[0] ?? 0
|
||||||
|
property int height: lastIpcObject?.size[1] ?? 0
|
||||||
|
property HyprlandWorkspace workspace: Hyprland.workspaces.values.find(w => w.id === lastIpcObject?.workspace.id) ?? null
|
||||||
|
property bool floating: lastIpcObject?.floating ?? false
|
||||||
|
property bool fullscreen: lastIpcObject?.fullscreen ?? false
|
||||||
|
property int pid: lastIpcObject?.pid ?? 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: clientComp
|
||||||
|
|
||||||
|
Client {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue