Use separate notification for health/status
This commit is contained in:
parent
da7499641a
commit
645d919457
2 changed files with 11 additions and 9 deletions
|
@ -34,7 +34,8 @@ Battery::Battery(Logger* newLogger, bool loglevelSet, QObject *parent) : QObject
|
||||||
highNotifyTimer = new QTimer(this);
|
highNotifyTimer = new QTimer(this);
|
||||||
lowNotifyTimer = new QTimer(this);
|
lowNotifyTimer = new QTimer(this);
|
||||||
healthNotifyTimer = new QTimer(this);
|
healthNotifyTimer = new QTimer(this);
|
||||||
notification = new MyNotification(this);
|
chargeNotification = new MyNotification(this);
|
||||||
|
healthNotification = new MyNotification(this);
|
||||||
|
|
||||||
// Number: charge percentage, e.g. 42
|
// Number: charge percentage, e.g. 42
|
||||||
chargeFile = new QFile("/sys/class/power_supply/battery/capacity", this);
|
chargeFile = new QFile("/sys/class/power_supply/battery/capacity", this);
|
||||||
|
@ -229,7 +230,7 @@ void Battery::showHighNotification() {
|
||||||
if(settings->getHighNotificationsInterval() < 610 && (charge >= settings->getHighAlert() && state != "discharging")
|
if(settings->getHighNotificationsInterval() < 610 && (charge >= settings->getHighAlert() && state != "discharging")
|
||||||
&& !(charge == 100 && state == "idle")) {
|
&& !(charge == 100 && state == "idle")) {
|
||||||
logV(QString("Notification: %1").arg(settings->getNotificationTitle().arg(charge)));
|
logV(QString("Notification: %1").arg(settings->getNotificationTitle().arg(charge)));
|
||||||
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationHighText(), settings->getHighAlertFile());
|
chargeNotification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationHighText(), settings->getHighAlertFile());
|
||||||
if(settings->getHighNotificationsInterval() == 50) {
|
if(settings->getHighNotificationsInterval() == 50) {
|
||||||
logD("Stop high battery timer");
|
logD("Stop high battery timer");
|
||||||
highNotifyTimer->stop();
|
highNotifyTimer->stop();
|
||||||
|
@ -237,14 +238,14 @@ void Battery::showHighNotification() {
|
||||||
}
|
}
|
||||||
else if(charge > settings->getLowAlert()) {
|
else if(charge > settings->getLowAlert()) {
|
||||||
logD("Close high battery notification");
|
logD("Close high battery notification");
|
||||||
notification->close();
|
chargeNotification->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battery::showLowNotification() {
|
void Battery::showLowNotification() {
|
||||||
if(settings->getLowNotificationsInterval() < 610 && charge <= settings->getLowAlert() && state != "charging") {
|
if(settings->getLowNotificationsInterval() < 610 && charge <= settings->getLowAlert() && state != "charging") {
|
||||||
logV(QString("Notification: %1").arg(settings->getNotificationTitle().arg(charge)));
|
logV(QString("Notification: %1").arg(settings->getNotificationTitle().arg(charge)));
|
||||||
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationLowText(), settings->getLowAlertFile());
|
chargeNotification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationLowText(), settings->getLowAlertFile());
|
||||||
if(settings->getLowNotificationsInterval() == 50) {
|
if(settings->getLowNotificationsInterval() == 50) {
|
||||||
logD("Stop low battery timer");
|
logD("Stop low battery timer");
|
||||||
lowNotifyTimer->stop();
|
lowNotifyTimer->stop();
|
||||||
|
@ -252,7 +253,7 @@ void Battery::showLowNotification() {
|
||||||
}
|
}
|
||||||
else if(charge < settings->getHighAlert()) {
|
else if(charge < settings->getHighAlert()) {
|
||||||
logD("Close low battery notification");
|
logD("Close low battery notification");
|
||||||
notification->close();
|
chargeNotification->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +290,7 @@ void Battery::showHealthNotification() {
|
||||||
notificationText = settings->getNotificationHealthCritText();
|
notificationText = settings->getNotificationHealthCritText();
|
||||||
}
|
}
|
||||||
logD(QString("Notification: %1").arg(settings->getNotificationHealthTitle().arg(titleArgs)));
|
logD(QString("Notification: %1").arg(settings->getNotificationHealthTitle().arg(titleArgs)));
|
||||||
notification->send(settings->getNotificationHealthTitle().arg(titleArgs), notificationText, settings->getHealthAlertFile());
|
healthNotification->send(settings->getNotificationHealthTitle().arg(titleArgs), notificationText, settings->getHealthAlertFile());
|
||||||
if(settings->getHealthNotificationsInterval() == 50) {
|
if(settings->getHealthNotificationsInterval() == 50) {
|
||||||
logD("Stop health timer");
|
logD("Stop health timer");
|
||||||
healthNotifyTimer->stop();
|
healthNotifyTimer->stop();
|
||||||
|
@ -297,7 +298,7 @@ void Battery::showHealthNotification() {
|
||||||
}
|
}
|
||||||
else if(HealthState[health] == HealthThresh["ok"] || HealthState[health] < settings->getHealthAlert()) {
|
else if(HealthState[health] == HealthThresh["ok"] || HealthState[health] < settings->getHealthAlert()) {
|
||||||
logD("Close health notification");
|
logD("Close health notification");
|
||||||
notification->close();
|
healthNotification->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +346,7 @@ bool Battery::getChargerConnected() {
|
||||||
|
|
||||||
void Battery::shutdown() {
|
void Battery::shutdown() {
|
||||||
logV("Shutting down...");
|
logV("Shutting down...");
|
||||||
notification->close();
|
chargeNotification->close();
|
||||||
blockSignals(true);
|
blockSignals(true);
|
||||||
if(updateTimer) {
|
if(updateTimer) {
|
||||||
updateTimer->stop();
|
updateTimer->stop();
|
||||||
|
|
|
@ -65,7 +65,8 @@ private:
|
||||||
QTimer *highNotifyTimer = nullptr;
|
QTimer *highNotifyTimer = nullptr;
|
||||||
QTimer *lowNotifyTimer = nullptr;
|
QTimer *lowNotifyTimer = nullptr;
|
||||||
QTimer *healthNotifyTimer = nullptr;
|
QTimer *healthNotifyTimer = nullptr;
|
||||||
MyNotification *notification = nullptr;
|
MyNotification *chargeNotification = nullptr;
|
||||||
|
MyNotification *healthNotification = nullptr;
|
||||||
|
|
||||||
|
|
||||||
// Default values:
|
// Default values:
|
||||||
|
|
Loading…
Reference in a new issue