diff --git a/nymea-app/ui/delegates/statedelegates/ColorDelegate.qml b/nymea-app/ui/delegates/statedelegates/ColorDelegate.qml index 18083220..6d9a3f2f 100644 --- a/nymea-app/ui/delegates/statedelegates/ColorDelegate.qml +++ b/nymea-app/ui/delegates/statedelegates/ColorDelegate.qml @@ -9,6 +9,7 @@ Item { id: colorComponentItem implicitWidth: app.iconSize * 2 implicitHeight: app.iconSize + property bool writable: false property var value signal changed(var value) @@ -25,6 +26,10 @@ Item { MouseArea { anchors.fill: parent onClicked: { + if (!colorComponentItem.writable) { + return; + } + var pos = colorComponentItem.mapToItem(root, 0, colorComponentItem.height) print("opening", colorComponentItem.value) var colorPicker = colorPickerComponent.createObject(root, {preferredY: pos.y, colorValue: colorComponentItem.value }) diff --git a/nymea-app/ui/delegates/statedelegates/SpinBoxDelegate.qml b/nymea-app/ui/delegates/statedelegates/SpinBoxDelegate.qml index 9b6e47fb..57347e5a 100644 --- a/nymea-app/ui/delegates/statedelegates/SpinBoxDelegate.qml +++ b/nymea-app/ui/delegates/statedelegates/SpinBoxDelegate.qml @@ -8,7 +8,7 @@ import "../../components" SpinBox { width: 150 signal changed(var value) - stepSize: (to - from) / 10 + stepSize: Math.min(10, (to - from) / 10) editable: true onValueModified: { changed(value) diff --git a/nymea-app/ui/delegates/statedelegates/TextFieldDelegate.qml b/nymea-app/ui/delegates/statedelegates/TextFieldDelegate.qml index 35fc098e..fc7b5cdd 100644 --- a/nymea-app/ui/delegates/statedelegates/TextFieldDelegate.qml +++ b/nymea-app/ui/delegates/statedelegates/TextFieldDelegate.qml @@ -8,4 +8,9 @@ import "../../components" TextField { property var value text: value + + signal changed(string value) + onEditingFinished: { + changed(text) + } } diff --git a/nymea-app/ui/devicepages/GenericDevicePage.qml b/nymea-app/ui/devicepages/GenericDevicePage.qml index f2d0aae7..118f55c9 100644 --- a/nymea-app/ui/devicepages/GenericDevicePage.qml +++ b/nymea-app/ui/devicepages/GenericDevicePage.qml @@ -12,6 +12,7 @@ DevicePageBase { showDetailsButton: false function executeAction(actionTypeId, params) { + print("executing", actionTypeId) return engine.deviceManager.executeAction(root.device.id, actionTypeId, params) } @@ -140,7 +141,7 @@ DevicePageBase { switch (stateDelegate.stateType.type.toLowerCase()) { case "string": if (isWritable) { - if (stateDelegate.stateType.allowedValues !== undefined) { + if (stateDelegate.stateType.allowedValues.length > 0) { sourceComp = "ComboBoxDelegate.qml" } else { sourceComp = "TextFieldDelegate.qml"; @@ -160,12 +161,16 @@ DevicePageBase { } break; case "int": + case "uint": case "double": if (stateDelegate.stateType.unit === Types.UnitUnixTime) { sourceComp = "DateTimeDelegate.qml"; } else if (isWritable) { - sourceComp = "SliderDelegate.qml"; -// sourceComp = "SpinBoxDelegate.qml"; + if (stateDelegate.stateType.minValue !== undefined && stateDelegate.stateType.maxValue !== undefined) { + sourceComp = "SliderDelegate.qml"; + } else { + sourceComp = "SpinBoxDelegate.qml"; + } } else { sourceComp = "NumberLabelDelegate.qml"; } @@ -179,12 +184,21 @@ DevicePageBase { print("GenericDevicePage: unhandled entry", stateDelegate.stateType.displayName) } + var minValue = stateDelegate.stateType.minValue + ? stateDelegate.stateType.minValue + : stateDelegate.stateType.type.toLowerCase() === "uint" + ? 0 + : -2000000000; // As per QML spec + var maxValue = stateDelegate.stateType.maxValue + ? stateDelegate.stateType.maxValue + : 2000000000; stateDelegateLoader.setSource("../delegates/statedelegates/" + sourceComp, { // value: root.device.states.getState(stateType.id).value, possibleValues: stateDelegate.stateType.allowedValues, - from: stateDelegate.stateType.minValue, - to: stateDelegate.stateType.maxValue, + from: minValue, + to: maxValue, + writable: isWritable, stateType: stateDelegate.stateType }) }