From b0a018f4b6831d3289d8cb3604af2c9d9d12e4e8 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 7 Aug 2025 16:40:04 +0800 Subject: chore: standardize more Component functions fix(Spell): not found if its correct --- launcher/components/App.qml | 2 +- launcher/components/IComponent.qml | 6 ++++-- launcher/components/Spell.qml | 21 ++++++++++++--------- 3 files changed, 17 insertions(+), 12 deletions(-) (limited to 'launcher') diff --git a/launcher/components/App.qml b/launcher/components/App.qml index f36e10e..f7c4e33 100644 --- a/launcher/components/App.qml +++ b/launcher/components/App.qml @@ -10,7 +10,7 @@ import qs.config IComponent { id: root - property list entries: inputCleaned ? AppSearch.fuzzyQuery(inputCleaned) : [] + property list entries: active ? AppSearch.fuzzyQuery(inputCleaned) : [] property int selectedIndex: -1 name: "Applications" diff --git a/launcher/components/IComponent.qml b/launcher/components/IComponent.qml index 661dd67..f0dc5f6 100644 --- a/launcher/components/IComponent.qml +++ b/launcher/components/IComponent.qml @@ -8,9 +8,11 @@ IRect { id: root // virtual properties property string name // Component/File name - readonly property string input: SelectionState.input + readonly property string _input: SelectionState.input + readonly property string input: _input.slice(prefix.length) readonly property string inputCleaned: input.toLowerCase().trim() property string prefix + property bool active: input && _input.startsWith(prefix) 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 || "" @@ -21,7 +23,7 @@ IRect { } } property string predictiveCompletion: processed?.predictiveCompletion || "" // would technically work with just from answer, but stuff like calc's answer wouldnt have anything to do with the input - property var processed: input && input.startsWith(prefix) ? process() : {} // cached process, thought qml would do that automatically :/ + property var processed: active ? process() : {} // cached process, thought qml would do that automatically :/ property var process: () => ({ valid: valid, priority: priority, diff --git a/launcher/components/Spell.qml b/launcher/components/Spell.qml index 5d45e0b..61de03f 100644 --- a/launcher/components/Spell.qml +++ b/launcher/components/Spell.qml @@ -11,7 +11,6 @@ IComponent { id: root property list aspell - property string word: input.slice(prefix.length) property int selectedIndex: -1 name: "Spell" @@ -58,17 +57,19 @@ IComponent { } process: function () { - proc.running = true; + Qt.callLater(() => { + proc.running = true; + }); const isValid = selectedIndex >= 0 && aspell.length > 0; - const selected = isValid ? aspell[selectedIndex] : "n"; - const answer = selected === "*" ? word : selected; + const selected = isValid ? aspell[selectedIndex] : ""; + const answer = selected === "*" ? input : selected; return { valid: isValid, priority: isValid, answer: isValid ? answer : "", - predictiveCompletion: isValid ? answer.slice(word.length) : "" + predictiveCompletion: isValid ? answer.slice(input.length) : "" }; } @@ -116,7 +117,7 @@ IComponent { if (aspell[selectedIndex] !== "*") Clip.copy(aspell[selectedIndex]); else - Clip.copy(word); + Clip.copy(input); } function syncSelectionState() { @@ -215,15 +216,17 @@ IComponent { Process { id: proc - command: ["sh", "-c", "echo " + word + " | aspell -a"] + command: ["sh", "-c", "echo " + input + " | aspell -a"] property bool found: false stdout: SplitParser { onRead: data => { if (data.startsWith("&")) { proc.found = true; - aspell = data.split(/\W+/).filter(word => /^[A-Za-z]+$/.test(word)).slice(1); - } else if (data.startsWith("*")) + aspell = data.split(/\W+/).filter(input => /^[A-Za-z]+$/.test(input)).slice(1); + } else if (data.startsWith("*")) { + proc.found = true; aspell = ["*"]; + } } } onStarted: { -- cgit v1.2.3