Fix timer logic once again...

This commit is contained in:
Matti Viljanen 2020-12-27 16:21:15 +02:00
parent a084c2d811
commit f582d55809

View file

@ -90,6 +90,14 @@ Battery::Battery(QObject *parent) : QObject(parent)
updateData(); updateData();
updateTimer->start(5000); updateTimer->start(5000);
// If updateData() didn't start the timers
// aka. "charging" status didn't change
// (or if both times are disabled, actually)
// manually trigger the timer startup.
if(!highNotifyTimer->isActive() && !lowNotifyTimer->isActive()) {
resetTimers();
}
} }
Battery::~Battery() { } Battery::~Battery() { }
@ -120,6 +128,9 @@ void Battery::updateData()
state = nextState; state = nextState;
emit stateChanged(state); emit stateChanged(state);
qDebug() << "Charging status:" << state; qDebug() << "Charging status:" << state;
// Hide/show notification right away
resetTimers();
} }
stateFile->close(); stateFile->close();
} }