From a5d8ae0fa321d34698f5298007ead257256a5c83 Mon Sep 17 00:00:00 2001 From: Matti Viljanen Date: Sun, 26 Apr 2020 18:23:35 +0300 Subject: [PATCH] Save settings after releasing the sliders --- application/qml/pages/SettingsPage.qml | 22 +++++++++++++++++----- application/src/settings.cpp | 6 ++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/application/qml/pages/SettingsPage.qml b/application/qml/pages/SettingsPage.qml index d197149..fa4dc75 100644 --- a/application/qml/pages/SettingsPage.qml +++ b/application/qml/pages/SettingsPage.qml @@ -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 } } } diff --git a/application/src/settings.cpp b/application/src/settings.cpp index ae79aab..60274c9 100644 --- a/application/src/settings.cpp +++ b/application/src/settings.cpp @@ -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; }