summaryrefslogtreecommitdiff
path: root/package/contents/ui/ConfigGeneral.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/ConfigGeneral.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/ConfigGeneral.qml')
-rw-r--r--package/contents/ui/ConfigGeneral.qml80
1 files changed, 80 insertions, 0 deletions
diff --git a/package/contents/ui/ConfigGeneral.qml b/package/contents/ui/ConfigGeneral.qml
new file mode 100644
index 0000000..9428ed0
--- /dev/null
+++ b/package/contents/ui/ConfigGeneral.qml
@@ -0,0 +1,80 @@
+import QtQuick 6.0
+import QtQuick.Layouts 1.15
+import QtQuick.Controls 6.0 as Controls
+import org.kde.kirigami as Kirigami
+import org.kde.kcmutils as KCM
+import org.kde.plasma.workspace.dbus as DBus
+
+KCM.SimpleKCM {
+ id: page
+
+ // KCM properties that will be automatically managed
+ property alias cfg_mqttClientId: mqttClientIdField.text
+ property alias cfg_mqttHosts: mqttHostsField.text
+ property alias cfg_mqttUsername: mqttUsernameField.text
+ property alias cfg_mqttPassword: mqttPasswordField.text
+ property alias cfg_refreshIntervalSeconds: refreshIntervalField.value
+
+ // Default values for KCM system
+ property string cfg_mqttClientIdDefault: "camper-widget-refresh"
+ property string cfg_mqttHostsDefault: "127.0.0.1:1883"
+ property string cfg_mqttUsernameDefault: ""
+ property string cfg_mqttPasswordDefault: ""
+ property int cfg_refreshIntervalSecondsDefault: 60
+
+ Kirigami.FormLayout {
+ anchors.fill: parent
+
+ Controls.TextField {
+ id: mqttClientIdField
+ Kirigami.FormData.label: i18n("MQTT client ID")
+ placeholderText: "camper-widget-refresh"
+ }
+
+ Controls.TextField {
+ id: mqttHostsField
+ Kirigami.FormData.label: i18n("MQTT hosts")
+ placeholderText: "127.0.0.1:1883"
+ Controls.ToolTip.visible: hovered
+ Controls.ToolTip.text: i18n("Comma separated list, e.g. 127.0.0.1 or 127.0.0.1,192.168.1.111 or 127.0.0.1:1883,192.168.1.111:1883")
+ }
+
+ Controls.TextField {
+ id: mqttUsernameField
+ Kirigami.FormData.label: i18n("MQTT username")
+ placeholderText: ""
+ }
+
+ Controls.TextField {
+ id: mqttPasswordField
+ Kirigami.FormData.label: i18n("MQTT password")
+ echoMode: Controls.TextField.Password
+ placeholderText: ""
+ }
+
+ Controls.SpinBox {
+ id: refreshIntervalField
+ Kirigami.FormData.label: i18n("Refresh interval (seconds)")
+ from: 1
+ to: 86400
+ stepSize: 1
+ }
+ }
+
+ // Notify config changes when KCM properties change
+ onCfg_mqttClientIdChanged: notifyConfigChanged()
+ onCfg_mqttHostsChanged: notifyConfigChanged()
+ onCfg_mqttUsernameChanged: notifyConfigChanged()
+ onCfg_mqttPasswordChanged: notifyConfigChanged()
+ onCfg_refreshIntervalSecondsChanged: notifyConfigChanged()
+
+ function notifyConfigChanged() {
+ DBus.SessionBus.asyncCall({
+ service: "org.craftknight.CamperWidget",
+ path: "/org/craftknight/camper_widget",
+ iface: "org.craftknight.CamperWidget.Config",
+ member: "Reload",
+ signature: ""
+ })
+ }
+}