1
0
Fork 0

Launcher: fix date-time picker

This commit is contained in:
James Turner 2018-05-07 22:19:34 +01:00
parent 552df27341
commit 42936f4f22
2 changed files with 15 additions and 3 deletions

View file

@ -29,6 +29,12 @@ FocusScope {
value = Math.min(value, maxValue);
}
function doCommit(newValue)
{
value = newValue;
commit(newValue)
}
function zeroPaddedNumber(v)
{
var s = v.toString();
@ -46,7 +52,7 @@ FocusScope {
value = Math.min(parseInt(input.text) + 1, maxValue)
input.text = __valueString
} else {
commit(Math.min(value + 1, maxValue));
doCommit(Math.min(value + 1, maxValue));
}
}
@ -56,7 +62,7 @@ FocusScope {
value = Math.max(parseInt(input.text) - 1, minValue)
input.text = __valueString
} else {
commit(Math.max(value - 1, minValue));
doCommit(Math.max(value - 1, minValue));
}
}
@ -109,7 +115,7 @@ FocusScope {
if (activeFocus) {
selectAll();
} else {
commit(parseInt(text))
doCommit(parseInt(text))
}
}

View file

@ -33,6 +33,12 @@ SettingControl {
function restoreState()
{
var rawValue = _config.getValueForKey("", root.setting, defaultValue);
if (rawValue.getFullYear() < 1800) {
// assume it's an invalid date, there doesn't seem to be a better
// way to check date validity from JS :(
rawValue = defaultValue
}
dateTimeEdit.setDate(rawValue);
}
}