Save settings after releasing the sliders

This commit is contained in:
Matti Viljanen 2020-04-26 18:23:35 +03:00
parent c0e8004cc2
commit a5d8ae0fa3
No known key found for this signature in database
GPG key ID: CF32A1495158F888
2 changed files with 21 additions and 7 deletions

View file

@ -103,10 +103,13 @@ Page {
valueText: value + "%"
highlightDirection: Qt.RightToLeft
onValueChanged: {
settings.highLimit = value
if(lowLimitSlider.value >= value)
lowLimitSlider.value = value - 1
}
onReleased: {
settings.lowLimit = lowLimitSlider.value
settings.highLimit = value
}
}
MySlider {
id: lowLimitSlider
@ -118,10 +121,13 @@ Page {
stepSize: 1
valueText: value + "%"
onValueChanged: {
settings.lowLimit = value
if(highLimitSlider.value <= value)
highLimitSlider.value = value + 1
}
onReleased: {
settings.lowLimit = value
settings.highLimit = highLimitSlider.value
}
}
}
Column {
@ -149,10 +155,13 @@ Page {
valueText: value + "%"
highlightDirection: Qt.RightToLeft
onValueChanged: {
settings.highAlert = value
if(lowAlertSlider.value >= value)
lowAlertSlider.value = value - 1
}
onReleased: {
settings.lowAlert = lowAlertSlider.value
settings.highAlert = value
}
}
MySlider {
id: lowAlertSlider
@ -163,10 +172,13 @@ Page {
stepSize: 1
valueText: value + "%"
onValueChanged: {
settings.lowAlert = value
if(highAlertSlider.value <= value)
highAlertSlider.value = value + 1
}
onReleased: {
settings.lowAlert = value
settings.highAlert = highAlertSlider.value
}
}
MySlider {
id: intervalSlider
@ -176,7 +188,7 @@ Page {
maximumValue: 600
stepSize: 10
valueText: Math.floor(value / 60) + (value % 60 < 10 ? ":0" + value % 60 : ":" + value % 60)
onValueChanged: settings.interval = value
onReleased: settings.interval = value
}
}
}

View file

@ -82,7 +82,8 @@ QString Settings::getNotificationHighText() { return notificationHighText; }
void Settings::setLowAlert(int newLimit) {
lowAlert = newLimit;
saveInteger(sLowAlert, &lowAlert);
mySettings->sync();
// Lows and highs are always saved in pairs!
//mySettings->sync();
emit lowAlertChanged(lowAlert);
qDebug() << "Change" << sLowAlert << newLimit;
}
@ -106,7 +107,8 @@ void Settings::setInterval(int newInterval) {
void Settings::setLowLimit(int newLimit) {
lowLimit = newLimit;
saveInteger(sLowLimit, &lowLimit);
mySettings->sync();
// Lows and highs are always saved in pairs!
//mySettings->sync();
emit lowLimitChanged(lowLimit);
qDebug() << "Change" << sLowLimit << newLimit;
}