From b17ae550381232fd8c0cce5024e8ec0852918a33 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 11 Aug 2025 19:16:05 +0800 Subject: feat(shell): implement standalone function for dynamic component loading feat(Searchable): add Include algorithm and update filtering logic fix(Launcher): refactor state handling and improve selection logic fix(Clip): update clipHist property initialization and selection state sync refactor(IComponent): enhance state management and streamline properties refactor(Clip): change algorithm to Include for improved search functionality --- launcher/components/Clip.qml | 10 ++++------ launcher/components/IComponent.qml | 14 ++++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'launcher/components') diff --git a/launcher/components/Clip.qml b/launcher/components/Clip.qml index ffec453..789cd48 100644 --- a/launcher/components/Clip.qml +++ b/launcher/components/Clip.qml @@ -10,7 +10,7 @@ import qs.config IComponent { id: root - property var clipHist: active ? Clip.query(inputCleaned) : [] + property var clipHist: Clip.query(inputCleaned) property int selectedIndex: -1 name: "Clipboard" @@ -21,11 +21,9 @@ IComponent { process: function () { const isValid = clipHist.length > 0; - const selected = isValid && clipHist[selectedIndex]; return { valid: isValid, - priority: isValid, - answer: selected.data || "" + priority: isValid }; } @@ -65,8 +63,8 @@ IComponent { function syncSelectionState() { Qt.callLater(() => { // fucking Qt why tf is repeater not ready when this is called - SelectionState.selected = repeater.itemAt(selectedIndex); - SelectionState.exec = root.exec; + state.selected = repeater.itemAt(selectedIndex); + state.exec = root.exec; }); } diff --git a/launcher/components/IComponent.qml b/launcher/components/IComponent.qml index f0dc5f6..fdeb5b6 100644 --- a/launcher/components/IComponent.qml +++ b/launcher/components/IComponent.qml @@ -7,12 +7,14 @@ import qs.config IRect { id: root // virtual properties + property bool standalone: false + property var state: SelectionState property string name // Component/File name - readonly property string _input: SelectionState.input - readonly property string input: _input.slice(prefix.length) + readonly property string _input: state.input + readonly property string input: !standalone ? _input.slice(prefix.length) : _input readonly property string inputCleaned: input.toLowerCase().trim() property string prefix - property bool active: input && _input.startsWith(prefix) + property bool active: !standalone ? input && _input.startsWith(prefix) : true property bool valid: processed?.valid || false property bool priority: valid && processed?.priority || false // please set priority to false if it's invalid property string answer: processed?.answer || "" @@ -66,7 +68,11 @@ IRect { color: Qt.rgba(Colors.background3.r, Colors.background3.g, Colors.background3.b, Launcher.widgetBgTransparency) // TODO when prioritized, highlight onPriorityChanged: { - SelectionState.priorities = [...[...SelectionState.priorities, root].reduce((s, x) => (s[(s.has(x) && 'delete') || 'add'](x), s), new Set())]; // sync with SelectionState.priorities + // sync with state.priorities + if (!standalone) + state.priorities = [...[...state.priorities, root].reduce((s, x) => (s[(s.has(x) && 'delete') || 'add'](x), s), new Set())]; + else + state.priorities = [this]; } Behavior on y { -- cgit v1.2.3