Massive typofix in settings' key names, optimize constructor

This commit is contained in:
Matti Viljanen 2020-03-20 23:00:30 +02:00
parent b00e024107
commit 2854217108
No known key found for this signature in database
GPG key ID: CF32A1495158F888
2 changed files with 32 additions and 40 deletions

View file

@ -75,7 +75,7 @@ Page {
valueText: value + "%" valueText: value + "%"
highlightDirection: Qt.RightToLeft highlightDirection: Qt.RightToLeft
onValueChanged: { onValueChanged: {
settings.highLimit = value settings.highAlert = value
if(lowAlertSlider.value >= value) if(lowAlertSlider.value >= value)
lowAlertSlider.value = value - 1 lowAlertSlider.value = value - 1
} }
@ -90,7 +90,7 @@ Page {
value: settings.lowAlert value: settings.lowAlert
valueText: value + "%" valueText: value + "%"
onValueChanged: { onValueChanged: {
settings.highLimit = value settings.lowAlert = value
if(highAlertSlider.value <= value) if(highAlertSlider.value <= value)
highAlertSlider.value = value + 1 highAlertSlider.value = value + 1
} }
@ -111,11 +111,11 @@ Page {
minimumValue: 20 minimumValue: 20
maximumValue: 95 maximumValue: 95
stepSize: 1 stepSize: 1
value: settings.lowLimit value: settings.highLimit
valueText: value + "%" valueText: value + "%"
highlightDirection: Qt.RightToLeft highlightDirection: Qt.RightToLeft
onValueChanged: { onValueChanged: {
settings.lowLimit = value settings.highLimit = value
if(lowLimitSlider.value >= value) if(lowLimitSlider.value >= value)
lowLimitSlider.value = value - 1 lowLimitSlider.value = value - 1
} }
@ -128,10 +128,10 @@ Page {
minimumValue: 20 minimumValue: 20
maximumValue: 95 maximumValue: 95
stepSize: 1 stepSize: 1
value: settings.highLimit value: settings.lowLimit
valueText: value + "%" valueText: value + "%"
onValueChanged: { onValueChanged: {
settings.highLimit = value settings.lowLimit = value
if(highLimitSlider.value <= value) if(highLimitSlider.value <= value)
highLimitSlider.value = value + 1 highLimitSlider.value = value + 1
} }

View file

@ -20,44 +20,36 @@
Settings::Settings(QObject *parent) : QObject(parent) Settings::Settings(QObject *parent) : QObject(parent)
{ {
int tempValue; int tempValue;
if(mySettings.contains(sLowAlert)) { tempValue = mySettings.value(sLowAlert, lowAlert).toInt();
tempValue = mySettings.value(sLowAlert).toInt(); if(tempValue >= 10 && tempValue <= 99) {
if(tempValue >= 10 && tempValue <= 99) { lowAlert = tempValue;
lowAlert = tempValue; emit lowAlertChanged();
emit lowAlertChanged();
}
} }
if(mySettings.contains(sHighAlert)) {
tempValue = mySettings.value(sHighAlert).toInt(); tempValue = mySettings.value(sHighAlert, highAlert).toInt();
if(tempValue >= 10 && tempValue <= 99) { if(tempValue >= 10 && tempValue <= 99) {
highAlert = tempValue; highAlert = tempValue;
emit highAlertChanged(); emit highAlertChanged();
}
} }
if(mySettings.contains(sInterval)) {
tempValue = mySettings.value(sInterval).toInt(); tempValue = mySettings.value(sInterval, interval).toInt();
if(tempValue >= 60 && tempValue <= 600) { if(tempValue >= 60 && tempValue <= 600) {
interval = tempValue; interval = tempValue;
emit intervalChanged(); emit intervalChanged();
}
} }
if(mySettings.contains(sLimitEnabled)) {
limitEnabled = (mySettings.value(sLimitEnabled).toInt() == 1); limitEnabled = (mySettings.value(sLimitEnabled, sLimitEnabled).toInt() == 1);
emit limitEnabledChanged(); emit limitEnabledChanged();
tempValue = mySettings.value(sLowLimit).toInt();
if(tempValue >= 20 && tempValue <= 95) {
lowLimit = tempValue;
emit lowLimitChanged();
} }
if(mySettings.contains(sLowLimit)) {
tempValue = mySettings.value(sLowLimit).toInt(); tempValue = mySettings.value(sHighLimit, highLimit).toInt();
if(tempValue >= 20 && tempValue <= 95) { if(tempValue >= 20 && tempValue <= 95) {
lowLimit = tempValue; highLimit = tempValue;
emit lowLimitChanged(); emit highLimitChanged();
}
}
if(mySettings.contains(sHighLimit)) {
tempValue = mySettings.value(sHighLimit).toInt();
if(tempValue >= 20 && tempValue <= 95) {
highLimit = tempValue;
emit highLimitChanged();
}
} }
} }