core: shell state manager

This commit is contained in:
2026-01-23 23:45:38 +02:00
parent edb941fe90
commit 31ea8d7616
2 changed files with 58 additions and 4 deletions

View File

@@ -0,0 +1,52 @@
pragma Singleton
import QtQuick
QtObject {
id: manager
property bool shellOpen: false
property var windowRequests: ({})
property var globals: ({})
signal shellOpened
signal shellClosed
signal windowRequested(string name, var payload)
function openShell() {
if (!shellOpen) {
console.log("ShellStateManager: openShell");
shellOpen = true;
shellOpened();
}
}
function closeShell() {
if (shellOpen) {
console.log("ShellStateManager: closeShell");
shellOpen = false;
shellClosed();
}
}
function toggleShell() {
console.log("ShellStateManager: toggleShell (isOpen " + shellOpen + ")");
shellOpen ? closeShell() : openShell();
}
function requestWindow(name, payload) {
console.log("ShellStateManager: requestWindow", name, payload);
windowRequests[name] = {
payload: payload,
timestamp: Date.now()
};
windowRequested(name, payload);
}
function setGlobal(key, value) {
globals[key] = value;
}
function global(key, defaultValue) {
return globals.hasOwnProperty(key) ? globals[key] : defaultValue;
}
}

View File

@@ -5,7 +5,9 @@ import "Shell"
ShellRoot { ShellRoot {
id: baseShell id: baseShell
property bool isOpen: false
// Use the singleton directly; it controls the shell state globally.
property bool isOpen: ShellStateManager.shellOpen
WLRLayerTopbar { WLRLayerTopbar {
visible: baseShell.isOpen visible: baseShell.isOpen
@@ -20,7 +22,7 @@ ShellRoot {
triggerDescription: "Toggle the menu" triggerDescription: "Toggle the menu"
name: "shell_toggle" name: "shell_toggle"
onReleased: { onReleased: {
baseShell.isOpen = !baseShell.isOpen; ShellStateManager.toggleShell()
} }
} }
@@ -28,10 +30,10 @@ ShellRoot {
target: "deltarune.shell" target: "deltarune.shell"
enabled: true enabled: true
function open(): void { function open(): void {
baseShell.isOpen = true; ShellStateManager.openShell()
} }
function close(): void { function close(): void {
baseShell.isOpen = false; ShellStateManager.closeShell()
} }
} }
} }