From f3b92b1b5d63986b45ec52f478589e9bba518945 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Fri, 22 Oct 2021 23:32:27 +0200 Subject: [PATCH] Fix uint handling in event descriptor delegate --- nymea-app/ui/components/NymeaSpinBox.qml | 1 + .../ui/delegates/ParamDescriptorDelegate.qml | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/nymea-app/ui/components/NymeaSpinBox.qml b/nymea-app/ui/components/NymeaSpinBox.qml index fc66c3ec..f0fa03d1 100644 --- a/nymea-app/ui/components/NymeaSpinBox.qml +++ b/nymea-app/ui/components/NymeaSpinBox.qml @@ -38,6 +38,7 @@ RowLayout { text: root.value readOnly: !root.editable horizontalAlignment: Text.AlignHCenter + Layout.fillWidth: true onTextEdited: { root.value = text root.valueModified(root.value) diff --git a/nymea-app/ui/delegates/ParamDescriptorDelegate.qml b/nymea-app/ui/delegates/ParamDescriptorDelegate.qml index 0dcf6cee..374ed996 100644 --- a/nymea-app/ui/delegates/ParamDescriptorDelegate.qml +++ b/nymea-app/ui/delegates/ParamDescriptorDelegate.qml @@ -32,6 +32,7 @@ import QtQuick 2.4 import QtQuick.Controls 2.1 import QtQuick.Layouts 1.2 import Nymea 1.0 +import "../components" ItemDelegate { id: root @@ -69,6 +70,7 @@ ItemDelegate { case "qstring": case "color": return false; + case "uint": case "int": case "double": return true; @@ -116,12 +118,13 @@ ItemDelegate { switch (paramType.type.toLowerCase()) { case "bool": return boolComponent; + case "uint": case "int": case "double": if (paramType.minValue !== undefined && paramType.maxValue !== undefined) { return labelComponent; } - return textFieldComponent; + return spinboxComponent; case "string": case "qstring": case "color": @@ -144,6 +147,7 @@ ItemDelegate { Loader { Layout.fillWidth: true sourceComponent: { + print("***********+ loading", paramType.type) switch (paramType.type.toLowerCase()) { case "int": case "double": @@ -151,6 +155,7 @@ ItemDelegate { return sliderComponent } + } } } @@ -206,6 +211,17 @@ ItemDelegate { } + Component { + id: spinboxComponent + NymeaSpinBox { + from: paramType.minValue + to: paramType.maxValue + value: root.value != undefined ? root.value : 0 + onValueModified: root.value = value + floatingPoint: root.paramType.type.toLowerCase() === "double" + } + } + Component { id: boolComponent ComboBox {