Fix static value selection in state descriptor editor

This commit is contained in:
Michael Zanetti 2021-08-30 23:13:29 +02:00
parent 7f26bb4568
commit 2f73092bf5

View File

@ -53,11 +53,6 @@ Page {
onBackPressed: root.backPressed(); onBackPressed: root.backPressed();
} }
QtObject {
id: d
property var value: root.stateType.defaultValue
}
GroupBox { GroupBox {
anchors { anchors {
left: parent.left left: parent.left
@ -123,13 +118,14 @@ Page {
ThinDivider { Layout.columnSpan: parent.columns } ThinDivider { Layout.columnSpan: parent.columns }
ParamDelegate { ParamDelegate {
id: staticValueParamDelegate
Layout.fillWidth: true Layout.fillWidth: true
hoverEnabled: false hoverEnabled: false
padding: 0 padding: 0
paramType: root.thing.thingClass.eventTypes.getEventType(root.stateType.id).paramTypes.getParamType(root.stateType.id) paramType: root.thing.thingClass.eventTypes.getEventType(root.stateType.id).paramTypes.getParamType(root.stateType.id)
enabled: staticValueRadioButton.checked enabled: staticValueRadioButton.checked
nameVisible: false nameVisible: false
value: d.value value: root.stateType.defaultValue
visible: staticValueRadioButton.checked visible: staticValueRadioButton.checked
placeholderText: qsTr("Insert value here") placeholderText: qsTr("Insert value here")
} }
@ -172,9 +168,11 @@ Page {
Layout.fillWidth: true Layout.fillWidth: true
Layout.margins: app.margins Layout.margins: app.margins
onClicked: { onClicked: {
print("saving")
root.stateDescriptor.valueOperator = operatorComboBox.currentIndex root.stateDescriptor.valueOperator = operatorComboBox.currentIndex
if (staticValueRadioButton.checked) { if (staticValueRadioButton.checked) {
root.stateDescriptor.value = d.value print("static value:", staticValueParamDelegate.value)
root.stateDescriptor.value = staticValueParamDelegate.value
} else { } else {
root.stateDescriptor.valueThingId = statePickerDelegate.thingId root.stateDescriptor.valueThingId = statePickerDelegate.thingId
root.stateDescriptor.valueStateTypeId = statePickerDelegate.stateTypeId root.stateDescriptor.valueStateTypeId = statePickerDelegate.stateTypeId