Fix battery percentage calculation and make it not show if no battery i detected
This commit is contained in:
parent
a8244cde67
commit
3292b53d49
1 changed files with 4 additions and 3 deletions
|
|
@ -6,9 +6,10 @@ import qs.Components
|
|||
|
||||
Item {
|
||||
id: batteryWidget
|
||||
|
||||
property var battery: UPower.displayDevice
|
||||
property bool isReady: battery && battery.ready && battery.isLaptopBattery && battery.isPresent
|
||||
property real percent: isReady ? battery.percentage : 0
|
||||
property real percent: isReady ? (battery.percentage * 100) : 0
|
||||
property bool charging: isReady ? battery.state === UPowerDeviceState.Charging : false
|
||||
property bool show: isReady && percent > 0
|
||||
|
||||
|
|
@ -24,7 +25,7 @@ Item {
|
|||
return "battery_alert";
|
||||
}
|
||||
|
||||
visible: show
|
||||
visible: isReady && battery.isLaptopBattery
|
||||
width: 22
|
||||
height: 36
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue