forked from qt-creator/qt-creator
QmlDesigner: Fix validation on integer spinboxes
Now spinboxes use IntValidator if decimals is set to zero. Fixes: QDS-11922 Change-Id: Ibe8c8a18294a6764a0cd2182d09c30cdf9fb27cc Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -95,7 +95,7 @@ T.SpinBox {
|
|||||||
control.focus = false
|
control.focus = false
|
||||||
}
|
}
|
||||||
|
|
||||||
validator: DoubleValidator {
|
DoubleValidator {
|
||||||
id: doubleValidator
|
id: doubleValidator
|
||||||
locale: control.locale.name
|
locale: control.locale.name
|
||||||
notation: DoubleValidator.StandardNotation
|
notation: DoubleValidator.StandardNotation
|
||||||
@@ -104,6 +104,15 @@ T.SpinBox {
|
|||||||
top: Math.max(control.realFrom, control.realTo)
|
top: Math.max(control.realFrom, control.realTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntValidator {
|
||||||
|
id: intValidator
|
||||||
|
locale: control.locale.name
|
||||||
|
bottom: Math.round(Math.min(control.realFrom, control.realTo))
|
||||||
|
top: Math.round(Math.max(control.realFrom, control.realTo))
|
||||||
|
}
|
||||||
|
|
||||||
|
validator: control.decimals === 0 ? intValidator : doubleValidator
|
||||||
|
|
||||||
ActionIndicator {
|
ActionIndicator {
|
||||||
id: actionIndicator
|
id: actionIndicator
|
||||||
style: control.style
|
style: control.style
|
||||||
@@ -153,7 +162,7 @@ T.SpinBox {
|
|||||||
id: spinBoxInput
|
id: spinBoxInput
|
||||||
style: control.style
|
style: control.style
|
||||||
__parentControl: control
|
__parentControl: control
|
||||||
validator: doubleValidator
|
validator: control.validator
|
||||||
|
|
||||||
function handleEditingFinished() {
|
function handleEditingFinished() {
|
||||||
control.checkAndClearFocus()
|
control.checkAndClearFocus()
|
||||||
|
Reference in New Issue
Block a user