Also tune some param delegates a bit

This commit is contained in:
Michael Zanetti 2020-05-07 17:37:40 +02:00
parent c30edaafdc
commit d69c466c22
2 changed files with 10 additions and 5 deletions

View File

@ -66,7 +66,8 @@ ItemDelegate {
id: loader id: loader
Layout.fillWidth: true// sourceComponent === textFieldComponent || sourceComponent === stringComponent Layout.fillWidth: true// sourceComponent === textFieldComponent || sourceComponent === stringComponent
sourceComponent: { sourceComponent: {
print("loading paramdelegate:", root.writable, root.paramType.type) print("Loading ParamDelegate");
print("Writable:", root.writable, "type:", root.paramType.type, "min:", root.paramType.minValue, "max:", root.paramType.maxValue)
if (!root.writable) { if (!root.writable) {
return stringComponent; return stringComponent;
} }
@ -79,7 +80,8 @@ ItemDelegate {
case "double": case "double":
if (root.paramType.allowedValues.length > 0) { if (root.paramType.allowedValues.length > 0) {
return comboBoxComponent; return comboBoxComponent;
} else if (root.paramType.minValue !== undefined && root.paramType.maxValue !== undefined) { } else if (root.paramType.minValue !== undefined && root.paramType.maxValue !== undefined
&& (root.paramType.maxValue - root.paramType.minValue <= 100)) {
return sliderComponent; return sliderComponent;
} else { } else {
return spinnerComponent; return spinnerComponent;
@ -149,6 +151,7 @@ ItemDelegate {
id: sliderComponent id: sliderComponent
RowLayout { RowLayout {
spacing: app.margins spacing: app.margins
Slider { Slider {
id: slider id: slider
Layout.fillWidth: true Layout.fillWidth: true
@ -162,7 +165,7 @@ ItemDelegate {
} }
return ret; return ret;
} }
property int decimals: root.paramType.type.toLocaleLowerCase() === "int" ? 0 : 1 property int decimals: root.paramType.type.toLocaleLowerCase() === "double" ? 1 : 0
onMoved: { onMoved: {
var newValue var newValue
@ -190,12 +193,12 @@ ItemDelegate {
SpinBox { SpinBox {
value: root.param.value ? root.param.value : 0 value: root.param.value ? root.param.value : 0
from: root.paramType.minValue from: root.paramType.minValue !== undefined
? root.paramType.minValue ? root.paramType.minValue
: root.paramType.type.toLowerCase() === "uint" : root.paramType.type.toLowerCase() === "uint"
? 0 ? 0
: -2000000000 : -2000000000
to: root.paramType.maxValue to: root.paramType.maxValue !== undefined
? root.paramType.maxValue ? root.paramType.maxValue
: 2000000000 : 2000000000
editable: true editable: true
@ -205,6 +208,7 @@ ItemDelegate {
return Types.toUiValue(value, root.paramType.unit) return Types.toUiValue(value, root.paramType.unit)
} }
Component.onCompleted: { Component.onCompleted: {
print("from:", from, "min", root.paramType.minValue)
if (root.value === undefined) { if (root.value === undefined) {
root.value = value root.value = value
} }

View File

@ -137,6 +137,7 @@ ItemDelegate {
Label { Label {
text: Types.toUiUnit(paramType.unit) text: Types.toUiUnit(paramType.unit)
visible: paramType.unit !== Types.UnitNone
} }
} }