diff --git a/Modules/Bar/Widgets/Battery.qml b/Modules/Bar/Widgets/Battery.qml index 307316de6..1e2b4782b 100644 --- a/Modules/Bar/Widgets/Battery.qml +++ b/Modules/Bar/Widgets/Battery.qml @@ -58,7 +58,7 @@ Item { readonly property bool isPresent: testMode ? true : BatteryService.isDevicePresent(selectedDevice) readonly property bool isReady: testMode ? true : BatteryService.isDeviceReady(selectedDevice) - readonly property real percent: testMode ? testPercent : (isReady ? Math.round(BatteryService.getPercentage(selectedDevice)) : -1) + readonly property real percent: testMode ? testPercent : (isReady ? BatteryService.getPercentage(selectedDevice) : -1) readonly property bool isCharging: testMode ? testCharging : (isReady ? BatteryService.isCharging(selectedDevice) : false) readonly property bool isPluggedIn: testMode ? testPluggedIn : (isReady ? BatteryService.isPluggedIn(selectedDevice) : false) @@ -74,7 +74,7 @@ Item { if (isReady && (!charging && !pluggedIn) && !hasNotifiedLowBattery && currentPercent <= warningThreshold) { hasNotifiedLowBattery = true; ToastService.showWarning(I18n.tr("toast.battery.low"), I18n.tr("toast.battery.low-desc", { - "percent": Math.round(currentPercent) + "percent": currentPercent }), "battery-exclamation"); } else if (hasNotifiedLowBattery && (charging || pluggedIn || currentPercent > warningThreshold + 5)) { hasNotifiedLowBattery = false; @@ -121,7 +121,7 @@ Item { screen: root.screen oppositeDirection: BarService.getPillDirection(root) icon: testMode ? BatteryService.getIcon(testPercent, testCharging, testPluggedIn, true) : BatteryService.getIcon(percent, isCharging, isPluggedIn, isReady) - text: (isReady || testMode) ? Math.round(percent) : "-" + text: (isReady || testMode) ? percent : "-" suffix: "%" autoHide: false forceOpen: isReady && displayMode === "alwaysShow" @@ -153,7 +153,7 @@ Item { } else if (selectedDevice) { // External / Peripheral Device (Phone, Keyboard, Mouse, Gamepad, Headphone etc.) let name = BatteryService.getDeviceName(selectedDevice); - let pct = Math.round(percent); + let pct = percent; lines.push(name + ": " + pct + suffix); } @@ -166,7 +166,7 @@ Item { for (var j = 0; j < external.length; j++) { var dev = external[j]; var dName = BatteryService.getDeviceName(dev); - var dPct = Math.round(BatteryService.getPercentage(dev)); + var dPct = BatteryService.getPercentage(dev); lines.push(dName + ": " + dPct + suffix); } } diff --git a/Modules/Panels/Battery/BatteryPanel.qml b/Modules/Panels/Battery/BatteryPanel.qml index d50b41eb6..f6f8e838b 100644 --- a/Modules/Panels/Battery/BatteryPanel.qml +++ b/Modules/Panels/Battery/BatteryPanel.qml @@ -202,7 +202,7 @@ SmartPanel { NText { Layout.preferredWidth: 40 * Style.uiScaleRatio horizontalAlignment: Text.AlignRight - text: `${Math.round(BatteryService.getPercentage(modelData))}%` + text: `${BatteryService.getPercentage(modelData)}%` color: Color.mOnSurface pointSize: Style.fontSizeS font.weight: Style.fontWeightBold @@ -266,7 +266,7 @@ SmartPanel { NText { Layout.preferredWidth: 40 * Style.uiScaleRatio horizontalAlignment: Text.AlignRight - text: `${Math.round(BatteryService.getPercentage(modelData))}%` + text: `${BatteryService.getPercentage(modelData)}%` color: Color.mOnSurface pointSize: Style.fontSizeS font.weight: Style.fontWeightBold diff --git a/Services/Hardware/BatteryService.qml b/Services/Hardware/BatteryService.qml index caf2198e1..030b674d5 100644 --- a/Services/Hardware/BatteryService.qml +++ b/Services/Hardware/BatteryService.qml @@ -20,7 +20,7 @@ Singleton { readonly property bool batteryPluggedIn: isPluggedIn(primaryDevice) readonly property bool batteryReady: isDeviceReady(primaryDevice) readonly property bool batteryPresent: isDevicePresent(primaryDevice) - readonly property string batteryIcon: getIcon(Math.round(batteryPercentage), batteryCharging, batteryPluggedIn, batteryReady) + readonly property string batteryIcon: getIcon(batteryPercentage, batteryCharging, batteryPluggedIn, batteryReady) readonly property var laptopBatteries: UPower.devices.values.filter(d => d.isLaptopBattery) readonly property var bluetoothBatteries: { @@ -116,9 +116,9 @@ Singleton { return -1; } if (device.batteryAvailable !== undefined) { - return (device.battery || 0) * 100; + return Math.round((device.battery || 0) * 100); } - return (device.percentage || 0) * 100; + return Math.round((device.percentage || 0) * 100); } function isCharging(device) {