Skip to content

Commit

Permalink
Show battery SoC inside circular multi gauge on Brief Page
Browse files Browse the repository at this point in the history
Contributes to issue #1491
  • Loading branch information
chriadam committed Dec 6, 2024
1 parent eafd2eb commit a7a4b1e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
41 changes: 41 additions & 0 deletions components/CircularMultiGauge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,45 @@ Item {
}
}
}

Item {
id: centerLabelColumn
anchors.centerIn: parent
width: Math.max(centerLabelIcon.width + centerLabel.width, centerQuantity.width)
height: centerLabelIcon.height + centerQuantity.height
visible: arcRepeater.count <= 3 && !isNaN(Global.batteries.system.stateOfCharge)

CP.ColorImage {
id: centerLabelIcon
anchors.right: centerLabel.left
color: Theme.color_font_primary
source: Global.batteries.system.icon
}
Label {
id: centerLabel
anchors {
// usually, center the label over the quantity, except when the quantity only has 1 digit - then take icon width into account.
horizontalCenterOffset: centerQuantity.valueText.length <= 1 ? centerLabelIcon.width/2 : 0
horizontalCenter: centerQuantity.horizontalCenter
verticalCenter: centerLabelIcon.verticalCenter
}
font.pixelSize: Theme.font_size_body2
color: Theme.color_font_primary
text: CommonWords.battery
width: Math.min(implicitWidth, centerQuantity.width)
elide: Text.ElideRight
}
QuantityLabel {
id: centerQuantity
anchors {
top: centerLabelIcon.bottom
horizontalCenter: parent.horizontalCenter
}
font.pixelSize: arcRepeater.count <= 2 ? Theme.font_briefPage_battery_percentage_pixelSize + 4 // larger font size if we have more space.
: valueText.length < 3 ? Theme.font_briefPage_battery_percentage_pixelSize // default font size.
: Theme.font_briefPage_battery_percentage_pixelSize - 8 // 5-inch "100%" fits with this font size with 3 gauges.
unit: VenusOS.Units_Percentage
value: Global.batteries.system.stateOfCharge
}
}
}
5 changes: 5 additions & 0 deletions data/mock/config/LevelsPageConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ QtObject {
{ type: VenusOS.Tank_Type_FreshWater, level: 75, capacity: 20 },
]
},
{
name: "No tanks",
tanks: [
]
},
]

property var environmentConfigs: [
Expand Down

0 comments on commit a7a4b1e

Please sign in to comment.