fix paramDelegate for double

This commit is contained in:
Michael Zanetti 2019-01-28 13:30:41 +01:00
parent 6b95be2e40
commit d81f609614

View File

@ -31,6 +31,7 @@ ItemDelegate {
id: loader
Layout.fillWidth: sourceComponent === textFieldComponent
sourceComponent: {
print("loading paramdelegate:", root.writable, root.paramType.type)
if (!root.writable) {
return stringComponent;
}
@ -39,7 +40,8 @@ ItemDelegate {
case "bool":
return boolComponent;
case "int":
return spinnerComponent;
case "double":
return sliderComponent;
case "string":
case "qstring":
if (root.paramType.allowedValues.length > 0) {
@ -104,22 +106,14 @@ ItemDelegate {
id: sliderComponent
RowLayout {
spacing: app.margins
Label {
text: root.paramType.minValue
}
Slider {
id: slider
Layout.fillWidth: true
from: root.paramType.minValue
to: root.paramType.maxValue
value: root.param.value
stepSize: {
switch (root.paramType.type.toLowerCase()) {
case "int":
return 1;
}
return 0.01;
}
stepSize: 1 / (10 * decimals)
property int decimals: root.paramType.type.toLocaleLowerCase() === "int" ? 0 : 1
onMoved: {
var newValue
@ -134,7 +128,7 @@ ItemDelegate {
}
}
Label {
text: root.paramType.maxValue
text: root.param.value.toFixed(slider.decimals) + root.paramType.unitString
}
}