Mobile: Add Input Validation and Conversion for Gradient Factors.

Add input validation and input conversion for the gradient factor
settings.

Signed-off-by: Michael Keller <mikeller@042.ch>
This commit is contained in:
Michael Keller 2024-02-14 16:41:44 +13:00 committed by Michael Keller
parent 704b26ff1e
commit a946dc323b

View file

@ -633,8 +633,8 @@ TemplatePage {
}
}
TemplateLabel {
visible: PrefTechnicalDetails.calcceiling
text: qsTr("GFLow")
enabled: PrefTechnicalDetails.calcceiling
text: qsTr("GFLow (10 to 150)")
}
TemplateSpinBox {
visible: PrefTechnicalDetails.calcceiling
@ -645,17 +645,30 @@ TemplatePage {
to: 150
stepSize: 1
value: PrefTechnicalDetails.gflow
validator: RegExpValidator { regExp: /1?\d{0,2}%?/ }
textFromValue: function (value, locale) {
return value + "%"
}
valueFromText: function(text, locale) {
var result = parseInt(text);
if (result < 10)
result = 10;
else if (result > 150)
result = 150;
else if (isNaN(result))
result = 35;
return result;
}
onValueChanged: {
PrefTechnicalDetails.gflow = value
rootItem.settingsChanged()
}
}
TemplateLabel {
visible: PrefTechnicalDetails.calcceiling
text: qsTr("GFHigh")
enabled: PrefTechnicalDetails.calcceiling
text: qsTr("GFHigh (10 to 150")
}
TemplateSpinBox {
visible: PrefTechnicalDetails.calcceiling
@ -666,9 +679,22 @@ TemplatePage {
to: 150
stepSize: 1
value: PrefTechnicalDetails.gfhigh
validator: RegExpValidator { regExp: /1?\d{0,2}%?/ }
textFromValue: function (value, locale) {
return value + "%"
}
valueFromText: function(text, locale) {
var result = parseInt(text);
if (result < 10)
result = 10;
else if (result > 150)
result = 150;
else if (isNaN(result))
result = 70;
return result;
}
onValueChanged: {
PrefTechnicalDetails.gfhigh = value
rootItem.settingsChanged()