drop old delegates, clean up some stuff
This commit is contained in:
parent
0b5fa2618c
commit
425572b3c7
@ -5,21 +5,14 @@
|
|||||||
<file>ui/main.qml</file>
|
<file>ui/main.qml</file>
|
||||||
<file>ui/NewDeviceWizard.qml</file>
|
<file>ui/NewDeviceWizard.qml</file>
|
||||||
<file>ui/SettingsPage.qml</file>
|
<file>ui/SettingsPage.qml</file>
|
||||||
<file>ui/actiondelegates/ActionDelegateBase.qml</file>
|
|
||||||
<file>ui/actiondelegates/ActionDelegateBool.qml</file>
|
|
||||||
<file>ui/actiondelegates/ActionDelegateSlider.qml</file>
|
|
||||||
<file>ui/components/GuhHeader.qml</file>
|
<file>ui/components/GuhHeader.qml</file>
|
||||||
<file>ui/components/HeaderButton.qml</file>
|
<file>ui/components/HeaderButton.qml</file>
|
||||||
<file>ui/images/add.svg</file>
|
<file>ui/images/add.svg</file>
|
||||||
<file>ui/images/back.svg</file>
|
<file>ui/images/back.svg</file>
|
||||||
<file>ui/images/close.svg</file>
|
<file>ui/images/close.svg</file>
|
||||||
<file>ui/MainPage.qml</file>
|
<file>ui/MainPage.qml</file>
|
||||||
<file>ui/actiondelegates/ActionDelegateFallback.qml</file>
|
|
||||||
<file>ui/images/info.svg</file>
|
<file>ui/images/info.svg</file>
|
||||||
<file>ui/actiondelegates/ActionDelegateColor.qml</file>
|
|
||||||
<file>ui/components/ColorPicker.qml</file>
|
<file>ui/components/ColorPicker.qml</file>
|
||||||
<file>ui/actiondelegates/ActionDelegateNoParams.qml</file>
|
|
||||||
<file>ui/actiondelegates/ActionDelegateStringFromStringList.qml</file>
|
|
||||||
<file>ui/customviews/CustomViewBase.qml</file>
|
<file>ui/customviews/CustomViewBase.qml</file>
|
||||||
<file>ui/customviews/WeatherView.qml</file>
|
<file>ui/customviews/WeatherView.qml</file>
|
||||||
<file>ui/customviews/MediaControllerView.qml</file>
|
<file>ui/customviews/MediaControllerView.qml</file>
|
||||||
@ -49,7 +42,6 @@
|
|||||||
<file>ui/images/media-seek-forward.svg</file>
|
<file>ui/images/media-seek-forward.svg</file>
|
||||||
<file>ui/images/media-skip-backward.svg</file>
|
<file>ui/images/media-skip-backward.svg</file>
|
||||||
<file>ui/images/media-skip-forward.svg</file>
|
<file>ui/images/media-skip-forward.svg</file>
|
||||||
<file>ui/paramdelegates/BoolParamDelegate.qml</file>
|
|
||||||
<file>ui/components/ThinDivider.qml</file>
|
<file>ui/components/ThinDivider.qml</file>
|
||||||
<file>ui/images/weather-app-symbolic.svg</file>
|
<file>ui/images/weather-app-symbolic.svg</file>
|
||||||
<file>ui/images/weathericons/weather-clear-day.svg</file>
|
<file>ui/images/weathericons/weather-clear-day.svg</file>
|
||||||
@ -81,11 +73,7 @@
|
|||||||
<file>ui/images/sensors.svg</file>
|
<file>ui/images/sensors.svg</file>
|
||||||
<file>ui/images/temperature.svg</file>
|
<file>ui/images/temperature.svg</file>
|
||||||
<file>ui/images/network-wired-symbolic.svg</file>
|
<file>ui/images/network-wired-symbolic.svg</file>
|
||||||
<file>ui/paramdelegates/StringParamDelegate.qml</file>
|
|
||||||
<file>ui/paramdelegates/ParamDelegate.qml</file>
|
|
||||||
<file>ui/paramdelegates/ParamDelegateBase.qml</file>
|
|
||||||
<file>ui/images/notification.svg</file>
|
<file>ui/images/notification.svg</file>
|
||||||
<file>ui/paramdelegates/IntParamDelegate.qml</file>
|
|
||||||
<file>ui/customviews/NotificationsView.qml</file>
|
<file>ui/customviews/NotificationsView.qml</file>
|
||||||
<file>ui/devicepages/DevicePageBase.qml</file>
|
<file>ui/devicepages/DevicePageBase.qml</file>
|
||||||
<file>ui/images/battery/battery-000.svg</file>
|
<file>ui/images/battery/battery-000.svg</file>
|
||||||
@ -104,7 +92,6 @@
|
|||||||
<file>ui/EditDevicesPage.qml</file>
|
<file>ui/EditDevicesPage.qml</file>
|
||||||
<file>ui/devicepages/ConfigureThingPage.qml</file>
|
<file>ui/devicepages/ConfigureThingPage.qml</file>
|
||||||
<file>ui/magic/DeviceRulesPage.qml</file>
|
<file>ui/magic/DeviceRulesPage.qml</file>
|
||||||
<file>ui/magic/NewThingMagicPage.qml</file>
|
|
||||||
<file>ui/magic/EditRulePage.qml</file>
|
<file>ui/magic/EditRulePage.qml</file>
|
||||||
<file>ui/magic/SelectThingPage.qml</file>
|
<file>ui/magic/SelectThingPage.qml</file>
|
||||||
<file>ui/magic/ComposeEventDescriptorPage.qml</file>
|
<file>ui/magic/ComposeEventDescriptorPage.qml</file>
|
||||||
@ -115,14 +102,14 @@
|
|||||||
<file>ui/images/tick.svg</file>
|
<file>ui/images/tick.svg</file>
|
||||||
<file>ui/magic/SelectEventDescriptorParamsPage.qml</file>
|
<file>ui/magic/SelectEventDescriptorParamsPage.qml</file>
|
||||||
<file>ui/magic/SelectEventDescriptorPage.qml</file>
|
<file>ui/magic/SelectEventDescriptorPage.qml</file>
|
||||||
<file>ui/paramdelegates/DoubleParamDelegate.qml</file>
|
<file>ui/delegates/ParamDescriptorDelegate.qml</file>
|
||||||
<file>ui/paramdescriptordelegates/ParamDescriptorDelegateBase.qml</file>
|
<file>ui/delegates/ParamDelegate.qml</file>
|
||||||
|
<file>ui/delegates/ActionDelegate.qml</file>
|
||||||
<file>ui/system/LogViewerPage.qml</file>
|
<file>ui/system/LogViewerPage.qml</file>
|
||||||
<file>ui/images/next.svg</file>
|
<file>ui/images/next.svg</file>
|
||||||
<file>ui/images/go-down.svg</file>
|
<file>ui/images/go-down.svg</file>
|
||||||
<file>ui/system/PluginsPage.qml</file>
|
<file>ui/system/PluginsPage.qml</file>
|
||||||
<file>ui/system/PluginParamsPage.qml</file>
|
<file>ui/system/PluginParamsPage.qml</file>
|
||||||
<file>ui/paramdelegates-ng/ParamDelegate.qml</file>
|
|
||||||
<file>ui/components/ErrorDialog.qml</file>
|
<file>ui/components/ErrorDialog.qml</file>
|
||||||
<file>ui/fonts/Ubuntu-B.ttf</file>
|
<file>ui/fonts/Ubuntu-B.ttf</file>
|
||||||
<file>ui/fonts/Ubuntu-BI.ttf</file>
|
<file>ui/fonts/Ubuntu-BI.ttf</file>
|
||||||
@ -136,7 +123,6 @@
|
|||||||
<file>ui/components/InterfacesModels.qml</file>
|
<file>ui/components/InterfacesModels.qml</file>
|
||||||
<file>ui/magic/StateEvaluatorDelegate.qml</file>
|
<file>ui/magic/StateEvaluatorDelegate.qml</file>
|
||||||
<file>ui/magic/EditStateEvaluatorPage.qml</file>
|
<file>ui/magic/EditStateEvaluatorPage.qml</file>
|
||||||
<file>ui/actiondelegates-ng/ActionDelegate.qml</file>
|
|
||||||
<file>ui/magic/SimpleStateEvaluatorDelegate.qml</file>
|
<file>ui/magic/SimpleStateEvaluatorDelegate.qml</file>
|
||||||
<file>ui/magic/SelectStateDescriptorParamsPage.qml</file>
|
<file>ui/magic/SelectStateDescriptorParamsPage.qml</file>
|
||||||
<file>ui/magic/SelectStateDescriptorPage.qml</file>
|
<file>ui/magic/SelectStateDescriptorPage.qml</file>
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import QtQuick.Layouts 1.1
|
|||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.1
|
||||||
import Mea 1.0
|
import Mea 1.0
|
||||||
import "components"
|
import "components"
|
||||||
import "paramdelegates-ng"
|
import "delegates"
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
id: root
|
id: root
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
import QtQuick 2.5
|
|
||||||
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
property var actionType: null
|
|
||||||
property var actionState: null
|
|
||||||
|
|
||||||
signal executeAction(var params)
|
|
||||||
}
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
import QtQuick 2.5
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
|
|
||||||
ActionDelegateBase {
|
|
||||||
id: root
|
|
||||||
height: rowLayout.implicitHeight
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: rowLayout
|
|
||||||
anchors { left: parent.left; right: parent.right; margins: app.margins }
|
|
||||||
spacing: app.margins
|
|
||||||
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
text: root.actionType ? root.actionType.displayName : ""
|
|
||||||
}
|
|
||||||
Switch {
|
|
||||||
position: root.actionState ? root.actionState : 0
|
|
||||||
onClicked: {
|
|
||||||
var params = [];
|
|
||||||
var param1 = new Object();
|
|
||||||
param1["paramTypeId"] = root.actionType.paramTypes.get(0).id;
|
|
||||||
param1["value"] = checked;
|
|
||||||
params.push(param1)
|
|
||||||
root.executeAction(params)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,55 +0,0 @@
|
|||||||
import QtQuick 2.5
|
|
||||||
import QtQuick.Controls.Material 2.1
|
|
||||||
import "../components"
|
|
||||||
|
|
||||||
ActionDelegateBase {
|
|
||||||
id: root
|
|
||||||
height: 200
|
|
||||||
|
|
||||||
onActionStateChanged: {
|
|
||||||
if (actionState && !colorPicker.pressed) {
|
|
||||||
colorPicker.color = actionState
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorPicker {
|
|
||||||
id: colorPicker
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: app.margins
|
|
||||||
color: root.actionState ? root.actionState : "white"
|
|
||||||
touchDelegate: Rectangle {
|
|
||||||
height: 15
|
|
||||||
width: height
|
|
||||||
radius: height / 2
|
|
||||||
color: Material.accent
|
|
||||||
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
color: colorPicker.hovered || colorPicker.pressed ? "#11000000" : "transparent"
|
|
||||||
anchors.centerIn: parent
|
|
||||||
height: 30
|
|
||||||
width: height
|
|
||||||
radius: width / 2
|
|
||||||
Behavior on color {
|
|
||||||
ColorAnimation {
|
|
||||||
duration: 200
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
property var lastSentTime: new Date()
|
|
||||||
onColorChanged: {
|
|
||||||
var currentTime = new Date();
|
|
||||||
if (pressed && currentTime - lastSentTime > 200) {
|
|
||||||
var params = [];
|
|
||||||
var param1 = new Object();
|
|
||||||
param1["paramTypeId"] = root.actionType.paramTypes.get(0).id;
|
|
||||||
param1["value"] = color;
|
|
||||||
params.push(param1)
|
|
||||||
root.executeAction(params)
|
|
||||||
lastSentTime = currentTime
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
import QtQuick 2.5
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
|
|
||||||
ActionDelegateBase {
|
|
||||||
id: root
|
|
||||||
height: columnLayout.height + app.margins * 2
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: columnLayout
|
|
||||||
anchors { left: parent.left; right: parent.right; top: parent.top; margins: app.margins }
|
|
||||||
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: actionType.displayName
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: qsTr("Note: This action type has not been implemented yet")
|
|
||||||
font.pixelSize: app.smallFont
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
import QtQuick 2.5
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
|
|
||||||
ActionDelegateBase {
|
|
||||||
id: root
|
|
||||||
height: layout.height + app.margins * 2
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: layout
|
|
||||||
anchors { left: parent.left; right: parent.right; top: parent.top; margins: app.margins }
|
|
||||||
Label {
|
|
||||||
text: root.actionType.displayName
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: qsTr("Do it!")
|
|
||||||
onClicked: root.executeAction([])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
import QtQuick 2.5
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
|
|
||||||
ActionDelegateBase {
|
|
||||||
id: root
|
|
||||||
height: columnLayout.height + app.margins
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: columnLayout
|
|
||||||
anchors { left: parent.left; right: parent.right; top: parent.top; margins: app.margins }
|
|
||||||
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: root.actionType.paramTypes.get(0).displayName
|
|
||||||
}
|
|
||||||
|
|
||||||
Slider {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
from: root.actionType ? root.actionType.paramTypes.get(0).minValue : 0
|
|
||||||
to: root.actionType ? root.actionType.paramTypes.get(0).maxValue : 100000000
|
|
||||||
value: root.actionState
|
|
||||||
onValueChanged: {
|
|
||||||
if (pressed) {
|
|
||||||
var params = [];
|
|
||||||
var param1 = {};
|
|
||||||
param1["paramTypeId"] = root.actionType.paramTypes.get(0).id;
|
|
||||||
param1["value"] = value;
|
|
||||||
params.push(param1)
|
|
||||||
root.executeAction(params)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
import QtQuick 2.5
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
|
|
||||||
ActionDelegateBase {
|
|
||||||
id: root
|
|
||||||
height: layout.height + app.margins * 2
|
|
||||||
|
|
||||||
property var paramType: actionType.paramTypes.get(0)
|
|
||||||
RowLayout {
|
|
||||||
id: layout
|
|
||||||
anchors { left: parent.left; top: parent.top; right: parent.right; margins: app.margins }
|
|
||||||
Label {
|
|
||||||
text: root.paramType.displayName
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
ComboBox {
|
|
||||||
model: root.paramType.allowedValues
|
|
||||||
currentIndex: root.paramType.allowedValues.indexOf(root.actionState)
|
|
||||||
onActivated: {
|
|
||||||
if (root.actionState === root.paramType.allowedValues[index]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var params = [];
|
|
||||||
var param1 = {};
|
|
||||||
param1["paramTypeId"] = root.paramType.id;
|
|
||||||
param1["value"] = root.paramType.allowedValues[index];
|
|
||||||
params.push(param1);
|
|
||||||
root.executeAction(params)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -3,109 +3,33 @@ import QtQuick.Controls 2.1
|
|||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import Mea 1.0
|
import Mea 1.0
|
||||||
import "../components"
|
import "../components"
|
||||||
|
import "../customviews"
|
||||||
|
|
||||||
DevicePageBase {
|
GenericDevicePage {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
header: GuhHeader {
|
|
||||||
text: device.name
|
|
||||||
onBackPressed: {
|
|
||||||
print("popping")
|
|
||||||
pageStack.pop()
|
|
||||||
}
|
|
||||||
|
|
||||||
HeaderButton {
|
GenericTypeLogView {
|
||||||
imageSource: "../images/info.svg"
|
anchors.fill: parent
|
||||||
onClicked: pageStack.push(Qt.resolvedUrl("GenericDeviceStateDetailsPage.qml"), {device: root.device})
|
text: qsTr("This button has been pressed %1 times in the last 24 hours.")
|
||||||
}
|
device: root.device
|
||||||
}
|
typeId: root.deviceClass.eventTypes.findByName("pressed").id
|
||||||
|
|
||||||
ColumnLayout {
|
onAddRuleClicked: {
|
||||||
anchors { fill: parent }
|
var rule = Engine.ruleManager.createNewRule();
|
||||||
spacing: app.margins
|
var eventDescriptor = rule.eventDescriptors.createNewEventDescriptor();
|
||||||
Label {
|
eventDescriptor.deviceId = device.id;
|
||||||
Layout.fillWidth: true
|
var eventType = root.deviceClass.eventTypes.findByName("pressed");
|
||||||
Layout.margins: app.margins
|
eventDescriptor.eventTypeId = eventType.id;
|
||||||
text: qsTr("When this switch is pressed...")
|
rule.name = root.device.name + " - " + eventType.displayName;
|
||||||
visible: actionListView.count > 0
|
if (eventType.paramTypes.count === 1) {
|
||||||
}
|
var paramType = eventType.paramTypes.get(0);
|
||||||
|
eventDescriptor.paramDescriptors.setParamDescriptor(paramType.id, value, ParamDescriptor.ValueOperatorEquals);
|
||||||
ListView {
|
rule.eventDescriptors.addEventDescriptor(eventDescriptor);
|
||||||
id: actionListView
|
rule.name = rule.name + " - " + value
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
model: RulesFilterModel {
|
|
||||||
id: rulesFilterModel
|
|
||||||
rules: Engine.ruleManager.rules
|
|
||||||
filterDeviceId: root.device.id
|
|
||||||
}
|
|
||||||
delegate: SwipeDelegate {
|
|
||||||
width: parent.width
|
|
||||||
property var ruleActions: rulesFilterModel.get(index).actions
|
|
||||||
property var ruleAction: ruleActions.count === 1 ? ruleActions.get(0) : null
|
|
||||||
property var ruleActionType: ruleAction ? ruleActionDeviceClass.actionTypes.getActionType(ruleAction.actionTypeId) : null
|
|
||||||
property var ruleActionDevice: ruleAction ? Engine.deviceManager.devices.getDevice(ruleAction.deviceId) : null
|
|
||||||
property var ruleActionDeviceClass: ruleActionDevice ? Engine.deviceManager.deviceClasses.getDeviceClass(ruleActionDevice.deviceClassId) : null
|
|
||||||
property var ruleActionParams: ruleAction && ruleAction ? ruleAction.ruleActionParams : null
|
|
||||||
property var ruleActionParam: ruleActionParams.count === 1 ? ruleActionParams.get(0) : null
|
|
||||||
text: {
|
|
||||||
if (ruleActions && ruleActions.count > 1) {
|
|
||||||
return qsTr("Multiple actions");
|
|
||||||
} else if (ruleActionParam) {
|
|
||||||
return qsTr("%1: Set %2 to %3").arg(ruleActionDevice.name).arg(ruleActionType.name).arg(ruleActionParam.value)
|
|
||||||
} else {
|
|
||||||
return qsTr("%1: Call %2").arg(ruleActionDevice.name).arg(ruleActionType.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
swipe.right: MouseArea {
|
|
||||||
anchors.right: parent.right
|
|
||||||
height: parent.height
|
|
||||||
width: height
|
|
||||||
ColorIcon {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: app.margins
|
|
||||||
name: "../images/delete.svg"
|
|
||||||
color: "red"
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
Engine.ruleManager.removeRule(rulesFilterModel.get(index).id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
width: parent.width - (app.margins * 2)
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: qsTr("No actions configured for this switch. You may add some actions for this switch by using the \"Add action\" button at the bottom.")
|
|
||||||
visible: actionListView.count == 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.margins: app.margins
|
|
||||||
text: qsTr("Add an action")
|
|
||||||
onClicked: {
|
|
||||||
var page = pageStack.push(Qt.resolvedUrl("../magic/SelectActionPage.qml"), {text: qsTr("When this switch is pressed...")});
|
|
||||||
page.complete.connect(function() {
|
|
||||||
print("have action:", page.device, page.actionType, page.params)
|
|
||||||
var rule = {};
|
|
||||||
rule["name"] = root.device.name + " pressed"
|
|
||||||
var events = [];
|
|
||||||
var event = {};
|
|
||||||
event["deviceId"] = root.device.id;
|
|
||||||
var eventDeviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(root.device.deviceClassId)
|
|
||||||
event["eventTypeId"] = eventDeviceClass.eventTypes.findByName("pressed").id;
|
|
||||||
events.push(event);
|
|
||||||
rule["eventDescriptors"] = events;
|
|
||||||
rule["actions"] = page.actions;
|
|
||||||
Engine.ruleManager.addRule(rule);
|
|
||||||
pageStack.pop(root)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
var rulePage = pageStack.push(Qt.resolvedUrl("../magic/DeviceRulesPage.qml"), {device: root.device});
|
||||||
|
rulePage.addRule(rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import QtQuick.Controls 2.1
|
|||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
import Mea 1.0
|
import Mea 1.0
|
||||||
import "../components"
|
import "../components"
|
||||||
import "../paramdelegates-ng"
|
import "../delegates"
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
id: root
|
id: root
|
||||||
|
|||||||
@ -97,33 +97,7 @@ DevicePageBase {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
property var actionType: deviceClass.actionTypes.get(index)
|
property var actionType: deviceClass.actionTypes.get(index)
|
||||||
property var actionValue: device.hasState(actionType.id) ? device.states.getState(actionType.id).value : null
|
property var actionValue: device.hasState(actionType.id) ? device.states.getState(actionType.id).value : null
|
||||||
source: {
|
source: Qt.resolvedUrl("../delegates/ActionDelegate.qml")
|
||||||
print("actiontype is", actionType.name, actionValue, actionType.paramTypes.count)
|
|
||||||
for (var i = 0; i < actionType.paramTypes.count; i++) {
|
|
||||||
print("have actionType param:", actionType.paramTypes.get(i).name, actionType.paramTypes.get(i).type)
|
|
||||||
}
|
|
||||||
|
|
||||||
return Qt.resolvedUrl("../actiondelegates-ng/ActionDelegate.qml");
|
|
||||||
var delegate = "ActionDelegateFallback.qml";
|
|
||||||
if (actionType.paramTypes.count === 0) {
|
|
||||||
delegate = "ActionDelegateNoParams.qml";
|
|
||||||
} else if (actionType.paramTypes.count === 1) {
|
|
||||||
var paramType = actionType.paramTypes.get(0)
|
|
||||||
if (paramType.type === "Int" && paramType.minValue !== null && paramType.maxValue !== null) {
|
|
||||||
delegate = "ActionDelegateSlider.qml";
|
|
||||||
} else if (paramType.type === "Bool") {
|
|
||||||
delegate = "ActionDelegateBool.qml";
|
|
||||||
} else if (paramType.type === "Color") {
|
|
||||||
delegate = "ActionDelegateColor.qml";
|
|
||||||
} else if (paramType.type === "String" && paramType.allowedValues.length > 0) {
|
|
||||||
delegate = "ActionDelegateStringFromStringList.qml";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return Qt.resolvedUrl("../actiondelegates/" + delegate);
|
|
||||||
}
|
|
||||||
|
|
||||||
Binding {
|
Binding {
|
||||||
target: delegateLoader.item ? delegateLoader.item : null
|
target: delegateLoader.item ? delegateLoader.item : null
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import QtQuick.Controls 2.1
|
|||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import Mea 1.0
|
import Mea 1.0
|
||||||
import "../components"
|
import "../components"
|
||||||
import "../paramdelegates"
|
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
id: root
|
id: root
|
||||||
|
|||||||
@ -1,94 +0,0 @@
|
|||||||
import QtQuick 2.4
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
import "../components"
|
|
||||||
import Mea 1.0
|
|
||||||
|
|
||||||
Page {
|
|
||||||
id: root
|
|
||||||
property alias text: header.text
|
|
||||||
property var device: null
|
|
||||||
readonly property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
|
|
||||||
|
|
||||||
header: GuhHeader {
|
|
||||||
id: header
|
|
||||||
onBackPressed: pageStack.pop()
|
|
||||||
}
|
|
||||||
|
|
||||||
ListModel {
|
|
||||||
id: eventModel
|
|
||||||
ListElement { interfaceName: "temperaturesensor"; text: qsTr("When it's freezing..."); identifier: "freeze"}
|
|
||||||
ListElement { interfaceName: "battery"; text: qsTr("When the device runs out of battery..."); identifier: "lowBattery"}
|
|
||||||
ListElement { interfaceName: "weather"; text: qsTr("When it starts raining..."); identifier: "rain" }
|
|
||||||
ListElement { interfaceName: "weather"; text: qsTr("When it's freezing..."); identifier: "freeze"}
|
|
||||||
}
|
|
||||||
|
|
||||||
ListModel {
|
|
||||||
id: actionModel
|
|
||||||
ListElement { interfaceName: "light"; text: qsTr("Switch light when..."); identifier: "switchLight"}
|
|
||||||
ListElement { interfaceName: "dimmablelight"; text: qsTr("Dim light when..."); identifier: "dimLight"}
|
|
||||||
ListElement { interfaceName: "colorlight"; text: qsTr("Set light color when..."); identifier: "colorLight" }
|
|
||||||
ListElement { interfaceName: "mediacontroller"; text: qsTr("Pause playback when..."); identifier: "pausePlayback" }
|
|
||||||
ListElement { interfaceName: "mediacontroller"; text: qsTr("Resume playback when..."); identifier: "resumePlayback" }
|
|
||||||
ListElement { interfaceName: "extendedvolumecontroller"; text: qsTr("Set volume..."); identifier: "setVolume" }
|
|
||||||
ListElement { interfaceName: "extendedvolumecontroller"; text: qsTr("Mute when..."); identifier: "mute" }
|
|
||||||
ListElement { interfaceName: "extendedvolumecontroller"; text: qsTr("Unmute when..."); identifier: "unmute" }
|
|
||||||
ListElement { interfaceName: "notifications"; text: qsTr("Notify me when..."); identifier: "notify" }
|
|
||||||
}
|
|
||||||
|
|
||||||
function entrySelected(identifier) {
|
|
||||||
switch (identifier) {
|
|
||||||
case "freeze":
|
|
||||||
var page = pageStack.push(Qt.resolvedUrl("SelectActionPage.qml"), {device: root.device })
|
|
||||||
page.complete.connect(function() {
|
|
||||||
print("have action:", page.actions.length)
|
|
||||||
var rule = {};
|
|
||||||
rule["name"] = "Freeze in " + root.device.name
|
|
||||||
var stateEvaluator = {};
|
|
||||||
var stateDescriptor = {};
|
|
||||||
stateDescriptor["deviceId"] = root.device.id;
|
|
||||||
stateDescriptor["operator"] = "ValueOperatorLessOrEqual";
|
|
||||||
stateDescriptor["stateTypeId"] = root.deviceClass.stateTypes.findByName("temperature").id;
|
|
||||||
stateDescriptor["value"] = 0;
|
|
||||||
stateEvaluator["stateDescriptor"] = stateDescriptor;
|
|
||||||
|
|
||||||
rule["stateEvaluator"] = stateEvaluator;
|
|
||||||
rule["actions"] = page.actions;
|
|
||||||
Engine.ruleManager.addRule(rule);
|
|
||||||
pageStack.pop(root);
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onDeviceClassChanged: {
|
|
||||||
actualModel.clear()
|
|
||||||
print("device supports interfaces", deviceClass.interfaces)
|
|
||||||
for (var i = 0; i < eventModel.count; i++) {
|
|
||||||
print("event is for interface", eventModel.get(i).interfaceName)
|
|
||||||
if (deviceClass.interfaces.indexOf(eventModel.get(i).interfaceName) >= 0) {
|
|
||||||
actualModel.append(eventModel.get(i))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print("huh")
|
|
||||||
for (var i = 0; i < actionModel.count; i++) {
|
|
||||||
print("action is for interface", actionModel.get(i).interfaceName)
|
|
||||||
if (deviceClass.interfaces.indexOf(actionModel.get(i).interfaceName) >= 0) {
|
|
||||||
actualModel.append(actionModel.get(i))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ListView {
|
|
||||||
anchors.fill: parent
|
|
||||||
model: ListModel {
|
|
||||||
id: actualModel
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: ItemDelegate {
|
|
||||||
width: parent.width
|
|
||||||
text: model.text
|
|
||||||
|
|
||||||
onClicked: root.entrySelected(model.identifier)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -42,7 +42,7 @@ Page {
|
|||||||
Layout.rightMargin: app.margins
|
Layout.rightMargin: app.margins
|
||||||
}
|
}
|
||||||
|
|
||||||
ParamDescriptorDelegateBase {
|
ParamDescriptorDelegate {
|
||||||
id: paramDescriptorDelegate
|
id: paramDescriptorDelegate
|
||||||
enabled: paramCheckBox.checked
|
enabled: paramCheckBox.checked
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import QtQuick 2.8
|
|||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.1
|
||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
import "../components"
|
import "../components"
|
||||||
import "../paramdelegates-ng"
|
import "../delegates"
|
||||||
import Mea 1.0
|
import Mea 1.0
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ Page {
|
|||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
ParamDescriptorDelegateBase {
|
ParamDescriptorDelegate {
|
||||||
id: paramDelegate
|
id: paramDelegate
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
paramType: root.stateType
|
paramType: root.stateType
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
import QtQuick 2.8
|
|
||||||
import QtQuick.Layouts 1.2
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
|
|
||||||
ParamDelegateBase {
|
|
||||||
id: root
|
|
||||||
contentItem: RowLayout {
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: label
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: root.paramType.displayName + "- " + root.value
|
|
||||||
}
|
|
||||||
Switch {
|
|
||||||
id: theSwitch
|
|
||||||
checked: root.value == true
|
|
||||||
onClicked: root.value = checked
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
import QtQuick 2.8
|
|
||||||
import QtQuick.Layouts 1.2
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
|
|
||||||
ParamDelegateBase {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
contentItem: RowLayout {
|
|
||||||
width: parent.width
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: label
|
|
||||||
text: root.paramType.displayName
|
|
||||||
}
|
|
||||||
TextField {
|
|
||||||
id: textField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: root.value ? root.value : root.paramType.defaultValue
|
|
||||||
onTextChanged: {
|
|
||||||
root.value = text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
import QtQuick 2.8
|
|
||||||
import QtQuick.Layouts 1.2
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
|
|
||||||
ParamDelegateBase {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
contentItem: RowLayout {
|
|
||||||
width: parent.width
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: label
|
|
||||||
text: root.paramType.displayName
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
TextField {
|
|
||||||
id: textField
|
|
||||||
text: root.value ? root.value : root.paramType.defaultValue
|
|
||||||
Layout.preferredWidth: implicitWidth
|
|
||||||
onTextChanged: {
|
|
||||||
root.value = text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
import QtQuick 2.8
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
|
|
||||||
Loader {
|
|
||||||
id: loader
|
|
||||||
|
|
||||||
property var paramType: null
|
|
||||||
property var value: null
|
|
||||||
source: {
|
|
||||||
var comp;
|
|
||||||
switch (loader.paramType.type) {
|
|
||||||
case "bool":
|
|
||||||
case "Bool":
|
|
||||||
comp = "Bool";
|
|
||||||
break;
|
|
||||||
case "String":
|
|
||||||
comp = "String";
|
|
||||||
break;
|
|
||||||
case "Int":
|
|
||||||
comp = "Int";
|
|
||||||
break;
|
|
||||||
case "Double":
|
|
||||||
comp = "Double";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
print("unhandled param type:", paramType.type)
|
|
||||||
}
|
|
||||||
return Qt.resolvedUrl(comp + "ParamDelegate.qml")
|
|
||||||
}
|
|
||||||
|
|
||||||
onStatusChanged: {
|
|
||||||
if (status == Loader.Ready) {
|
|
||||||
loader.item.value = root.value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Binding {
|
|
||||||
target: loader.item
|
|
||||||
when: loader.item
|
|
||||||
property: "paramType"
|
|
||||||
value: loader.paramType
|
|
||||||
}
|
|
||||||
|
|
||||||
Binding {
|
|
||||||
target: loader
|
|
||||||
when: loader.item
|
|
||||||
property: "value"
|
|
||||||
value: loader.item.value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
import QtQuick 2.4
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
|
|
||||||
ItemDelegate {
|
|
||||||
|
|
||||||
property var paramType: null
|
|
||||||
property var value: null
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
import QtQuick 2.8
|
|
||||||
import QtQuick.Layouts 1.2
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
|
|
||||||
ParamDelegateBase {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
contentItem: RowLayout {
|
|
||||||
width: parent.width
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: label
|
|
||||||
text: root.paramType.name
|
|
||||||
}
|
|
||||||
TextField {
|
|
||||||
id: textField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: root.value ? root.value : root.paramType.defaultValue
|
|
||||||
onTextChanged: {
|
|
||||||
root.value = text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -3,7 +3,7 @@ import QtQuick.Controls 2.1
|
|||||||
import QtQuick.Controls.Material 2.1
|
import QtQuick.Controls.Material 2.1
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import "../components"
|
import "../components"
|
||||||
import "../paramdelegates-ng"
|
import "../delegates"
|
||||||
import Mea 1.0
|
import Mea 1.0
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
|
|||||||
Reference in New Issue
Block a user