summaryrefslogtreecommitdiff
path: root/popups
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-07-27 14:46:32 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-07-27 14:57:41 +0800
commit90df3a1a8738d61f747c50f26359ccabf0c7b229 (patch)
tree8df5a8ce0bef4f7cb831ba517ac54969c46fbe19 /popups
parent1f9873b40fee2d33c5b7103a25077ec61a387063 (diff)
new: more advanced math via kalk
refactor(components): optimizations and simplify
Diffstat (limited to 'popups')
-rw-r--r--popups/launcher/components/App.qml13
-rw-r--r--popups/launcher/components/Calc.qml16
-rw-r--r--popups/launcher/components/DateTime.qml (renamed from popups/launcher/components/Date.qml)0
-rw-r--r--popups/launcher/components/ISmartCalc.qml14
-rw-r--r--popups/launcher/components/SelectionState.qml2
5 files changed, 26 insertions, 19 deletions
diff --git a/popups/launcher/components/App.qml b/popups/launcher/components/App.qml
index e90bea1..f9c63e3 100644
--- a/popups/launcher/components/App.qml
+++ b/popups/launcher/components/App.qml
@@ -10,7 +10,7 @@ import qs.config
IComponent {
id: root
- property list<DesktopEntry> entries: active ? AppSearch.query(inputCleaned) : []
+ property list<DesktopEntry> entries: AppSearch.query(inputCleaned)
property int selectedIndex: -1
name: "Applications"
@@ -25,14 +25,15 @@ IComponent {
}
}
- property string predictiveCompletion: valid ? entries[selectedIndex]?.name.slice(input.length) || "" : ""
+ property string predictiveCompletion: entries[selectedIndex]?.name.slice(input.length) || ""
process: function () {
- const isValid = entries.length > 0;
- const selected = isValid ? entries[selectedIndex] : "";
+ const valid = entries.length > 0;
+ // TODO: consider removing the valid check
+ const selected = valid ? entries[selectedIndex] : "";
return {
- valid: isValid,
- priority: isValid,
+ valid,
+ priority: valid,
answer: selected?.icon || ""
};
}
diff --git a/popups/launcher/components/Calc.qml b/popups/launcher/components/Calc.qml
index c6cdbc1..4cc45a7 100644
--- a/popups/launcher/components/Calc.qml
+++ b/popups/launcher/components/Calc.qml
@@ -6,6 +6,8 @@ import qs.components
import qs.services
import qs.config
+import core
+
IComponent {
property int cursorPosition: SelectionState.cursorPosition
@@ -17,17 +19,19 @@ IComponent {
}
process: function () {
- const isValid = /^(?=.*\d)(?=.*[+\-*\/\^])[0-9+\-*\/\^().\s]+$/.test(input);
- const answer = isValid ? String(eval(input.replace(/\^/g, '**').replace(/([\d)])\(/g, '$1*(').replace(/\)([\d])/g, ')*$1'))) : null;
+ MathCalc.query(input);
+ const valid = MathCalc.result && MathCalc.result.length > 0;
+ const answer = MathCalc.result;
return {
- valid: isValid,
- priority: isValid,
- answer: answer,
- predictiveCompletion: isValid ? ' = ' + answer : ''
+ valid,
+ priority: valid,
+ answer,
+ predictiveCompletion: valid ? ' = ' + answer : ''
};
}
exec: function () {
Clip.copy(answer);
+ MathCalc.reset_ctx();
}
IInnerComponent {
diff --git a/popups/launcher/components/Date.qml b/popups/launcher/components/DateTime.qml
index 0929b75..0929b75 100644
--- a/popups/launcher/components/Date.qml
+++ b/popups/launcher/components/DateTime.qml
diff --git a/popups/launcher/components/ISmartCalc.qml b/popups/launcher/components/ISmartCalc.qml
index 6e6381c..5474cc5 100644
--- a/popups/launcher/components/ISmartCalc.qml
+++ b/popups/launcher/components/ISmartCalc.qml
@@ -14,7 +14,6 @@ IComponent {
required property string predictiveText
property int cursorPosition: SelectionState.cursorPosition
- property string answer: active && valid ? SmartCalc.result : ""
preview: Component {
Icon {
@@ -24,13 +23,14 @@ IComponent {
process: function () {
SmartCalc.query(input);
- const isValid = active && SmartCalc.result && SmartCalc.result.length > 0 && category;
- const answer = isValid ? SmartCalc.result : "";
+ const answer = SmartCalc.result;
+ // TODO: use answer property rn its circular dependent since it has to be valid which is the line below
+ const valid = SmartCalc.result && SmartCalc.result.length > 0 && category;
return {
- valid: isValid,
- priority: isValid,
- answer: answer,
- predictiveCompletion: isValid ? ` ${predictiveText} ` + answer : ''
+ valid,
+ priority: valid,
+ answer,
+ predictiveCompletion: ` ${predictiveText} ` + answer
};
}
exec: function () {
diff --git a/popups/launcher/components/SelectionState.qml b/popups/launcher/components/SelectionState.qml
index 1ab577a..212bd1d 100644
--- a/popups/launcher/components/SelectionState.qml
+++ b/popups/launcher/components/SelectionState.qml
@@ -2,6 +2,8 @@ pragma Singleton
import Quickshell
import QtQuick
+// FIXME: fix some selection not show/updated when deselected i.e. "pi" from app back to calc wont visually show deselection of last app
+// FIXME: icon/answer not updated when changed to non first priority
Singleton {
id: root