mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:48:09 +02:00
show spinbox suffix in separate control to: disallow editing it & allow to pass validator
This commit is contained in:
parent
a9ff1f4ecd
commit
37bb3586ea
1 changed files with 23 additions and 4 deletions
|
@ -83,8 +83,10 @@ SpinBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
validator: DoubleValidator {
|
validator: DoubleValidator {
|
||||||
bottom: Math.min(spinBox.from, spinBox.to)
|
decimals: spinBox.decimals
|
||||||
top: Math.max(spinBox.from, spinBox.to)
|
bottom: Math.min(spinBox.realFrom, spinBox.realTo)
|
||||||
|
top: Math.max(spinBox.realFrom, spinBox.realTo)
|
||||||
|
notation: DoubleValidator.StandardNotation
|
||||||
}
|
}
|
||||||
|
|
||||||
textFromValue: function(value, locale) {
|
textFromValue: function(value, locale) {
|
||||||
|
@ -97,20 +99,37 @@ SpinBox {
|
||||||
|
|
||||||
|
|
||||||
contentItem: TextInput {
|
contentItem: TextInput {
|
||||||
|
id: spinboxText
|
||||||
z: 2
|
z: 2
|
||||||
color: isLightColorScheme
|
color: isLightColorScheme
|
||||||
? (spinBox.activeFocus ? hifi.colors.black : hifi.colors.lightGray)
|
? (spinBox.activeFocus ? hifi.colors.black : hifi.colors.lightGray)
|
||||||
: (spinBox.activeFocus ? hifi.colors.white : hifi.colors.lightGrayText)
|
: (spinBox.activeFocus ? hifi.colors.white : hifi.colors.lightGrayText)
|
||||||
selectedTextColor: hifi.colors.black
|
selectedTextColor: hifi.colors.black
|
||||||
selectionColor: hifi.colors.primaryHighlight
|
selectionColor: hifi.colors.primaryHighlight
|
||||||
text: spinBox.textFromValue(spinBox.value, spinBox.locale) + suffix
|
text: spinBox.textFromValue(spinBox.value, spinBox.locale)
|
||||||
inputMethodHints: spinBox.inputMethodHints
|
inputMethodHints: spinBox.inputMethodHints
|
||||||
validator: spinBox.validator
|
validator: spinBox.validator
|
||||||
verticalAlignment: Qt.AlignVCenter
|
verticalAlignment: Qt.AlignVCenter
|
||||||
leftPadding: spinBoxLabelInside.visible ? 30 : hifi.dimensions.textPadding
|
leftPadding: spinBoxLabelInside.visible ? 30 : hifi.dimensions.textPadding
|
||||||
//rightPadding: hifi.dimensions.spinnerSize
|
|
||||||
width: spinBox.width - hifi.dimensions.spinnerSize
|
width: spinBox.width - hifi.dimensions.spinnerSize
|
||||||
onEditingFinished: spinBox.editingFinished()
|
onEditingFinished: spinBox.editingFinished()
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: suffixText
|
||||||
|
x: metrics.advanceWidth(spinboxText.text + '*')
|
||||||
|
height: spinboxText.height
|
||||||
|
|
||||||
|
FontMetrics {
|
||||||
|
id: metrics
|
||||||
|
font: spinboxText.font
|
||||||
|
}
|
||||||
|
|
||||||
|
color: isLightColorScheme
|
||||||
|
? (spinBox.activeFocus ? hifi.colors.black : hifi.colors.lightGray)
|
||||||
|
: (spinBox.activeFocus ? hifi.colors.white : hifi.colors.lightGrayText)
|
||||||
|
text: suffix
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
up.indicator: Item {
|
up.indicator: Item {
|
||||||
|
|
Loading…
Reference in a new issue