[applets/batterymonitor] BatteryItem: Fix nullable property access

Amends [supposedly] e9d926f6659b1968d98453e985f891087936de5f
wilder-5.24
ivan tkachenko 4 years ago
parent c2688b74eb
commit 7d0f1a014c
No known key found for this signature in database
GPG Key ID: 4D197017E61437CF
  1. 8
      applets/batterymonitor/package/contents/ui/BatteryItem.qml

@ -34,7 +34,7 @@ RowLayout {
// State: "Discharging"|"Charging"|"FullyCharged"|etc.,
// Type: string,
// Vendor: string,
// }
// }?
property var battery
// NOTE: According to the UPower spec this property is only valid for primary batteries, however
@ -150,7 +150,8 @@ RowLayout {
wrapMode: Text.WordWrap
}
readonly property bool remainingTimeRowVisible: batterymonitor.remainingTime > 0
readonly property bool remainingTimeRowVisible: root.battery !== null
&& batterymonitor.remainingTime > 0
&& root.battery["Is Power Supply"]
&& ["Discharging", "Charging"].includes(root.battery.State)
@ -166,7 +167,8 @@ RowLayout {
visible: details.remainingTimeRowVisible
}
readonly property bool healthRowVisible: root.battery["Is Power Supply"]
readonly property bool healthRowVisible: root.battery !== null
&& root.battery["Is Power Supply"]
&& root.battery.Capacity !== ""
&& typeof root.battery.Capacity === "number"

Loading…
Cancel
Save