From 3292b53d49437213935d7cc2808f001a7fe85dee Mon Sep 17 00:00:00 2001 From: Anas Khalifa Date: Sun, 20 Jul 2025 12:03:52 +0300 Subject: [PATCH] Fix battery percentage calculation and make it not show if no battery i detected --- Bar/Modules/Battery.qml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Bar/Modules/Battery.qml b/Bar/Modules/Battery.qml index 49b3eb3..fe66910 100644 --- a/Bar/Modules/Battery.qml +++ b/Bar/Modules/Battery.qml @@ -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 @@ -78,4 +79,4 @@ Item { targetItem: batteryWidget delay: 200 } -} \ No newline at end of file +} \ No newline at end of file