From 425572b3c7d233e82dd0656f97e2ea6358c130f2 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Fri, 25 May 2018 13:01:50 +0200 Subject: [PATCH] drop old delegates, clean up some stuff --- mea/resources.qrc | 20 +-- mea/ui/NewDeviceWizard.qml | 2 +- mea/ui/actiondelegates/ActionDelegateBase.qml | 10 -- mea/ui/actiondelegates/ActionDelegateBool.qml | 31 ----- .../actiondelegates/ActionDelegateColor.qml | 55 -------- .../ActionDelegateFallback.qml | 23 ---- .../ActionDelegateNoParams.qml | 21 ---- .../actiondelegates/ActionDelegateSlider.qml | 35 ------ .../ActionDelegateStringFromStringList.qml | 34 ----- .../ActionDelegate.qml | 0 .../ParamDelegate.qml | 0 .../ParamDescriptorDelegate.qml} | 0 mea/ui/devicepages/ButtonDevicePage.qml | 118 ++++-------------- mea/ui/devicepages/ConfigureThingPage.qml | 2 +- mea/ui/devicepages/GenericDevicePage.qml | 28 +---- .../GenericDeviceStateDetailsPage.qml | 1 - mea/ui/magic/NewThingMagicPage.qml | 94 -------------- .../magic/SelectEventDescriptorParamsPage.qml | 2 +- mea/ui/magic/SelectRuleActionParamsPage.qml | 2 +- .../magic/SelectStateDescriptorParamsPage.qml | 2 +- mea/ui/paramdelegates/BoolParamDelegate.qml | 21 ---- mea/ui/paramdelegates/DoubleParamDelegate.qml | 24 ---- mea/ui/paramdelegates/IntParamDelegate.qml | 25 ---- mea/ui/paramdelegates/ParamDelegate.qml | 50 -------- mea/ui/paramdelegates/ParamDelegateBase.qml | 9 -- mea/ui/paramdelegates/StringParamDelegate.qml | 24 ---- mea/ui/system/PluginParamsPage.qml | 2 +- 27 files changed, 31 insertions(+), 604 deletions(-) delete mode 100644 mea/ui/actiondelegates/ActionDelegateBase.qml delete mode 100644 mea/ui/actiondelegates/ActionDelegateBool.qml delete mode 100644 mea/ui/actiondelegates/ActionDelegateColor.qml delete mode 100644 mea/ui/actiondelegates/ActionDelegateFallback.qml delete mode 100644 mea/ui/actiondelegates/ActionDelegateNoParams.qml delete mode 100644 mea/ui/actiondelegates/ActionDelegateSlider.qml delete mode 100644 mea/ui/actiondelegates/ActionDelegateStringFromStringList.qml rename mea/ui/{actiondelegates-ng => delegates}/ActionDelegate.qml (100%) rename mea/ui/{paramdelegates-ng => delegates}/ParamDelegate.qml (100%) rename mea/ui/{paramdescriptordelegates/ParamDescriptorDelegateBase.qml => delegates/ParamDescriptorDelegate.qml} (100%) delete mode 100644 mea/ui/magic/NewThingMagicPage.qml delete mode 100644 mea/ui/paramdelegates/BoolParamDelegate.qml delete mode 100644 mea/ui/paramdelegates/DoubleParamDelegate.qml delete mode 100644 mea/ui/paramdelegates/IntParamDelegate.qml delete mode 100644 mea/ui/paramdelegates/ParamDelegate.qml delete mode 100644 mea/ui/paramdelegates/ParamDelegateBase.qml delete mode 100644 mea/ui/paramdelegates/StringParamDelegate.qml diff --git a/mea/resources.qrc b/mea/resources.qrc index 734e6b88..d920b536 100644 --- a/mea/resources.qrc +++ b/mea/resources.qrc @@ -5,21 +5,14 @@ ui/main.qml ui/NewDeviceWizard.qml ui/SettingsPage.qml - ui/actiondelegates/ActionDelegateBase.qml - ui/actiondelegates/ActionDelegateBool.qml - ui/actiondelegates/ActionDelegateSlider.qml ui/components/GuhHeader.qml ui/components/HeaderButton.qml ui/images/add.svg ui/images/back.svg ui/images/close.svg ui/MainPage.qml - ui/actiondelegates/ActionDelegateFallback.qml ui/images/info.svg - ui/actiondelegates/ActionDelegateColor.qml ui/components/ColorPicker.qml - ui/actiondelegates/ActionDelegateNoParams.qml - ui/actiondelegates/ActionDelegateStringFromStringList.qml ui/customviews/CustomViewBase.qml ui/customviews/WeatherView.qml ui/customviews/MediaControllerView.qml @@ -49,7 +42,6 @@ ui/images/media-seek-forward.svg ui/images/media-skip-backward.svg ui/images/media-skip-forward.svg - ui/paramdelegates/BoolParamDelegate.qml ui/components/ThinDivider.qml ui/images/weather-app-symbolic.svg ui/images/weathericons/weather-clear-day.svg @@ -81,11 +73,7 @@ ui/images/sensors.svg ui/images/temperature.svg ui/images/network-wired-symbolic.svg - ui/paramdelegates/StringParamDelegate.qml - ui/paramdelegates/ParamDelegate.qml - ui/paramdelegates/ParamDelegateBase.qml ui/images/notification.svg - ui/paramdelegates/IntParamDelegate.qml ui/customviews/NotificationsView.qml ui/devicepages/DevicePageBase.qml ui/images/battery/battery-000.svg @@ -104,7 +92,6 @@ ui/EditDevicesPage.qml ui/devicepages/ConfigureThingPage.qml ui/magic/DeviceRulesPage.qml - ui/magic/NewThingMagicPage.qml ui/magic/EditRulePage.qml ui/magic/SelectThingPage.qml ui/magic/ComposeEventDescriptorPage.qml @@ -115,14 +102,14 @@ ui/images/tick.svg ui/magic/SelectEventDescriptorParamsPage.qml ui/magic/SelectEventDescriptorPage.qml - ui/paramdelegates/DoubleParamDelegate.qml - ui/paramdescriptordelegates/ParamDescriptorDelegateBase.qml + ui/delegates/ParamDescriptorDelegate.qml + ui/delegates/ParamDelegate.qml + ui/delegates/ActionDelegate.qml ui/system/LogViewerPage.qml ui/images/next.svg ui/images/go-down.svg ui/system/PluginsPage.qml ui/system/PluginParamsPage.qml - ui/paramdelegates-ng/ParamDelegate.qml ui/components/ErrorDialog.qml ui/fonts/Ubuntu-B.ttf ui/fonts/Ubuntu-BI.ttf @@ -136,7 +123,6 @@ ui/components/InterfacesModels.qml ui/magic/StateEvaluatorDelegate.qml ui/magic/EditStateEvaluatorPage.qml - ui/actiondelegates-ng/ActionDelegate.qml ui/magic/SimpleStateEvaluatorDelegate.qml ui/magic/SelectStateDescriptorParamsPage.qml ui/magic/SelectStateDescriptorPage.qml diff --git a/mea/ui/NewDeviceWizard.qml b/mea/ui/NewDeviceWizard.qml index 06774f1e..79341c05 100644 --- a/mea/ui/NewDeviceWizard.qml +++ b/mea/ui/NewDeviceWizard.qml @@ -3,7 +3,7 @@ import QtQuick.Layouts 1.1 import QtQuick.Controls 2.1 import Mea 1.0 import "components" -import "paramdelegates-ng" +import "delegates" Page { id: root diff --git a/mea/ui/actiondelegates/ActionDelegateBase.qml b/mea/ui/actiondelegates/ActionDelegateBase.qml deleted file mode 100644 index 761faf1c..00000000 --- a/mea/ui/actiondelegates/ActionDelegateBase.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.5 - - -Item { - id: root - property var actionType: null - property var actionState: null - - signal executeAction(var params) -} diff --git a/mea/ui/actiondelegates/ActionDelegateBool.qml b/mea/ui/actiondelegates/ActionDelegateBool.qml deleted file mode 100644 index 1a931126..00000000 --- a/mea/ui/actiondelegates/ActionDelegateBool.qml +++ /dev/null @@ -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) - } - } - } -} diff --git a/mea/ui/actiondelegates/ActionDelegateColor.qml b/mea/ui/actiondelegates/ActionDelegateColor.qml deleted file mode 100644 index 6f5d7a9e..00000000 --- a/mea/ui/actiondelegates/ActionDelegateColor.qml +++ /dev/null @@ -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 - } - } - } -} diff --git a/mea/ui/actiondelegates/ActionDelegateFallback.qml b/mea/ui/actiondelegates/ActionDelegateFallback.qml deleted file mode 100644 index 3d643ada..00000000 --- a/mea/ui/actiondelegates/ActionDelegateFallback.qml +++ /dev/null @@ -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 - } - } -} diff --git a/mea/ui/actiondelegates/ActionDelegateNoParams.qml b/mea/ui/actiondelegates/ActionDelegateNoParams.qml deleted file mode 100644 index bcec8ab0..00000000 --- a/mea/ui/actiondelegates/ActionDelegateNoParams.qml +++ /dev/null @@ -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([]) - } - } -} diff --git a/mea/ui/actiondelegates/ActionDelegateSlider.qml b/mea/ui/actiondelegates/ActionDelegateSlider.qml deleted file mode 100644 index 826ca616..00000000 --- a/mea/ui/actiondelegates/ActionDelegateSlider.qml +++ /dev/null @@ -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) - } - } - } - } -} diff --git a/mea/ui/actiondelegates/ActionDelegateStringFromStringList.qml b/mea/ui/actiondelegates/ActionDelegateStringFromStringList.qml deleted file mode 100644 index a71cb3d5..00000000 --- a/mea/ui/actiondelegates/ActionDelegateStringFromStringList.qml +++ /dev/null @@ -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) - } - } - } -} diff --git a/mea/ui/actiondelegates-ng/ActionDelegate.qml b/mea/ui/delegates/ActionDelegate.qml similarity index 100% rename from mea/ui/actiondelegates-ng/ActionDelegate.qml rename to mea/ui/delegates/ActionDelegate.qml diff --git a/mea/ui/paramdelegates-ng/ParamDelegate.qml b/mea/ui/delegates/ParamDelegate.qml similarity index 100% rename from mea/ui/paramdelegates-ng/ParamDelegate.qml rename to mea/ui/delegates/ParamDelegate.qml diff --git a/mea/ui/paramdescriptordelegates/ParamDescriptorDelegateBase.qml b/mea/ui/delegates/ParamDescriptorDelegate.qml similarity index 100% rename from mea/ui/paramdescriptordelegates/ParamDescriptorDelegateBase.qml rename to mea/ui/delegates/ParamDescriptorDelegate.qml diff --git a/mea/ui/devicepages/ButtonDevicePage.qml b/mea/ui/devicepages/ButtonDevicePage.qml index c2de5725..7a754b51 100644 --- a/mea/ui/devicepages/ButtonDevicePage.qml +++ b/mea/ui/devicepages/ButtonDevicePage.qml @@ -3,109 +3,33 @@ import QtQuick.Controls 2.1 import QtQuick.Layouts 1.1 import Mea 1.0 import "../components" +import "../customviews" -DevicePageBase { +GenericDevicePage { id: root - header: GuhHeader { - text: device.name - onBackPressed: { - print("popping") - pageStack.pop() - } - HeaderButton { - imageSource: "../images/info.svg" - onClicked: pageStack.push(Qt.resolvedUrl("GenericDeviceStateDetailsPage.qml"), {device: root.device}) - } - } + GenericTypeLogView { + anchors.fill: parent + 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 { - anchors { fill: parent } - spacing: app.margins - Label { - Layout.fillWidth: true - Layout.margins: app.margins - text: qsTr("When this switch is pressed...") - visible: actionListView.count > 0 - } - - ListView { - id: actionListView - 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) - }) + onAddRuleClicked: { + var rule = Engine.ruleManager.createNewRule(); + var eventDescriptor = rule.eventDescriptors.createNewEventDescriptor(); + eventDescriptor.deviceId = device.id; + var eventType = root.deviceClass.eventTypes.findByName("pressed"); + eventDescriptor.eventTypeId = eventType.id; + rule.name = root.device.name + " - " + eventType.displayName; + if (eventType.paramTypes.count === 1) { + var paramType = eventType.paramTypes.get(0); + eventDescriptor.paramDescriptors.setParamDescriptor(paramType.id, value, ParamDescriptor.ValueOperatorEquals); + rule.eventDescriptors.addEventDescriptor(eventDescriptor); + rule.name = rule.name + " - " + value } + var rulePage = pageStack.push(Qt.resolvedUrl("../magic/DeviceRulesPage.qml"), {device: root.device}); + rulePage.addRule(rule); } } } diff --git a/mea/ui/devicepages/ConfigureThingPage.qml b/mea/ui/devicepages/ConfigureThingPage.qml index 33668734..c5dff614 100644 --- a/mea/ui/devicepages/ConfigureThingPage.qml +++ b/mea/ui/devicepages/ConfigureThingPage.qml @@ -3,7 +3,7 @@ import QtQuick.Controls 2.1 import QtQuick.Layouts 1.2 import Mea 1.0 import "../components" -import "../paramdelegates-ng" +import "../delegates" Page { id: root diff --git a/mea/ui/devicepages/GenericDevicePage.qml b/mea/ui/devicepages/GenericDevicePage.qml index c08687d5..874b2454 100644 --- a/mea/ui/devicepages/GenericDevicePage.qml +++ b/mea/ui/devicepages/GenericDevicePage.qml @@ -97,33 +97,7 @@ DevicePageBase { width: parent.width property var actionType: deviceClass.actionTypes.get(index) property var actionValue: device.hasState(actionType.id) ? device.states.getState(actionType.id).value : null - source: { - 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); - } + source: Qt.resolvedUrl("../delegates/ActionDelegate.qml") Binding { target: delegateLoader.item ? delegateLoader.item : null diff --git a/mea/ui/devicepages/GenericDeviceStateDetailsPage.qml b/mea/ui/devicepages/GenericDeviceStateDetailsPage.qml index 1a965799..3b06178d 100644 --- a/mea/ui/devicepages/GenericDeviceStateDetailsPage.qml +++ b/mea/ui/devicepages/GenericDeviceStateDetailsPage.qml @@ -3,7 +3,6 @@ import QtQuick.Controls 2.1 import QtQuick.Layouts 1.1 import Mea 1.0 import "../components" -import "../paramdelegates" Page { id: root diff --git a/mea/ui/magic/NewThingMagicPage.qml b/mea/ui/magic/NewThingMagicPage.qml deleted file mode 100644 index 04849fdd..00000000 --- a/mea/ui/magic/NewThingMagicPage.qml +++ /dev/null @@ -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) - } - } -} diff --git a/mea/ui/magic/SelectEventDescriptorParamsPage.qml b/mea/ui/magic/SelectEventDescriptorParamsPage.qml index 7dab50ac..3c2aac9e 100644 --- a/mea/ui/magic/SelectEventDescriptorParamsPage.qml +++ b/mea/ui/magic/SelectEventDescriptorParamsPage.qml @@ -42,7 +42,7 @@ Page { Layout.rightMargin: app.margins } - ParamDescriptorDelegateBase { + ParamDescriptorDelegate { id: paramDescriptorDelegate enabled: paramCheckBox.checked Layout.fillWidth: true diff --git a/mea/ui/magic/SelectRuleActionParamsPage.qml b/mea/ui/magic/SelectRuleActionParamsPage.qml index 4367a7e1..9829c847 100644 --- a/mea/ui/magic/SelectRuleActionParamsPage.qml +++ b/mea/ui/magic/SelectRuleActionParamsPage.qml @@ -2,7 +2,7 @@ import QtQuick 2.8 import QtQuick.Controls 2.1 import QtQuick.Layouts 1.2 import "../components" -import "../paramdelegates-ng" +import "../delegates" import Mea 1.0 Page { diff --git a/mea/ui/magic/SelectStateDescriptorParamsPage.qml b/mea/ui/magic/SelectStateDescriptorParamsPage.qml index 57430a11..c1e29bfa 100644 --- a/mea/ui/magic/SelectStateDescriptorParamsPage.qml +++ b/mea/ui/magic/SelectStateDescriptorParamsPage.qml @@ -23,7 +23,7 @@ Page { ColumnLayout { anchors.fill: parent - ParamDescriptorDelegateBase { + ParamDescriptorDelegate { id: paramDelegate Layout.fillWidth: true paramType: root.stateType diff --git a/mea/ui/paramdelegates/BoolParamDelegate.qml b/mea/ui/paramdelegates/BoolParamDelegate.qml deleted file mode 100644 index c95993a0..00000000 --- a/mea/ui/paramdelegates/BoolParamDelegate.qml +++ /dev/null @@ -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 - } - } -} - diff --git a/mea/ui/paramdelegates/DoubleParamDelegate.qml b/mea/ui/paramdelegates/DoubleParamDelegate.qml deleted file mode 100644 index b2928159..00000000 --- a/mea/ui/paramdelegates/DoubleParamDelegate.qml +++ /dev/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.displayName - } - TextField { - id: textField - Layout.fillWidth: true - text: root.value ? root.value : root.paramType.defaultValue - onTextChanged: { - root.value = text; - } - } - } -} diff --git a/mea/ui/paramdelegates/IntParamDelegate.qml b/mea/ui/paramdelegates/IntParamDelegate.qml deleted file mode 100644 index a11165ae..00000000 --- a/mea/ui/paramdelegates/IntParamDelegate.qml +++ /dev/null @@ -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; - } - } - } -} diff --git a/mea/ui/paramdelegates/ParamDelegate.qml b/mea/ui/paramdelegates/ParamDelegate.qml deleted file mode 100644 index d4551ed4..00000000 --- a/mea/ui/paramdelegates/ParamDelegate.qml +++ /dev/null @@ -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 - } -} diff --git a/mea/ui/paramdelegates/ParamDelegateBase.qml b/mea/ui/paramdelegates/ParamDelegateBase.qml deleted file mode 100644 index e3242a71..00000000 --- a/mea/ui/paramdelegates/ParamDelegateBase.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.4 -import QtQuick.Controls 2.1 - -ItemDelegate { - - property var paramType: null - property var value: null - -} diff --git a/mea/ui/paramdelegates/StringParamDelegate.qml b/mea/ui/paramdelegates/StringParamDelegate.qml deleted file mode 100644 index 43b745b0..00000000 --- a/mea/ui/paramdelegates/StringParamDelegate.qml +++ /dev/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; - } - } - } -} diff --git a/mea/ui/system/PluginParamsPage.qml b/mea/ui/system/PluginParamsPage.qml index cfee18c5..65560116 100644 --- a/mea/ui/system/PluginParamsPage.qml +++ b/mea/ui/system/PluginParamsPage.qml @@ -3,7 +3,7 @@ import QtQuick.Controls 2.1 import QtQuick.Controls.Material 2.1 import QtQuick.Layouts 1.3 import "../components" -import "../paramdelegates-ng" +import "../delegates" import Mea 1.0 Page {