summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-08-17 13:30:04 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-08-18 00:44:22 +0800
commit4fdcac3dd0b5748f1b45769f9429062c63aaf7c4 (patch)
tree53ecd396c1ed6f783344157e50ffec212d5e345e
parent62c60ddf9ea8491406f125836772c66c70f01605 (diff)
feat: standalone also toggle instead of only spawning
-rw-r--r--shell.qml71
1 files changed, 37 insertions, 34 deletions
diff --git a/shell.qml b/shell.qml
index 10cf88b..7e17826 100644
--- a/shell.qml
+++ b/shell.qml
@@ -24,50 +24,53 @@ Scope {
}
IpcHandler {
target: "launcher"
+ property var standaloneObj: null
function toggle() {
launcherLoader.active = !launcherLoader.active;
}
function standalone(component: string): void {
- // NOTE: 'component' must be a QML type name (e.g., 'Calc'), not a 'Component { ... }' block.
- // Passing a full Component block will cause a QML error.
- Qt.createQmlObject(`
- import Quickshell
- import QtQuick
- import "launcher"
- import "launcher/components"
+ if (standaloneObj) {
+ standaloneObj.active = !standaloneObj.active;
+ return;
+ }
+ standaloneObj = Qt.createQmlObject(`
+ import Quickshell
+ import QtQuick
+ import "launcher"
+ import "launcher/components"
- LazyLoader {
- property QtObject selectionState: QtObject {
- property Item selected: null
- property string input: ""
- property int cursorPosition: 0
- property var priorities: []
- property int selectedPriority: 0
- property int previousSelectedPriority: 0
- property var widgets: []
- }
- readonly property list<Component> widgets: [
- Component {
- Loader {
- sourceComponent: Qt.createComponent("launcher/components/" + "${component}.qml")
- onLoaded: {
- item.standalone = true
- item.state = selectionState;
+ LazyLoader {
+ property QtObject selectionState: QtObject {
+ property Item selected: null
+ property string input: ""
+ property int cursorPosition: 0
+ property var priorities: []
+ property int selectedPriority: 0
+ property int previousSelectedPriority: 0
+ property var widgets: []
+ }
+ readonly property list<Component> widgets: [
+ Component {
+ Loader {
+ sourceComponent: Qt.createComponent("launcher/components/" + "${component}.qml")
+ onLoaded: {
+ item.standalone = true
+ item.state = selectionState;
+ }
+ }
}
+ ]
+ id: root
+ active: true
+ component: Launcher {
+ widgetItems: widgets
+ state: selectionState
+ parentLoader: root
}
}
- ]
- id: root
- active: true
- component: Launcher {
- widgetItems: widgets
- state: selectionState
- parentLoader: root
- }
- }
- `, root);
+ `, root);
}
}