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

View file

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