From 515cfc951e94acbb8afbccd3dcf5b67315fcecf9 Mon Sep 17 00:00:00 2001 From: "pls.153" Date: Mon, 22 Jul 2024 16:36:22 +0200 Subject: [PATCH] example 'meshtastic': sync Qt6 QML --- .../qml/ext/radios/BatteryLevel.qml | 16 ++++++++++------ .../meshtastic-qt6/qml/ext/radios/Radios.qml | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/meshtastic-qt6/qml/ext/radios/BatteryLevel.qml b/examples/meshtastic-qt6/qml/ext/radios/BatteryLevel.qml index 0055c37..5f262ba 100644 --- a/examples/meshtastic-qt6/qml/ext/radios/BatteryLevel.qml +++ b/examples/meshtastic-qt6/qml/ext/radios/BatteryLevel.qml @@ -3,32 +3,36 @@ import QtQuick Rectangle { anchors.verticalCenter: parent.verticalCenter width: 12 - height: 22 + height: 25 color: (level > 15) ? "#f0f0f0" : "yellow" radius: 2 border.width: 1 border.color: "#808080" - property int level: 0 + property string voltage + property string level + + function percent() { return parseInt(level, 10) } Rectangle { x: 1 width: parent.width - 2 - height: (parent.height - 2) * level / 100 + height: (parent.height - 2) * percent() / 100 anchors.bottom: parent.bottom anchors.bottomMargin: 1 - color: (level > 15) ? "#28c940" : "#ff5f57" + color: (percent() > 15) ? "#28c940" : "#ff5f57" } Text { x: -4 - paintedWidth height: parent.height verticalAlignment: Text.AlignVCenter - font.pixelSize: 12 + horizontalAlignment: Text.AlignRight + font.pixelSize: 11 font.family: fontText.name font.weight: Font.DemiBold color: "white" - text: level + "%" + text: voltage + "\n" + level } } diff --git a/examples/meshtastic-qt6/qml/ext/radios/Radios.qml b/examples/meshtastic-qt6/qml/ext/radios/Radios.qml index 3f95eab..5083ee9 100644 --- a/examples/meshtastic-qt6/qml/ext/radios/Radios.qml +++ b/examples/meshtastic-qt6/qml/ext/radios/Radios.qml @@ -49,7 +49,7 @@ Rectangle { // hack to define all model key _types_ ListElement { - name: ""; ini: false; hwModel: ""; batteryLevel: 0; current: false + name: ""; ini: false; hwModel: ""; voltage: ""; batteryLevel: ""; current: false } function addRadio(radio) { @@ -109,6 +109,7 @@ Rectangle { Rad.BatteryLevel { anchors.right: parent.right anchors.rightMargin: 14 + voltage: model.voltage level: model.batteryLevel visible: !model.ini }