Remove redundant high/low notification enabled
This commit is contained in:
parent
aea2ef3da2
commit
b94df34839
13 changed files with 22 additions and 118 deletions
|
@ -36,8 +36,6 @@ Page {
|
||||||
autoStopCharging.checked = settings.limitEnabled
|
autoStopCharging.checked = settings.limitEnabled
|
||||||
highLimitSlider.value = settings.highLimit
|
highLimitSlider.value = settings.highLimit
|
||||||
lowLimitSlider.value = settings.lowLimit
|
lowLimitSlider.value = settings.lowLimit
|
||||||
highNotificationsSwitch.checked = settings.highNotificationsEnabled
|
|
||||||
lowNotificationsSwitch.checked = settings.lowNotificationsEnabled
|
|
||||||
highAlertSlider.value = settings.highAlert
|
highAlertSlider.value = settings.highAlert
|
||||||
lowAlertSlider.value = settings.lowAlert
|
lowAlertSlider.value = settings.lowAlert
|
||||||
highIntervalSlider.value = settings.highNotificationsInterval
|
highIntervalSlider.value = settings.highNotificationsInterval
|
||||||
|
@ -220,16 +218,6 @@ Page {
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
}
|
}
|
||||||
|
|
||||||
TextSwitch {
|
|
||||||
id: highNotificationsSwitch
|
|
||||||
text: qsTr("Show high charge notification")
|
|
||||||
onCheckedChanged: settings.highNotificationsEnabled = checked
|
|
||||||
}
|
|
||||||
TextSwitch {
|
|
||||||
id: lowNotificationsSwitch
|
|
||||||
text: qsTr("Show low charge notification")
|
|
||||||
onCheckedChanged: settings.lowNotificationsEnabled = checked
|
|
||||||
}
|
|
||||||
Slider {
|
Slider {
|
||||||
id: highAlertSlider
|
id: highAlertSlider
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
|
@ -28,8 +28,6 @@ Settings::Settings(QObject *parent) : QObject(parent)
|
||||||
loadInteger(sHighNotificationsInterval, &highNotificationsInterval, 50, 610);
|
loadInteger(sHighNotificationsInterval, &highNotificationsInterval, 50, 610);
|
||||||
loadInteger(sLowNotificationsInterval, &lowNotificationsInterval, 50, 610);
|
loadInteger(sLowNotificationsInterval, &lowNotificationsInterval, 50, 610);
|
||||||
loadInteger(sLimitEnabled, &limitEnabled, 0, 1);
|
loadInteger(sLimitEnabled, &limitEnabled, 0, 1);
|
||||||
loadInteger(sHighNotificationsEnabled, &highNotificationsEnabled, 0, 1);
|
|
||||||
loadInteger(sLowNotificationsEnabled, &lowNotificationsEnabled, 0, 1);
|
|
||||||
loadInteger(sLowLimit, &lowLimit, 20, 94);
|
loadInteger(sLowLimit, &lowLimit, 20, 94);
|
||||||
loadInteger(sHighLimit, &highLimit, 21, 95);
|
loadInteger(sHighLimit, &highLimit, 21, 95);
|
||||||
|
|
||||||
|
@ -45,8 +43,6 @@ Settings::~Settings()
|
||||||
saveInteger(sHighNotificationsInterval, &highNotificationsInterval);
|
saveInteger(sHighNotificationsInterval, &highNotificationsInterval);
|
||||||
saveInteger(sLowNotificationsInterval, &lowNotificationsInterval);
|
saveInteger(sLowNotificationsInterval, &lowNotificationsInterval);
|
||||||
saveInteger(sLimitEnabled, &limitEnabled);
|
saveInteger(sLimitEnabled, &limitEnabled);
|
||||||
saveInteger(sHighNotificationsEnabled, &highNotificationsEnabled);
|
|
||||||
saveInteger(sLowNotificationsEnabled, &lowNotificationsEnabled);
|
|
||||||
saveInteger(sLowLimit, &lowLimit);
|
saveInteger(sLowLimit, &lowLimit);
|
||||||
saveInteger(sHighLimit, &highLimit);
|
saveInteger(sHighLimit, &highLimit);
|
||||||
mySettings->setValue(sNotificationTitle, notificationTitle);
|
mySettings->setValue(sNotificationTitle, notificationTitle);
|
||||||
|
@ -64,8 +60,6 @@ int Settings::getLowNotificationsInterval() { return lowNotificationsInterv
|
||||||
int Settings::getLowLimit() { return lowLimit; }
|
int Settings::getLowLimit() { return lowLimit; }
|
||||||
int Settings::getHighLimit() { return highLimit; }
|
int Settings::getHighLimit() { return highLimit; }
|
||||||
bool Settings::getLimitEnabled() { return limitEnabled == 1; }
|
bool Settings::getLimitEnabled() { return limitEnabled == 1; }
|
||||||
bool Settings::getHighNotificationsEnabled() { return highNotificationsEnabled == 1; }
|
|
||||||
bool Settings::getLowNotificationsEnabled() { return lowNotificationsEnabled == 1; }
|
|
||||||
QString Settings::getLowAlertFile() { return lowAlertFile; }
|
QString Settings::getLowAlertFile() { return lowAlertFile; }
|
||||||
QString Settings::getHighAlertFile() { return highAlertFile; }
|
QString Settings::getHighAlertFile() { return highAlertFile; }
|
||||||
QString Settings::getNotificationTitle() { return notificationTitle; }
|
QString Settings::getNotificationTitle() { return notificationTitle; }
|
||||||
|
@ -130,22 +124,6 @@ void Settings::setLimitEnabled(bool newEnabled) {
|
||||||
qDebug() << sLimitEnabled << newEnabled;
|
qDebug() << sLimitEnabled << newEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setHighNotificationsEnabled(bool newEnabled) {
|
|
||||||
highNotificationsEnabled = (newEnabled ? 1 : 0);
|
|
||||||
saveInteger(sHighNotificationsEnabled, &highNotificationsEnabled);
|
|
||||||
mySettings->sync();
|
|
||||||
emit highNotificationsEnabledChanged(highNotificationsEnabled);
|
|
||||||
qDebug() << sHighNotificationsEnabled << newEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Settings::setLowNotificationsEnabled(bool newEnabled) {
|
|
||||||
lowNotificationsEnabled = (newEnabled ? 1 : 0);
|
|
||||||
saveInteger(sLowNotificationsEnabled, &lowNotificationsEnabled);
|
|
||||||
mySettings->sync();
|
|
||||||
emit lowNotificationsEnabledChanged(lowNotificationsEnabled);
|
|
||||||
qDebug() << sLowNotificationsEnabled << newEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Settings::setNotificationTitle(QString newText) {
|
void Settings::setNotificationTitle(QString newText) {
|
||||||
notificationTitle = newText;
|
notificationTitle = newText;
|
||||||
mySettings->setValue(sNotificationTitle, notificationTitle);
|
mySettings->setValue(sNotificationTitle, notificationTitle);
|
||||||
|
|
|
@ -25,17 +25,15 @@
|
||||||
class Settings : public QObject
|
class Settings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int lowAlert READ getLowAlert WRITE setLowAlert NOTIFY lowAlertChanged)
|
|
||||||
Q_PROPERTY(int highAlert READ getHighAlert WRITE setHighAlert NOTIFY highAlertChanged)
|
Q_PROPERTY(int highAlert READ getHighAlert WRITE setHighAlert NOTIFY highAlertChanged)
|
||||||
|
Q_PROPERTY(int lowAlert READ getLowAlert WRITE setLowAlert NOTIFY lowAlertChanged)
|
||||||
Q_PROPERTY(int highNotificationsInterval READ getHighNotificationsInterval WRITE setHighNotificationsInterval NOTIFY highNotificationsIntervalChanged)
|
Q_PROPERTY(int highNotificationsInterval READ getHighNotificationsInterval WRITE setHighNotificationsInterval NOTIFY highNotificationsIntervalChanged)
|
||||||
Q_PROPERTY(int lowNotificationsInterval READ getLowNotificationsInterval WRITE setLowNotificationsInterval NOTIFY lowNotificationsIntervalChanged)
|
Q_PROPERTY(int lowNotificationsInterval READ getLowNotificationsInterval WRITE setLowNotificationsInterval NOTIFY lowNotificationsIntervalChanged)
|
||||||
Q_PROPERTY(int highLimit READ getHighLimit WRITE setHighLimit NOTIFY highLimitChanged)
|
Q_PROPERTY(int highLimit READ getHighLimit WRITE setHighLimit NOTIFY highLimitChanged)
|
||||||
Q_PROPERTY(int lowLimit READ getLowLimit WRITE setLowLimit NOTIFY lowLimitChanged)
|
Q_PROPERTY(int lowLimit READ getLowLimit WRITE setLowLimit NOTIFY lowLimitChanged)
|
||||||
Q_PROPERTY(bool limitEnabled READ getLimitEnabled WRITE setLimitEnabled NOTIFY limitEnabledChanged)
|
Q_PROPERTY(bool limitEnabled READ getLimitEnabled WRITE setLimitEnabled NOTIFY limitEnabledChanged)
|
||||||
Q_PROPERTY(bool highNotificationsEnabled READ getHighNotificationsEnabled WRITE setHighNotificationsEnabled NOTIFY highNotificationsEnabledChanged)
|
|
||||||
Q_PROPERTY(bool lowNotificationsEnabled READ getLowNotificationsEnabled WRITE setLowNotificationsEnabled NOTIFY lowNotificationsEnabledChanged)
|
|
||||||
Q_PROPERTY(QString lowAlertFile READ getLowAlertFile NOTIFY lowAlertFileChanged)
|
|
||||||
Q_PROPERTY(QString highAlertFile READ getHighAlertFile NOTIFY highAlertFileChanged)
|
Q_PROPERTY(QString highAlertFile READ getHighAlertFile NOTIFY highAlertFileChanged)
|
||||||
|
Q_PROPERTY(QString lowAlertFile READ getLowAlertFile NOTIFY lowAlertFileChanged)
|
||||||
Q_PROPERTY(QString notificationTitle READ getNotificationTitle WRITE setNotificationTitle NOTIFY notificationTitleChanged)
|
Q_PROPERTY(QString notificationTitle READ getNotificationTitle WRITE setNotificationTitle NOTIFY notificationTitleChanged)
|
||||||
Q_PROPERTY(QString notificationLowText READ getNotificationLowText WRITE setNotificationLowText NOTIFY notificationLowTextChanged)
|
Q_PROPERTY(QString notificationLowText READ getNotificationLowText WRITE setNotificationLowText NOTIFY notificationLowTextChanged)
|
||||||
Q_PROPERTY(QString notificationHighText READ getNotificationHighText WRITE setNotificationHighText NOTIFY notificationHighTextChanged)
|
Q_PROPERTY(QString notificationHighText READ getNotificationHighText WRITE setNotificationHighText NOTIFY notificationHighTextChanged)
|
||||||
|
@ -51,8 +49,6 @@ public:
|
||||||
int getLowLimit();
|
int getLowLimit();
|
||||||
int getHighLimit();
|
int getHighLimit();
|
||||||
bool getLimitEnabled();
|
bool getLimitEnabled();
|
||||||
bool getHighNotificationsEnabled();
|
|
||||||
bool getLowNotificationsEnabled();
|
|
||||||
QString getLowAlertFile();
|
QString getLowAlertFile();
|
||||||
QString getHighAlertFile();
|
QString getHighAlertFile();
|
||||||
QString getNotificationTitle();
|
QString getNotificationTitle();
|
||||||
|
@ -66,8 +62,6 @@ public:
|
||||||
void setLowLimit(int newLimit);
|
void setLowLimit(int newLimit);
|
||||||
void setHighLimit(int newLimit);
|
void setHighLimit(int newLimit);
|
||||||
void setLimitEnabled(bool newEnabled);
|
void setLimitEnabled(bool newEnabled);
|
||||||
void setHighNotificationsEnabled(bool newEnabled);
|
|
||||||
void setLowNotificationsEnabled(bool newEnabled);
|
|
||||||
void setNotificationTitle(QString newText);
|
void setNotificationTitle(QString newText);
|
||||||
void setNotificationLowText(QString newText);
|
void setNotificationLowText(QString newText);
|
||||||
void setNotificationHighText(QString newText);
|
void setNotificationHighText(QString newText);
|
||||||
|
@ -81,8 +75,6 @@ private:
|
||||||
int highNotificationsInterval = 60;
|
int highNotificationsInterval = 60;
|
||||||
int lowNotificationsInterval = 60;
|
int lowNotificationsInterval = 60;
|
||||||
int limitEnabled = 0; // Converted to boolean for QML
|
int limitEnabled = 0; // Converted to boolean for QML
|
||||||
int highNotificationsEnabled = 1; // Converted to boolean for QML
|
|
||||||
int lowNotificationsEnabled = 1; // Converted to boolean for QML
|
|
||||||
int lowLimit = 65;
|
int lowLimit = 65;
|
||||||
int highLimit = 70;
|
int highLimit = 70;
|
||||||
QString lowAlertFile = "/usr/share/sounds/jolla-ambient/stereo/general_warning.wav";
|
QString lowAlertFile = "/usr/share/sounds/jolla-ambient/stereo/general_warning.wav";
|
||||||
|
@ -97,8 +89,6 @@ private:
|
||||||
const char* sHighNotificationsInterval = "highNotificationsInterval";
|
const char* sHighNotificationsInterval = "highNotificationsInterval";
|
||||||
const char* sLowNotificationsInterval = "lowNotificationsInterval";
|
const char* sLowNotificationsInterval = "lowNotificationsInterval";
|
||||||
const char* sLimitEnabled = "limitEnabled";
|
const char* sLimitEnabled = "limitEnabled";
|
||||||
const char* sHighNotificationsEnabled = "highNotificationsEnabled";
|
|
||||||
const char* sLowNotificationsEnabled = "lowNotificationsEnabled";
|
|
||||||
const char* sLowLimit = "lowLimit";
|
const char* sLowLimit = "lowLimit";
|
||||||
const char* sHighLimit = "highLimit";
|
const char* sHighLimit = "highLimit";
|
||||||
const char* sLowAlertFile = "lowAlertFile";
|
const char* sLowAlertFile = "lowAlertFile";
|
||||||
|
@ -117,8 +107,6 @@ signals:
|
||||||
void highNotificationsIntervalChanged(int);
|
void highNotificationsIntervalChanged(int);
|
||||||
void lowNotificationsIntervalChanged(int);
|
void lowNotificationsIntervalChanged(int);
|
||||||
void limitEnabledChanged(bool);
|
void limitEnabledChanged(bool);
|
||||||
void highNotificationsEnabledChanged(bool);
|
|
||||||
void lowNotificationsEnabledChanged(bool);
|
|
||||||
void lowLimitChanged(int);
|
void lowLimitChanged(int);
|
||||||
void highLimitChanged(int);
|
void highLimitChanged(int);
|
||||||
void lowAlertFileChanged(QString);
|
void lowAlertFileChanged(QString);
|
||||||
|
|
|
@ -314,14 +314,6 @@
|
||||||
<source>Start background service at startup</source>
|
<source>Start background service at startup</source>
|
||||||
<translation>Starte den Hintergrunddienst beim Einschalten</translation>
|
<translation>Starte den Hintergrunddienst beim Einschalten</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Show high charge notification</source>
|
|
||||||
<translation>Zeige Hinweis, wenn der Akku voll ist</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Show low charge notification</source>
|
|
||||||
<translation>Zeige Hinweis, wenn der Akku leer ist</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Battery high notification interval</source>
|
<source>Battery high notification interval</source>
|
||||||
<translation>Intervall für Hinweis "battery voll"</translation>
|
<translation>Intervall für Hinweis "battery voll"</translation>
|
||||||
|
|
|
@ -310,14 +310,6 @@
|
||||||
<source>Start background service at startup</source>
|
<source>Start background service at startup</source>
|
||||||
<translation>Käynnistä taustapalvelu kun puhelin käynnistyy</translation>
|
<translation>Käynnistä taustapalvelu kun puhelin käynnistyy</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Show high charge notification</source>
|
|
||||||
<translation>Näytä korkean varauksen ilmoitukset</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Show low charge notification</source>
|
|
||||||
<translation>Näytä matalan varauksen ilmoitukset</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Battery high notification interval</source>
|
<source>Battery high notification interval</source>
|
||||||
<translation>Korkean varauksen ilmoituksen aikaväli</translation>
|
<translation>Korkean varauksen ilmoituksen aikaväli</translation>
|
||||||
|
|
|
@ -310,14 +310,6 @@
|
||||||
<source>Start background service at startup</source>
|
<source>Start background service at startup</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Show high charge notification</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Show low charge notification</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Battery high notification interval</source>
|
<source>Battery high notification interval</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
|
|
|
@ -310,14 +310,6 @@
|
||||||
<source>Start background service at startup</source>
|
<source>Start background service at startup</source>
|
||||||
<translation>Uruchom proces w tle podczas uruchomienia</translation>
|
<translation>Uruchom proces w tle podczas uruchomienia</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Show high charge notification</source>
|
|
||||||
<translation>Pokaż powiadomienie o wysokim poziomie naładowania</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Show low charge notification</source>
|
|
||||||
<translation>Pokaż powiadomienie o niskim poziomie naładowania</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Battery high notification interval</source>
|
<source>Battery high notification interval</source>
|
||||||
<translation>Interwał powiadamiania o wysokim poziomie naładowania</translation>
|
<translation>Interwał powiadamiania o wysokim poziomie naładowania</translation>
|
||||||
|
|
|
@ -310,14 +310,6 @@
|
||||||
<source>Start background service at startup</source>
|
<source>Start background service at startup</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Show high charge notification</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Show low charge notification</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Battery high notification interval</source>
|
<source>Battery high notification interval</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
|
|
|
@ -312,14 +312,6 @@
|
||||||
<source>Start background service at startup</source>
|
<source>Start background service at startup</source>
|
||||||
<translation>启动时开始后台服务</translation>
|
<translation>启动时开始后台服务</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Show high charge notification</source>
|
|
||||||
<translation>显示高充电通知</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Show low charge notification</source>
|
|
||||||
<translation>显示低电量通知</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Battery high notification interval</source>
|
<source>Battery high notification interval</source>
|
||||||
<translation>电池电量高通知区间</translation>
|
<translation>电池电量高通知区间</translation>
|
||||||
|
|
|
@ -310,14 +310,6 @@
|
||||||
<source>Start background service at startup</source>
|
<source>Start background service at startup</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Show high charge notification</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Show low charge notification</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Battery high notification interval</source>
|
<source>Battery high notification interval</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
|
|
|
@ -163,7 +163,7 @@ void Battery::resetTimers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battery::showHighNotification() {
|
void Battery::showHighNotification() {
|
||||||
if(settings->getHighNotificationsEnabled() && (charge >= settings->getHighAlert() && state != "discharging")
|
if(settings->getHighNotificationsInterval() < 610 && (charge >= settings->getHighAlert() && state != "discharging")
|
||||||
&& !(charge == 100 && state == "idle")) {
|
&& !(charge == 100 && state == "idle")) {
|
||||||
qDebug() << "Battery notification timer: full enough battery";
|
qDebug() << "Battery notification timer: full enough battery";
|
||||||
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationHighText(), settings->getHighAlertFile());
|
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationHighText(), settings->getHighAlertFile());
|
||||||
|
@ -179,7 +179,7 @@ void Battery::showHighNotification() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battery::showLowNotification() {
|
void Battery::showLowNotification() {
|
||||||
if(settings->getLowNotificationsEnabled() && charge <= settings->getLowAlert() && state != "charging") {
|
if(settings->getLowNotificationsInterval() < 610 && charge <= settings->getLowAlert() && state != "charging") {
|
||||||
qDebug() << "Battery notification timer: empty enough battery";
|
qDebug() << "Battery notification timer: empty enough battery";
|
||||||
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationLowText(), settings->getLowAlertFile());
|
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationLowText(), settings->getLowAlertFile());
|
||||||
if(settings->getLowNotificationsInterval() == 50) {
|
if(settings->getLowNotificationsInterval() == 50) {
|
||||||
|
@ -194,12 +194,12 @@ void Battery::showLowNotification() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battery::updateNotification() {
|
void Battery::updateNotification() {
|
||||||
if(settings->getHighNotificationsEnabled() && (charge >= settings->getHighAlert() && state != "discharging")
|
if(settings->getHighNotificationsInterval() < 610 && (charge >= settings->getHighAlert() && state != "discharging")
|
||||||
&& !(charge == 100 && state == "idle")) {
|
&& !(charge == 100 && state == "idle")) {
|
||||||
qDebug() << "Battery notification timer: full enough battery";
|
qDebug() << "Battery notification timer: full enough battery";
|
||||||
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationHighText(), settings->getHighAlertFile());
|
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationHighText(), settings->getHighAlertFile());
|
||||||
}
|
}
|
||||||
else if(settings->getLowNotificationsEnabled() && charge <= settings->getLowAlert() && state != "charging") {
|
else if(settings->getLowNotificationsInterval() < 610 && charge <= settings->getLowAlert() && state != "charging") {
|
||||||
qDebug() << "Battery notification timer: empty enough battery";
|
qDebug() << "Battery notification timer: empty enough battery";
|
||||||
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationLowText(), settings->getLowAlertFile());
|
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationLowText(), settings->getLowAlertFile());
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ Settings::Settings(QObject *parent) : QObject(parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mySettings->contains("notificationsEnabled")) {
|
if(mySettings->contains("notificationsEnabled")) {
|
||||||
mySettings->setValue(sHighNotificationsEnabled, mySettings->value("notificationsEnabled"));
|
mySettings->setValue("highNotificationsEnabled", mySettings->value("notificationsEnabled"));
|
||||||
mySettings->remove("notificationsEnabled");
|
mySettings->remove("notificationsEnabled");
|
||||||
qInfo() << "Migrated old upperLimit value";
|
qInfo() << "Migrated old notificationsEnabled value";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mySettings->contains("interval")) {
|
if(mySettings->contains("interval")) {
|
||||||
|
@ -52,6 +52,20 @@ Settings::Settings(QObject *parent) : QObject(parent)
|
||||||
qInfo() << "Migrated old notification interval value";
|
qInfo() << "Migrated old notification interval value";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mySettings->contains("highNotificationsEnabled")) {
|
||||||
|
if(mySettings->value("highNotificationsEnabled").toInt() == 0)
|
||||||
|
mySettings->setValue(sHighNotificationsInterval, 610);
|
||||||
|
mySettings->remove("highNotificationsEnabled");
|
||||||
|
qInfo() << "Migrated old highNotificationsEnabled value";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mySettings->contains("lowNotificationsEnabled")) {
|
||||||
|
if(mySettings->value("lowNotificationsEnabled").toInt() == 0)
|
||||||
|
mySettings->setValue(sLowNotificationsInterval, 610);
|
||||||
|
mySettings->remove("lowNotificationsEnabled");
|
||||||
|
qInfo() << "Migrated old lowNotificationsEnabled value";
|
||||||
|
}
|
||||||
|
|
||||||
// Do this here, because...
|
// Do this here, because...
|
||||||
watcher = new QFileSystemWatcher(QStringList(mySettings->fileName()));
|
watcher = new QFileSystemWatcher(QStringList(mySettings->fileName()));
|
||||||
connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateConfig(QString)));
|
connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateConfig(QString)));
|
||||||
|
@ -99,8 +113,6 @@ void Settings::updateConfig(QString path) {
|
||||||
restartTimers |= loadInteger(sHighNotificationsInterval, &highNotificationsInterval, 50, 610);
|
restartTimers |= loadInteger(sHighNotificationsInterval, &highNotificationsInterval, 50, 610);
|
||||||
restartTimers |= loadInteger(sLowNotificationsInterval, &lowNotificationsInterval, 50, 610);
|
restartTimers |= loadInteger(sLowNotificationsInterval, &lowNotificationsInterval, 50, 610);
|
||||||
loadInteger(sLimitEnabled, &limitEnabled, 0, 1);
|
loadInteger(sLimitEnabled, &limitEnabled, 0, 1);
|
||||||
restartTimers |= loadInteger(sHighNotificationsEnabled, &highNotificationsEnabled, 0, 1);
|
|
||||||
restartTimers |= loadInteger(sLowNotificationsEnabled, &lowNotificationsEnabled, 0, 1);
|
|
||||||
loadInteger(sLowLimit, &lowLimit, 20, 94);
|
loadInteger(sLowLimit, &lowLimit, 20, 94);
|
||||||
loadInteger(sHighLimit, &highLimit, 21, 95);
|
loadInteger(sHighLimit, &highLimit, 21, 95);
|
||||||
|
|
||||||
|
@ -139,8 +151,6 @@ int Settings::getLowNotificationsInterval() { return lowNotificationsInterv
|
||||||
int Settings::getLowLimit() { return lowLimit; }
|
int Settings::getLowLimit() { return lowLimit; }
|
||||||
int Settings::getHighLimit() { return highLimit; }
|
int Settings::getHighLimit() { return highLimit; }
|
||||||
bool Settings::getLimitEnabled() { return limitEnabled == 1; }
|
bool Settings::getLimitEnabled() { return limitEnabled == 1; }
|
||||||
bool Settings::getHighNotificationsEnabled() { return highNotificationsEnabled == 1; }
|
|
||||||
bool Settings::getLowNotificationsEnabled() { return lowNotificationsEnabled == 1; }
|
|
||||||
QString Settings::getLowAlertFile() { return lowAlertFile; }
|
QString Settings::getLowAlertFile() { return lowAlertFile; }
|
||||||
QString Settings::getHighAlertFile() { return highAlertFile; }
|
QString Settings::getHighAlertFile() { return highAlertFile; }
|
||||||
QString Settings::getNotificationTitle() { return notificationTitle; }
|
QString Settings::getNotificationTitle() { return notificationTitle; }
|
||||||
|
|
|
@ -61,8 +61,6 @@ private:
|
||||||
|
|
||||||
// Converted to boolean for QML
|
// Converted to boolean for QML
|
||||||
int limitEnabled = 0;
|
int limitEnabled = 0;
|
||||||
int highNotificationsEnabled = 1; // Converted to boolean for QML
|
|
||||||
int lowNotificationsEnabled = 1; // Converted to boolean for QML
|
|
||||||
int daemonEnabled = 1;
|
int daemonEnabled = 1;
|
||||||
|
|
||||||
int lowLimit = 65;
|
int lowLimit = 65;
|
||||||
|
@ -79,8 +77,6 @@ private:
|
||||||
const char* sHighNotificationsInterval = "highNotificationsInterval";
|
const char* sHighNotificationsInterval = "highNotificationsInterval";
|
||||||
const char* sLowNotificationsInterval = "lowNotificationsInterval";
|
const char* sLowNotificationsInterval = "lowNotificationsInterval";
|
||||||
const char* sLimitEnabled = "limitEnabled";
|
const char* sLimitEnabled = "limitEnabled";
|
||||||
const char* sHighNotificationsEnabled = "highNotificationsEnabled";
|
|
||||||
const char* sLowNotificationsEnabled = "lowNotificationsEnabled";
|
|
||||||
const char* sLowLimit = "lowLimit";
|
const char* sLowLimit = "lowLimit";
|
||||||
const char* sHighLimit = "highLimit";
|
const char* sHighLimit = "highLimit";
|
||||||
const char* sLowAlertFile = "lowAlertFile";
|
const char* sLowAlertFile = "lowAlertFile";
|
||||||
|
|
Loading…
Reference in a new issue