Implement "Once" and "Never" special time values
This commit is contained in:
parent
16f8d1b30a
commit
aea2ef3da2
11 changed files with 108 additions and 12 deletions
|
@ -268,21 +268,39 @@ Page {
|
|||
id: highIntervalSlider
|
||||
width: parent.width
|
||||
label: qsTr("Battery high notification interval")
|
||||
minimumValue: 60
|
||||
maximumValue: 600
|
||||
minimumValue: 50
|
||||
maximumValue: 610
|
||||
stepSize: 10
|
||||
valueText: Math.floor(value / 60) + (value % 60 < 10 ? ":0" + value % 60 : ":" + value % 60)
|
||||
valueText: updateValueText()
|
||||
onReleased: settings.highNotificationsInterval = value
|
||||
onValueChanged: updateValueText()
|
||||
function updateValueText() {
|
||||
console.log("UpdateValueText()")
|
||||
if(value == 50)
|
||||
return qsTr("Once")
|
||||
if(value == 610)
|
||||
return qsTr("Never")
|
||||
return Math.floor(value / 60) + (value % 60 < 10 ? ":0" + value % 60 : ":" + value % 60)
|
||||
}
|
||||
}
|
||||
Slider {
|
||||
id: lowIntervalSlider
|
||||
width: parent.width
|
||||
label: qsTr("Battery low notification interval")
|
||||
minimumValue: 60
|
||||
maximumValue: 600
|
||||
minimumValue: 50
|
||||
maximumValue: 610
|
||||
stepSize: 10
|
||||
valueText: Math.floor(value / 60) + (value % 60 < 10 ? ":0" + value % 60 : ":" + value % 60)
|
||||
valueText: updateValueText()
|
||||
onValueChanged: updateValueText()
|
||||
onReleased: settings.lowNotificationsInterval = value
|
||||
function updateValueText() {
|
||||
console.log("UpdateValueText()")
|
||||
if(value == 50)
|
||||
return qsTr("Once")
|
||||
if(value == 610)
|
||||
return qsTr("Never")
|
||||
return Math.floor(value / 60) + (value % 60 < 10 ? ":0" + value % 60 : ":" + value % 60)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ Settings::Settings(QObject *parent) : QObject(parent)
|
|||
// Read in the values
|
||||
loadInteger(sLowAlert, &lowAlert, 10, 99);
|
||||
loadInteger(sHighAlert, &highAlert, 11, 100);
|
||||
loadInteger(sHighNotificationsInterval, &highNotificationsInterval, 60, 600);
|
||||
loadInteger(sLowNotificationsInterval, &lowNotificationsInterval, 60, 600);
|
||||
loadInteger(sHighNotificationsInterval, &highNotificationsInterval, 50, 610);
|
||||
loadInteger(sLowNotificationsInterval, &lowNotificationsInterval, 50, 610);
|
||||
loadInteger(sLimitEnabled, &limitEnabled, 0, 1);
|
||||
loadInteger(sHighNotificationsEnabled, &highNotificationsEnabled, 0, 1);
|
||||
loadInteger(sLowNotificationsEnabled, &lowNotificationsEnabled, 0, 1);
|
||||
|
|
|
@ -330,5 +330,13 @@
|
|||
<source>Battery low notification interval</source>
|
||||
<translation>Intervall für Hinweis "battery leer"</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Once</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Never</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -326,5 +326,13 @@
|
|||
<source>Battery low notification interval</source>
|
||||
<translation>Matalan varauksen ilmoituksen aikaväli</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Once</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Never</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -326,5 +326,13 @@
|
|||
<source>Battery low notification interval</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Once</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Never</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -326,5 +326,13 @@
|
|||
<source>Battery low notification interval</source>
|
||||
<translation>Interwał powiadamiania o niskim poziomie naładowania</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Once</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Never</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -326,5 +326,13 @@
|
|||
<source>Battery low notification interval</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Once</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Never</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -328,5 +328,13 @@
|
|||
<source>Battery low notification interval</source>
|
||||
<translation>电池电量低通知区间</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Once</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Never</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -326,5 +326,13 @@
|
|||
<source>Battery low notification interval</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Once</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Never</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -88,6 +88,8 @@ Battery::Battery(QObject *parent) : QObject(parent)
|
|||
connect(highNotifyTimer, SIGNAL(timeout()), this, SLOT(showHighNotification()));
|
||||
connect(lowNotifyTimer, SIGNAL(timeout()), this, SLOT(showLowNotification()));
|
||||
|
||||
updateData();
|
||||
resetTimers();
|
||||
updateTimer->start(5000);
|
||||
}
|
||||
|
||||
|
@ -144,8 +146,20 @@ void Battery::resetTimers() {
|
|||
lowNotifyTimer->stop();
|
||||
highNotifyTimer->setInterval(settings->getHighNotificationsInterval() * 1000);
|
||||
lowNotifyTimer->setInterval(settings->getLowNotificationsInterval() * 1000);
|
||||
highNotifyTimer->start();
|
||||
lowNotifyTimer->start();
|
||||
if(settings->getHighNotificationsInterval() < 610) {
|
||||
qDebug() << "Starting high level notification timer";
|
||||
highNotifyTimer->start();
|
||||
}
|
||||
else {
|
||||
qDebug() << "High level notification timer not started";
|
||||
}
|
||||
if(settings->getLowNotificationsInterval() < 610) {
|
||||
qDebug() << "Starting low level notification timer";
|
||||
lowNotifyTimer->start();
|
||||
}
|
||||
else {
|
||||
qDebug() << "Low level notification timer not started";
|
||||
}
|
||||
}
|
||||
|
||||
void Battery::showHighNotification() {
|
||||
|
@ -153,6 +167,10 @@ void Battery::showHighNotification() {
|
|||
&& !(charge == 100 && state == "idle")) {
|
||||
qDebug() << "Battery notification timer: full enough battery";
|
||||
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationHighText(), settings->getHighAlertFile());
|
||||
if(settings->getLowNotificationsInterval() == 50) {
|
||||
qDebug() << "Stop high notification timer (show only once)";
|
||||
highNotifyTimer->stop();
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "Battery notification timer: close notification";
|
||||
|
@ -164,6 +182,10 @@ void Battery::showLowNotification() {
|
|||
if(settings->getLowNotificationsEnabled() && charge <= settings->getLowAlert() && state != "charging") {
|
||||
qDebug() << "Battery notification timer: empty enough battery";
|
||||
notification->send(settings->getNotificationTitle().arg(charge), settings->getNotificationLowText(), settings->getLowAlertFile());
|
||||
if(settings->getLowNotificationsInterval() == 50) {
|
||||
qDebug() << "Stop low notification timer (show only once)";
|
||||
lowNotifyTimer->stop();
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "Battery notification timer: close notification";
|
||||
|
|
|
@ -96,8 +96,8 @@ void Settings::updateConfig(QString path) {
|
|||
|
||||
loadInteger(sLowAlert, &lowAlert, 10, 99);
|
||||
loadInteger(sHighAlert, &highAlert, 11, 100);
|
||||
restartTimers |= loadInteger(sHighNotificationsInterval, &highNotificationsInterval, 60, 600);
|
||||
restartTimers |= loadInteger(sLowNotificationsInterval, &lowNotificationsInterval, 60, 600);
|
||||
restartTimers |= loadInteger(sHighNotificationsInterval, &highNotificationsInterval, 50, 610);
|
||||
restartTimers |= loadInteger(sLowNotificationsInterval, &lowNotificationsInterval, 50, 610);
|
||||
loadInteger(sLimitEnabled, &limitEnabled, 0, 1);
|
||||
restartTimers |= loadInteger(sHighNotificationsEnabled, &highNotificationsEnabled, 0, 1);
|
||||
restartTimers |= loadInteger(sLowNotificationsEnabled, &lowNotificationsEnabled, 0, 1);
|
||||
|
|
Loading…
Reference in a new issue