diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-10-27 17:08:03 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-10-27 17:08:03 +0800 |
| commit | 0921aaaee9d2dfda81bd3db6cccac2c5dba9821c (patch) | |
| tree | 2b49e0a9380af6454fc390266d9407661042288b | |
| parent | e5385b8e813b24a36d8b397ffd3544b48f775696 (diff) | |
refactor(standalonelauncher): inline qml -> separate file
| -rw-r--r-- | popups/launcher/StandaloneLauncher.qml | 42 | ||||
| -rw-r--r-- | shell.qml | 44 |
2 files changed, 45 insertions, 41 deletions
diff --git a/popups/launcher/StandaloneLauncher.qml b/popups/launcher/StandaloneLauncher.qml new file mode 100644 index 0000000..e3ab641 --- /dev/null +++ b/popups/launcher/StandaloneLauncher.qml @@ -0,0 +1,42 @@ +import Quickshell +import QtQuick + +import "components" + +LazyLoader { + id: root + + required property string componentName + + // TODO: just use the same selectionState + property QtObject selectionState: QtObject { + property Item selected: null + property string input: "" + property int cursorPosition: 0 + property var priorities: [] + property int selectedPriority: 0 + property var widgets: [] + } + + readonly property list<Component> widgets: [ + Component { + Loader { + sourceComponent: Qt.createComponent(`components/${root.componentName}.qml`) + onLoaded: { + item.standalone = true; + item.state = selectionState; + item.priority = true; + item.close.connect(() => root.active = false); + } + } + } + ] + + active: true + component: Launcher { + name: "quickshell::launcher::${component}" + widgetItems: widgets + state: selectionState + parentLoader: root + } +} @@ -11,8 +11,6 @@ import core import qs.services -// TODO: remove all MouseArea and use modern alternative - Scope { id: root @@ -56,45 +54,9 @@ Scope { root.standaloneObj.obj.active = !root.standaloneObj.obj.active; return; } - root.standaloneObj.obj = Qt.createQmlObject(` - import Quickshell - import QtQuick - import "popups/launcher" - import "popups/launcher/components" - - LazyLoader { - // TODO: just use the same selectionState - property QtObject selectionState: QtObject { - property Item selected: null - property string input: "" - property int cursorPosition: 0 - property var priorities: [] - property int selectedPriority: 0 - property var widgets: [] - } - readonly property list<Component> widgets: [ - Component { - Loader { - sourceComponent: Qt.createComponent("popups/launcher/components/${component}.qml") - onLoaded: { - item.standalone = true - item.state = selectionState; - item.priority = true - item.close.connect(() => root.active = false); - } - } - } - ] - id: root - active: true - component: Launcher { - name: "quickshell::launcher::${component}" - widgetItems: widgets - state: selectionState - parentLoader: root - } - } - `, root); + root.standaloneObj.obj = Qt.createComponent("popups/launcher/StandaloneLauncher.qml", Component.PreferSynchronous, root).createObject(root, { + componentName: component + }); root.standaloneObj.name = component; } } |
