Skip to content

Commit 6a3ff68

Browse files
committed
fixing variables a bit
1 parent 354a69b commit 6a3ff68

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

modules/BatteryMonitor.qml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import QtMultimedia
99
Scope {
1010
id: root
1111

12-
readonly property list<var> lowWarnLevels: [...GlobalConfig.general.battery.lowBatteryWarnLevels].sort((a, b) => b.level - a.level)
13-
readonly property list<var> chargeWarnLevels: [...GlobalConfig.general.battery.chargingWarnLevels].sort((a, b) => a.level - b.level)
12+
readonly property list<var> lowBatteryWarningLevels: [...GlobalConfig.general.battery.lowBatteryWarnLevels].sort((a, b) => b.level - a.level)
13+
readonly property list<var> chargingBatteryWarningLevels: [...GlobalConfig.general.battery.chargingWarnLevels].sort((a, b) => a.level - b.level)
1414

1515
MediaPlayer {
1616
id: notifyLowBattery
@@ -23,12 +23,12 @@ Scope {
2323
if (UPower.onBattery) {
2424
if (GlobalConfig.utilities.toasts.chargingChanged)
2525
Toaster.toast(qsTr("Charger unplugged"), qsTr("Battery is discharging"), "power_off");
26-
for (const level of root.chargeWarnLevels)
26+
for (const level of root.chargingBatteryWarningLevels)
2727
level.warned = false;
2828
} else {
2929
if (GlobalConfig.utilities.toasts.chargingChanged)
3030
Toaster.toast(qsTr("Charger plugged in"), qsTr("Battery is charging"), "power");
31-
for (const level of root.lowWarnLevels)
31+
for (const level of root.lowBatteryWarningLevels)
3232
level.warned = false;
3333
}
3434
}
@@ -38,22 +38,19 @@ Scope {
3838

3939
Connections {
4040
function onPercentageChanged(): void {
41-
// if (!UPower.onBattery)
42-
// return;
43-
4441
const p = UPower.displayDevice.percentage * 100;
45-
// If charging check the chargeWarnLevels
42+
// If charging check the charging levels
4643
if (!UPower.onBattery){
47-
for (const level of root.chargeWarnLevels){
44+
for (const level of root.chargingBatteryWarningLevels){
4845
if (p >= level.level && !level.warned) {
4946
level.warned = true;
5047
Toaster.toast(level.title ?? qsTr("Charge warning"), level.message ?? qsTr("Battery level is high"), level.icon ?? 'battery_android_alert', level.critical ? Toast.Error : Toast.Warning);
5148
}
5249
}
5350
}
54-
// If discharging check the lowWarnLevels
51+
// If discharging check the low battery levels
5552
else {
56-
for (const level of root.lowWarnLevels) {
53+
for (const level of root.lowBatteryWarningLevels) {
5754
if (p <= level.level && !level.warned) {
5855
level.warned = true;
5956
Toaster.toast(level.title ?? qsTr("Battery warning"), level.message ?? qsTr("Battery level is low"), level.icon ?? "battery_android_alert", level.critical ? Toast.Error : Toast.Warning);

0 commit comments

Comments
 (0)