mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
make rounding in function not individually.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user