mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-06 02:08:25 +02:00
[ui] AttributeEditor: fix value setting by slider + avoid scientific notation
* fix reference to non-existing slider.value * convert values to string to avoid e+XX notation on large numbers * fix number of decimals based on stepSize to avoid floating point approximations
This commit is contained in:
parent
6bb70895f3
commit
d3885331b2
1 changed files with 6 additions and 2 deletions
|
@ -202,7 +202,9 @@ RowLayout {
|
||||||
}
|
}
|
||||||
implicitWidth: 70
|
implicitWidth: 70
|
||||||
enabled: root.editable
|
enabled: root.editable
|
||||||
text: slider.active && slider.item.pressed ? slider.value : attribute.value
|
// cast value to string to avoid intrusive scientific notations on numbers
|
||||||
|
property string displayValue: String(slider.active && slider.item.pressed ? slider.item.formattedValue : attribute.value)
|
||||||
|
text: displayValue
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
validator: attribute.type == "FloatParam" ? doubleValidator : intValidator
|
validator: attribute.type == "FloatParam" ? doubleValidator : intValidator
|
||||||
onEditingFinished: setTextFieldAttribute(text)
|
onEditingFinished: setTextFieldAttribute(text)
|
||||||
|
@ -214,6 +216,8 @@ RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
active: attribute.desc.range != undefined
|
active: attribute.desc.range != undefined
|
||||||
sourceComponent: Slider {
|
sourceComponent: Slider {
|
||||||
|
readonly property int stepDecimalCount: stepSize < 1 ? String(stepSize).split(".").pop().length : 0
|
||||||
|
readonly property real formattedValue: value.toFixed(stepDecimalCount)
|
||||||
enabled: root.editable
|
enabled: root.editable
|
||||||
value: attribute.value
|
value: attribute.value
|
||||||
from: attribute.desc.range[0]
|
from: attribute.desc.range[0]
|
||||||
|
@ -223,7 +227,7 @@ RowLayout {
|
||||||
|
|
||||||
onPressedChanged: {
|
onPressedChanged: {
|
||||||
if(!pressed)
|
if(!pressed)
|
||||||
_reconstruction.setAttribute(attribute, value)
|
_reconstruction.setAttribute(attribute, formattedValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue