init: working version
This commit is contained in:
commit
7d8d7dacae
109 changed files with 15066 additions and 0 deletions
96
modules/ui/UIState.qml
Normal file
96
modules/ui/UIState.qml
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
|
||||
import qs.services
|
||||
import qs.util
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
|
||||
Scope {
|
||||
id: root
|
||||
|
||||
required property ShellScreen screen
|
||||
property alias uiState: uiState
|
||||
|
||||
PersistentProperties {
|
||||
id: uiState
|
||||
reloadableId: `uiState-${QsWindow.window.screen.name}`
|
||||
|
||||
// Open panels
|
||||
property bool dashboard
|
||||
property bool launcher
|
||||
property bool osd
|
||||
property bool session
|
||||
|
||||
property bool blockScreen
|
||||
|
||||
// Other state
|
||||
property ListModel workspaces
|
||||
property int dashboardTab: 0
|
||||
property bool osdVolumeReact: true
|
||||
property bool osdBrightnessReact: true
|
||||
|
||||
Component.onCompleted: {
|
||||
workspaces = listModelComp.createObject(this);
|
||||
States.load(root.screen, this);
|
||||
}
|
||||
}
|
||||
|
||||
// Workspace Handling
|
||||
|
||||
Component {
|
||||
id: listModelComp
|
||||
ListModel {}
|
||||
}
|
||||
|
||||
// Initialize workspace list
|
||||
Timer {
|
||||
running: true
|
||||
interval: Hypr.arbitraryRaceConditionDelay
|
||||
onTriggered: {
|
||||
// NOTE: Reinitialize workspace list on reload because persistence doesn't work
|
||||
uiState.workspaces = listModelComp.createObject(uiState);
|
||||
Hypr.workspaces.values.forEach(w => {
|
||||
if (w.monitor === Hypr.monitorFor(root.screen))
|
||||
uiState.workspaces.append({"workspace": w});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Remove deleted workspaces
|
||||
Connections {
|
||||
target: Hypr.workspaces
|
||||
function onObjectRemovedPost(workspace, index) {
|
||||
root.removeWorkspace(workspace);
|
||||
}
|
||||
}
|
||||
|
||||
// Update workspaces moved between monitors
|
||||
// (also handles initialized workspaces)
|
||||
Instantiator {
|
||||
model: Hypr.workspaces
|
||||
delegate: Connections {
|
||||
required property HyprlandWorkspace modelData
|
||||
target: modelData
|
||||
function onMonitorChanged() {
|
||||
if (modelData.monitor === Hypr.monitorFor(root.screen)) {
|
||||
uiState.workspaces.append({"workspace": modelData});
|
||||
} else {
|
||||
root.removeWorkspace(modelData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeWorkspace(workspace: HyprlandWorkspace): void {
|
||||
let i = 0;
|
||||
while (i < uiState.workspaces.count) {
|
||||
const w = uiState.workspaces.get(i).workspace;
|
||||
if (w === workspace) {
|
||||
uiState.workspaces.remove(i);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue