Fix broken battery notification timer

This commit is contained in:
Matti Viljanen 2020-03-28 10:13:00 +02:00
parent 01e06c8192
commit 49b197ff60
No known key found for this signature in database
GPG key ID: CF32A1495158F888
2 changed files with 14 additions and 9 deletions

View file

@ -63,17 +63,28 @@ ApplicationWindow
interval: settings.interval * 1000
running: settings.notificationsEnabled
repeat: true
triggeredOnStart: true
onTriggered: {
if(battery.charge <= settings.lowerLimit && battery.state === "discharging") {
if(settings.notificationsEnabled && battery.charge <= settings.lowAlert && battery.state === "discharging") {
console.info("Battery notification timer: empty enough battery")
alertLow.play()
notification.republish()
}
else if(battery.charge >= settings.upperLimit &&
(battery.state === "charging" && battery.charging === true) || (battery.state === "idle" && battery.charging === false)) {
else if((battery.charge >= settings.highAlert && battery.state === "charging")
|| (battery.charge === 100 && battery.state === "idle")) {
console.info("Battery notification timer: full enough battery")
alertHigh.play()
notification.republish()
}
else if(notification.replacesId > 0) {
console.info("Battery notification timer: close notification")
notification.close()
}
}
onRunningChanged: {
console.debug("alertTimer is " + (running ? "" : "not ") + "running")
if(notification.replacesId > 0) {
console.info("Battery notification timer: close notification")
notification.close()
}
}

View file

@ -23,12 +23,6 @@ Page {
id: settingsPage
allowedOrientations: Orientation.Portrait | Orientation.Landscape | Orientation.LandscapeInverted
onStatusChanged: {
if(status === PageStatus.Activating) {
settingsTimer.start()
}
}
Timer {
id: settingsTimer
interval: 10