diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-04 15:40:31 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-04 15:40:31 +1000 |
| commit | 050ddf7c3e4ea6aa7a18087d17aee2a43781d0af (patch) | |
| tree | 58a93f727211aa79604891d6536b5e01b56ef795 /modules/launcher/items | |
| parent | plugin/cim: use QtConcurrent (diff) | |
| download | caelestia-shell-050ddf7c3e4ea6aa7a18087d17aee2a43781d0af.tar.gz caelestia-shell-050ddf7c3e4ea6aa7a18087d17aee2a43781d0af.tar.bz2 caelestia-shell-050ddf7c3e4ea6aa7a18087d17aee2a43781d0af.zip | |
plugin: add qalculator
For launcher >calc instead of qalc proc
Diffstat (limited to 'modules/launcher/items')
| -rw-r--r-- | modules/launcher/items/CalcItem.qml | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/modules/launcher/items/CalcItem.qml b/modules/launcher/items/CalcItem.qml index 211ac61..120866f 100644 --- a/modules/launcher/items/CalcItem.qml +++ b/modules/launcher/items/CalcItem.qml @@ -1,8 +1,8 @@ import qs.components import qs.services import qs.config +import Caelestia import Quickshell -import Quickshell.Io import QtQuick import QtQuick.Layouts @@ -13,7 +13,7 @@ Item { readonly property string math: list.search.text.slice(`${Config.launcher.actionPrefix}calc `.length) function onClicked(): void { - Quickshell.execDetached(["sh", "-c", `qalc -t -m 100 '${root.math}' | wl-copy`]); + Quickshell.execDetached(["wl-copy", Qalculator.eval(math, false)]); root.list.visibilities.launcher = false; } @@ -22,13 +22,6 @@ Item { anchors.left: parent?.left anchors.right: parent?.right - onMathChanged: { - if (math) { - qalcProc.command = ["qalc", "-m", "100", math]; - qalcProc.running = true; - } - } - StateLayer { radius: Appearance.rounding.full @@ -37,22 +30,6 @@ Item { } } - Binding { - id: binding - - when: root.math.length > 0 - target: metrics - property: "text" - } - - Process { - id: qalcProc - - stdout: StdioCollector { - onStreamFinished: binding.value = text.trim() - } - } - RowLayout { anchors.left: parent.left anchors.right: parent.right @@ -71,28 +48,18 @@ Item { id: result color: { - if (metrics.text.includes("error: ")) + if (text.includes("error: ") || text.includes("warning: ")) return Colours.palette.m3error; if (!root.math) return Colours.palette.m3onSurfaceVariant; return Colours.palette.m3onSurface; } - text: metrics.elidedText - font.pointSize: Appearance.font.size.normal + text: root.math.length > 0 ? Qalculator.eval(root.math) : qsTr("Type an expression to calculate") + elide: Text.ElideLeft Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter - - TextMetrics { - id: metrics - - text: qsTr("Type an expression to calculate") - font.family: result.font.family - font.pointSize: result.font.pointSize - elide: Text.ElideRight - elideWidth: result.width - } } StyledRect { |