Skip to content

Commit

Permalink
Show brief page single center gauge power with selected units
Browse files Browse the repository at this point in the history
The user can set a setting which determines whether to display
electrical quantities as current (amps) or power (watts).

This commit ensures that we respect the value of that setting
also for the quantity label shown in the single circular gauge
on the brief page.

Contributes to issue #1857
  • Loading branch information
chriadam committed Feb 5, 2025
1 parent e26018a commit bedf412
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions components/CircularSingleGauge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Item {
property alias icon: icon
property alias name: nameLabel.text
property alias voltage: voltageLabel.value
property alias current: currentLabel.value
property real current: NaN
property real power: NaN
property alias value: arc.value
property int status
property alias caption: captionLabel.text
Expand Down Expand Up @@ -101,10 +102,13 @@ Item {
QuantityLabel {
id: currentLabel

readonly property bool unitAmps: (Global.systemSettings.electricalQuantity === VenusOS.Units_Amp && !isNaN(gauges.current))
|| (!isNaN(gauges.current) && isNaN(gauges.power))
valueColor: Theme.color_briefPage_battery_value_text_color
unitColor: Theme.color_briefPage_battery_unit_text_color
font.pixelSize: Theme.font_briefPage_battery_voltage_pixelSize
unit: VenusOS.Units_Amp
value: currentLabel.unitAmps ? gauges.current : gauges.power
unit: currentLabel.unitAmps ? VenusOS.Units_Amp : VenusOS.Units_Watt
}
}

Expand Down
1 change: 1 addition & 0 deletions pages/BriefPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ SwipeViewPage {
value: visible && !isNaN(battery.stateOfCharge) ? battery.stateOfCharge : 0
voltage: battery.voltage
current: battery.current
power: battery.power
status: Theme.getValueStatus(value, properties.valueType)
caption: Utils.formatBatteryTimeToGo(battery.timeToGo, VenusOS.Battery_TimeToGo_LongFormat)
animationEnabled: root.animationEnabled
Expand Down

0 comments on commit bedf412

Please sign in to comment.