example 'meshtastic': sync Qt6 QML

This commit is contained in:
pls.153 2024-07-22 16:36:22 +02:00
parent 536a722822
commit 515cfc951e
2 changed files with 12 additions and 7 deletions

View file

@ -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
}
}

View file

@ -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
}