summaryrefslogtreecommitdiff
path: root/popups
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-07-26 18:16:25 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-07-26 18:16:25 +0800
commitc119b2cf8eb2fe2cb2b204e870deb7c6dfb189ee (patch)
tree82be34f895614eafd89f4b8cce3e5e1dd08439b3 /popups
parent7bc4e6df35894a18aec7695375bc7c47e78ba8cb (diff)
init: qml_plugin
new(plugin): date
Diffstat (limited to 'popups')
-rw-r--r--popups/launcher/components/Clip.qml4
-rw-r--r--popups/launcher/components/Date.qml84
2 files changed, 88 insertions, 0 deletions
diff --git a/popups/launcher/components/Clip.qml b/popups/launcher/components/Clip.qml
index 000b2aa..a8f1863 100644
--- a/popups/launcher/components/Clip.qml
+++ b/popups/launcher/components/Clip.qml
@@ -207,4 +207,8 @@ IComponent {
}
}
}
+
+ Component.onCompleted: {
+
+ }
}
diff --git a/popups/launcher/components/Date.qml b/popups/launcher/components/Date.qml
new file mode 100644
index 0000000..43cb99e
--- /dev/null
+++ b/popups/launcher/components/Date.qml
@@ -0,0 +1,84 @@
+import Quickshell
+import QtQuick
+import QtQuick.Layouts
+
+import qs.components
+import qs.services
+import qs.config
+
+import core
+
+IComponent {
+ property string answer: active && valid ? SmartCalc.result : ""
+
+ name: "Date"
+ preview: Component {
+ Icon {
+ text: "๐Ÿ“…"
+ }
+ }
+
+ process: function () {
+ SmartCalc.query(input);
+ const isValid = active && SmartCalc.result && SmartCalc.result.length > 0 && (SmartCalc.result_type == SmartCalc.Time || SmartCalc.result_type == SmartCalc.Date);
+ const answer = isValid ? SmartCalc.result : "";
+ return {
+ valid: isValid,
+ priority: isValid,
+ answer: answer,
+ predictiveCompletion: isValid ? ' is ' + answer : ''
+ };
+ }
+ exec: function () {
+ Clip.copy(answer);
+ }
+
+ IInnerComponent {
+ RowLayout {
+ spacing: 0
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.preferredHeight: parent.height
+
+ Item {
+ Layout.fillWidth: true
+ IText {
+ anchors.centerIn: parent
+ elide: cursorPosition > input.length / 2 ? Text.ElideLeft : Text.ElideRight
+ width: Math.min(implicitWidth, parent.width - Launcher.innerMargin * 2)
+ clip: true
+ renderType: Text.CurveRendering
+ visible: valid
+ text: input.replace(/ /g, "").replace(/\+/g, " + ").replace(/-/g, " - ").replace(/\*/g, " ร— ").replace(/\//g, " รท ").replace(/%/g, " % ").replace(/\(/g, " ( ").replace(/\)/g, " ) ")
+ font {
+ pixelSize: Launcher.widgetFontSize
+ bold: true
+ }
+ }
+ }
+
+ IText {
+ visible: valid
+ text: "โ†’"
+ font.pixelSize: Launcher.widgetFontSize
+ font.bold: true
+ }
+
+ Item {
+ Layout.fillWidth: true
+ IText {
+ animate: true
+ anchors.centerIn: parent
+ width: Math.min(implicitWidth, parent.width - Launcher.innerMargin * 2)
+ renderType: Text.CurveRendering
+ visible: valid
+ text: valid ? answer : ''
+ font {
+ pixelSize: Launcher.widgetFontSize
+ bold: true
+ }
+ }
+ }
+ }
+ }
+}