From 991e25221f6ab791699c096bf86cf08708127949 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 4 Apr 2023 19:46:35 +0200 Subject: [PATCH] Handle inline controls for virtual switch and button --- nymea-app/ui/delegates/ThingTile.qml | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/nymea-app/ui/delegates/ThingTile.qml b/nymea-app/ui/delegates/ThingTile.qml index 24cbe5a1..216a8024 100644 --- a/nymea-app/ui/delegates/ThingTile.qml +++ b/nymea-app/ui/delegates/ThingTile.qml @@ -65,6 +65,15 @@ MainPageTile { return null } + // virtual switch + if (root.thing.thingClass.id == "{8ea0a168-74ff-4445-8c13-74aab195af4e}") { + return lightsComponent; + } + // virtual button + if (root.thing.thingClass.id == "{820b2f2d-0d92-48c8-8fd4-f94ce8fc4103}") { + return virtualButtonComponent; + } + for (var i = 0; i < root.thing.thingClass.interfaces.length; i++) { switch (root.thing.thingClass.interfaces[i]) { case "closable": @@ -142,6 +151,35 @@ MainPageTile { } } + Component { + id: virtualButtonComponent + RowLayout { + property Thing thing: null + + Item { + Layout.fillWidth: true + } + + ItemDelegate { + Layout.preferredWidth: Style.iconSize + Layout.preferredHeight: width + Layout.rightMargin: app.margins / 2 + Layout.alignment: Qt.AlignVCenter + padding: 0; topPadding: 0; bottomPadding: 0 + + contentItem: ColorIcon { + name: app.interfaceToIcon("power") + color: Style.iconColor + } + onClicked: { + var actionType = thing.thingClass.actionTypes.findByName("press"); + var params = []; + engine.thingManager.executeAction(thing.id, actionType.id, params); + } + } + } + } + Component { id: ventilationComponent RowLayout {