diff --git a/nymea-app/images.qrc b/nymea-app/images.qrc index afb8e2d4..a1cb016b 100644 --- a/nymea-app/images.qrc +++ b/nymea-app/images.qrc @@ -177,5 +177,8 @@ ui/images/network-wifi-offline.svg ui/images/network-wired-offline.svg ui/images/preferences-look-and-feel.svg + ui/images/sensors/closable.svg + ui/images/lock-closed.svg + ui/images/lock-open.svg diff --git a/nymea-app/ui/Nymea.qml b/nymea-app/ui/Nymea.qml index 96a9211c..9ce24790 100644 --- a/nymea-app/ui/Nymea.qml +++ b/nymea-app/ui/Nymea.qml @@ -170,6 +170,8 @@ ApplicationWindow { return Qt.resolvedUrl("images/sensors/light.svg") case "presencesensor": return Qt.resolvedUrl("images/sensors/presence.svg") + case "closablesensor": + return Qt.resolvedUrl("images/sensors/closable.svg") case "media": case "mediacontroller": return Qt.resolvedUrl("images/mediaplayer-app-symbolic.svg") @@ -210,7 +212,7 @@ ApplicationWindow { case "fingerprintreader": return Qt.resolvedUrl("images/fingerprint.svg") case "accesscontrol": - return Qt.resolvedUrl("images/network-secure.svg"); + return Qt.resolvedUrl("images/lock-closed.svg"); case "smartmeter": case "smartmeterconsumer": case "smartmeterproducer": @@ -244,6 +246,7 @@ ApplicationWindow { "co2sensor": "turquoise", "daylightsensor": "gold", "presencesensor": "darkblue", + "closablesensor": "green", "smartmeterproducer": "lightgreen", "smartmeterconsumer": "orange", "extendedsmartmeterproducer": "blue", diff --git a/nymea-app/ui/devicelistpages/SensorsDeviceListPage.qml b/nymea-app/ui/devicelistpages/SensorsDeviceListPage.qml index 4c7fd110..8ca43278 100644 --- a/nymea-app/ui/devicelistpages/SensorsDeviceListPage.qml +++ b/nymea-app/ui/devicelistpages/SensorsDeviceListPage.qml @@ -84,6 +84,7 @@ DeviceListPageBase { ListElement { interfaceName: "co2sensor"; stateName: "co2" } ListElement { interfaceName: "daylightsensor"; stateName: "daylight" } ListElement { interfaceName: "presencesensor"; stateName: "isPresent" } + ListElement { interfaceName: "closablesensor"; stateName: "closed" } ListElement { interfaceName: "heating"; stateName: "power" } ListElement { interfaceName: "thermostat"; stateName: "targetTemperature" } } @@ -100,24 +101,45 @@ DeviceListPageBase { Layout.preferredHeight: app.iconSize * .8 Layout.preferredWidth: height Layout.alignment: Qt.AlignVCenter - color: app.interfaceToColor(model.interfaceName) - name: app.interfaceToIcon(model.interfaceName) + color: { + switch (model.interfaceName) { + case "closablesensor": + return sensorValueDelegate.stateValue.value === true ? "green" : "red"; + default: + return app.interfaceToColor(model.interfaceName) + } + } + name: { + switch (model.interfaceName) { + case "closablesensor": + return sensorValueDelegate.stateValue.value === true ? Qt.resolvedUrl("../images/lock-closed.svg") : Qt.resolvedUrl("../images/lock-open.svg"); + default: + return app.interfaceToIcon(model.interfaceName) + } + } } Label { Layout.fillWidth: true - text: sensorValueDelegate.stateType && sensorValueDelegate.stateType.type.toLowerCase() === "bool" - ? sensorValueDelegate.stateType.displayName - : sensorValueDelegate.stateValue - ? "%1 %2".arg(Math.round(sensorValueDelegate.stateValue.value * 100) / 100).arg(sensorValueDelegate.stateType.unitString) - : "" + text: { + switch (model.interfaceName) { + case "closablesensor": + return sensorValueDelegate.stateValue.value === true ? qsTr("is closed") : qsTr("is open"); + default: + return sensorValueDelegate.stateType && sensorValueDelegate.stateType.type.toLowerCase() === "bool" + ? sensorValueDelegate.stateType.displayName + : sensorValueDelegate.stateValue + ? "%1 %2".arg(Math.round(sensorValueDelegate.stateValue.value * 100) / 100).arg(sensorValueDelegate.stateType.unitString) + : "" + } + } elide: Text.ElideRight verticalAlignment: Text.AlignVCenter font.pixelSize: app.smallFont } Led { id: led - visible: sensorValueDelegate.stateType && sensorValueDelegate.stateType.type.toLowerCase() == "bool" + visible: ["presencesensor", "daylightsensor"].indexOf(model.interfaceName) >= 0 state: visible && sensorValueDelegate.stateValue.value === true ? "on" : "off" } Item { diff --git a/nymea-app/ui/devicepages/SensorDevicePagePost110.qml b/nymea-app/ui/devicepages/SensorDevicePagePost110.qml index b70b737b..266b8193 100644 --- a/nymea-app/ui/devicepages/SensorDevicePagePost110.qml +++ b/nymea-app/ui/devicepages/SensorDevicePagePost110.qml @@ -11,7 +11,7 @@ ListView { interactive: contentHeight > height model: ListModel { Component.onCompleted: { - var supportedInterfaces = ["temperaturesensor", "humiditysensor", "pressuresensor", "moisturesensor", "lightsensor", "conductivitysensor", "noisesensor", "co2sensor", "presencesensor", "daylightsensor"] + var supportedInterfaces = ["temperaturesensor", "humiditysensor", "pressuresensor", "moisturesensor", "lightsensor", "conductivitysensor", "noisesensor", "co2sensor", "presencesensor", "daylightsensor", "closablesensor"] for (var i = 0; i < supportedInterfaces.length; i++) { if (root.deviceClass.interfaces.indexOf(supportedInterfaces[i]) >= 0) { append({name: supportedInterfaces[i]}); @@ -38,7 +38,8 @@ ListView { "noisesensor": "noise", "co2sensor": "co2", "presencesensor": "isPresent", - "daylightsensor": "daylight" + "daylightsensor": "daylight", + "closablesensor": "closed" } } @@ -72,8 +73,22 @@ ListView { anchors.centerIn: parent height: app.iconSize * 4 width: height - name: app.interfaceToIcon(boolView.interfaceName) - color: device.states.getState(boolView.stateType.id).value === true ? app.interfaceToColor(boolView.interfaceName) : keyColor + name: { + switch (boolView.interfaceName) { + case "closablesensor": + return device.states.getState(boolView.stateType.id).value === true ? Qt.resolvedUrl("../images/lock-closed.svg") : Qt.resolvedUrl("../images/lock-open.svg") + default: + return app.interfaceToIcon(boolView.interfaceName) + } + } + color: { + switch (boolView.interfaceName) { + case "closablesensor": + return device.states.getState(boolView.stateType.id).value === true ? "green" : "red" + default: + device.states.getState(boolView.stateType.id).value === true ? app.interfaceToColor(boolView.interfaceName) : keyColor + } + } } } Item { diff --git a/nymea-app/ui/images/lock-closed.svg b/nymea-app/ui/images/lock-closed.svg new file mode 100644 index 00000000..d7cf5385 --- /dev/null +++ b/nymea-app/ui/images/lock-closed.svg @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/nymea-app/ui/images/lock-open.svg b/nymea-app/ui/images/lock-open.svg new file mode 100644 index 00000000..354dada1 --- /dev/null +++ b/nymea-app/ui/images/lock-open.svg @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/nymea-app/ui/images/sensors/closable.svg b/nymea-app/ui/images/sensors/closable.svg new file mode 100644 index 00000000..d7cf5385 --- /dev/null +++ b/nymea-app/ui/images/sensors/closable.svg @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/nymea-app/ui/mainviews/DevicesPageDelegate.qml b/nymea-app/ui/mainviews/DevicesPageDelegate.qml index 422f9478..88df04e2 100644 --- a/nymea-app/ui/mainviews/DevicesPageDelegate.qml +++ b/nymea-app/ui/mainviews/DevicesPageDelegate.qml @@ -428,6 +428,7 @@ MainPageTile { ListElement { ifaceName: "pressuresensor"; stateName: "pressure" } ListElement { ifaceName: "daylightsensor"; stateName: "daylight" } ListElement { ifaceName: "presencesensor"; stateName: "isPresent" } + ListElement { ifaceName: "closablesensor"; stateName: "closed" } ListElement { ifaceName: "lightsensor"; stateName: "lightIntensity" } ListElement { ifaceName: "co2sensor"; stateName: "co2" } ListElement { ifaceName: "conductivity"; stateName: "conductivity" } @@ -511,7 +512,7 @@ MainPageTile { Led { Layout.preferredHeight: app.iconSize * .5 Layout.preferredWidth: height - state: sensorsRoot.shownStateType && sensorsRoot.device.stateValue(sensorsRoot.shownStateType.id) === true ? "on" : "off" + state: sensorsRoot.shownStateType && sensorsRoot.device.states.getState(sensorsRoot.shownStateType.id).value === true ? "on" : "off" visible: sensorsRoot.shownStateType && sensorsRoot.shownStateType.type.toLowerCase() === "bool" } }