Merge PR #141: Fixes in some generic state delegates

This commit is contained in:
Jenkins 2019-02-05 23:11:54 +01:00
commit 0396098390
4 changed files with 30 additions and 6 deletions

View File

@ -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 })

View File

@ -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)

View File

@ -8,4 +8,9 @@ import "../../components"
TextField {
property var value
text: value
signal changed(string value)
onEditingFinished: {
changed(text)
}
}

View File

@ -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
})
}