summaryrefslogtreecommitdiff
path: root/package/contents/ui/FormatUtils.qml
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2026-02-07 17:29:48 +0100
committerDawid Rycerz <dawid@rycerz.xyz>2026-02-07 17:29:48 +0100
commit2eda97537b63d68b2e9ba06500e3fb491894d10c (patch)
tree52873ad380cd97f4327765aac24659a2b00079b1 /package/contents/ui/FormatUtils.qml
feat: camper van energy monitoring widget for Plasma 6main
Pure QML KPackage widget with Rust background service for real-time Victron energy system monitoring via MQTT and D-Bus. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'package/contents/ui/FormatUtils.qml')
-rw-r--r--package/contents/ui/FormatUtils.qml31
1 files changed, 31 insertions, 0 deletions
diff --git a/package/contents/ui/FormatUtils.qml b/package/contents/ui/FormatUtils.qml
new file mode 100644
index 0000000..9fe400a
--- /dev/null
+++ b/package/contents/ui/FormatUtils.qml
@@ -0,0 +1,31 @@
+import QtQuick 6.0
+
+QtObject {
+ function formatSoc(soc) {
+ if (soc === undefined || soc === null || isNaN(soc) || soc < 0) {
+ return "--"
+ }
+ return Math.round(soc) + "%"
+ }
+
+ function formatPower(connected, power) {
+ if (!connected) {
+ return "--"
+ }
+ return Math.round(power) + "W"
+ }
+
+ function formatSolar(solarPower) {
+ if (solarPower === undefined || solarPower === null || isNaN(solarPower) || solarPower < 0) {
+ return "--"
+ }
+ return Math.round(solarPower) + "W"
+ }
+
+ function formatAcPower(power) {
+ if (power === undefined || power === null || isNaN(power) || power < 0) {
+ return "--"
+ }
+ return Math.round(power) + "W"
+ }
+}