Merge PR #376: Small improvements in the edit rules page
This commit is contained in:
commit
d4eff3baa2
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@ -137,6 +137,7 @@ ItemDelegate {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: Types.toUiUnit(paramType.unit)
|
text: Types.toUiUnit(paramType.unit)
|
||||||
|
visible: paramType.unit !== Types.UnitNone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -499,7 +499,7 @@ Page {
|
|||||||
|
|
||||||
Button {
|
Button {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.margins: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.bottomMargin: app.margins
|
||||||
text: eventsRepeater.count == 0 && timeEventRepeater.count === 0 ? qsTr("Configure...") : qsTr("Add another...")
|
text: eventsRepeater.count == 0 && timeEventRepeater.count === 0 ? qsTr("Configure...") : qsTr("Add another...")
|
||||||
visible: !root.isStateBased
|
visible: !root.isStateBased
|
||||||
onClicked: {
|
onClicked: {
|
||||||
@ -592,8 +592,8 @@ Page {
|
|||||||
|
|
||||||
Button {
|
Button {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.margins: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.bottomMargin: app.margins
|
||||||
text: root.rule.stateEvaluator === null && root.rule.timeDescriptor.calendarItems.count === 0 ?
|
text: root.rule.stateEvaluator === null || root.rule.timeDescriptor.calendarItems.count === 0 ?
|
||||||
qsTr("Configure...") :
|
qsTr("Configure...") :
|
||||||
qsTr("Add another...")
|
qsTr("Add another...")
|
||||||
visible: root.rule.timeDescriptor.timeEventItems.count === 0 || root.rule.stateEvaluator === null
|
visible: root.rule.timeDescriptor.timeEventItems.count === 0 || root.rule.stateEvaluator === null
|
||||||
@ -661,7 +661,7 @@ Page {
|
|||||||
|
|
||||||
Button {
|
Button {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.margins: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.bottomMargin: app.margins
|
||||||
text: root.isEmpty ? qsTr("Configure...") :
|
text: root.isEmpty ? qsTr("Configure...") :
|
||||||
actionsRepeater.count == 0 ? qsTr("Add an action...") : qsTr("Add another action...")
|
actionsRepeater.count == 0 ? qsTr("Add an action...") : qsTr("Add another action...")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
@ -697,7 +697,7 @@ Page {
|
|||||||
|
|
||||||
Button {
|
Button {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.margins: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.bottomMargin: app.margins
|
||||||
text: actionsRepeater.count == 0 ? qsTr("Add an action...") : qsTr("Add another action...")
|
text: actionsRepeater.count == 0 ? qsTr("Add an action...") : qsTr("Add another action...")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var page = pageStack.push(ruleActionQuestionPageComponent, {exitAction: true});
|
var page = pageStack.push(ruleActionQuestionPageComponent, {exitAction: true});
|
||||||
|
|||||||
@ -64,9 +64,18 @@ NymeaListItemDelegate {
|
|||||||
var ruleActionParam = root.ruleAction.ruleActionParams.get(i)
|
var ruleActionParam = root.ruleAction.ruleActionParams.get(i)
|
||||||
print("populating subtext:", ruleActionParam.eventTypeId, ruleActionParam.eventParamTypeId, ruleActionParam.stateDeviceId, ruleActionParam.stateTypeId, ruleActionParam.isValueBased, ruleActionParam.isEventParamBased, ruleActionParam.isStateValueBased)
|
print("populating subtext:", ruleActionParam.eventTypeId, ruleActionParam.eventParamTypeId, ruleActionParam.stateDeviceId, ruleActionParam.stateTypeId, ruleActionParam.isValueBased, ruleActionParam.isEventParamBased, ruleActionParam.isStateValueBased)
|
||||||
|
|
||||||
var paramString = qsTr("%1: %2").arg(root.actionType.paramTypes.getParamType(ruleActionParam.paramTypeId).displayName)
|
var paramType = root.actionType.paramTypes.getParamType(ruleActionParam.paramTypeId);
|
||||||
|
var paramString = qsTr("%1: %2").arg(paramType.displayName)
|
||||||
if (ruleActionParam.isValueBased) {
|
if (ruleActionParam.isValueBased) {
|
||||||
paramString = paramString.arg(ruleActionParam.value)
|
var text = ""
|
||||||
|
switch (paramType.type.toLowerCase()) {
|
||||||
|
case "bool":
|
||||||
|
text = ruleActionParam.value === true ? qsTr("True") : qsTr("False")
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
text = ruleActionParam.value
|
||||||
|
}
|
||||||
|
paramString = paramString.arg(text)
|
||||||
} else if (ruleActionParam.isEventParamBased) {
|
} else if (ruleActionParam.isEventParamBased) {
|
||||||
paramString = paramString.arg(qsTr("value from event"))
|
paramString = paramString.arg(qsTr("value from event"))
|
||||||
} else if (ruleActionParam.isStateValueBased) {
|
} else if (ruleActionParam.isStateValueBased) {
|
||||||
|
|||||||
@ -97,10 +97,17 @@ SwipeDelegate {
|
|||||||
if (!root.stateType) {
|
if (!root.stateType) {
|
||||||
return qsTr("Press to edit condition")
|
return qsTr("Press to edit condition")
|
||||||
}
|
}
|
||||||
|
var valueText = root.stateEvaluator.stateDescriptor.value;
|
||||||
|
switch (root.stateType.type.toLowerCase()) {
|
||||||
|
case "bool":
|
||||||
|
valueText = root.stateEvaluator.stateDescriptor.value === true ? qsTr("True") : qsTr("False")
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (root.device) {
|
if (root.device) {
|
||||||
return qsTr("%1: %2 %3 %4").arg(root.device.name).arg(root.stateType.displayName).arg(operatorString).arg(root.stateEvaluator.stateDescriptor.value)
|
return qsTr("%1: %2 %3 %4").arg(root.device.name).arg(root.stateType.displayName).arg(operatorString).arg(valueText)
|
||||||
} else if (root.iface) {
|
} else if (root.iface) {
|
||||||
return qsTr("%1: %2 %3 %4").arg(root.iface.displayName).arg(root.stateType.displayName).arg(operatorString).arg(root.stateEvaluator.stateDescriptor.value)
|
return qsTr("%1: %2 %3 %4").arg(root.iface.displayName).arg(root.stateType.displayName).arg(operatorString).arg(valueText)
|
||||||
}
|
}
|
||||||
return "--";
|
return "--";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user