From e06510134f452929d00dfe574f1753c9582a2dba Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 7 May 2023 12:27:38 +0200 Subject: [PATCH] Improve tooltips in new charts --- nymea-app/ui/customviews/StateChart.qml | 75 +++++++------------ nymea-app/ui/devicepages/SensorDevicePage.qml | 1 + .../airconditioning/ACChartsPage.qml | 5 ++ .../airconditioning/TooltipDelegate.qml | 9 +++ 4 files changed, 42 insertions(+), 48 deletions(-) diff --git a/nymea-app/ui/customviews/StateChart.qml b/nymea-app/ui/customviews/StateChart.qml index c85a0ed0..bf182940 100644 --- a/nymea-app/ui/customviews/StateChart.qml +++ b/nymea-app/ui/customviews/StateChart.qml @@ -359,45 +359,6 @@ Item { } } - - RowLayout { - id: legend - anchors { left: parent.left; bottom: parent.bottom; right: parent.right } - anchors.leftMargin: chartView.plotArea.x - height: Style.smallIconSize - anchors.margins: Style.margins - visible: false - - Item { - Layout.fillWidth: true - Layout.fillHeight: true - // opacity: selfProductionConsumptionSeries.opacity - MouseArea { - anchors.fill: parent - anchors.topMargin: -Style.smallMargins - anchors.bottomMargin: -Style.smallMargins - // onClicked: d.selectSeries(selfProductionConsumptionSeries) - } - Row { - anchors.centerIn: parent - spacing: Style.smallMargins - ColorIcon { - name: "weathericons/weather-clear-day" - size: Style.smallIconSize - color: Style.green - } - Label { - width: parent.parent.width - x - elide: Text.ElideRight - visible: legend.width > 500 - text: qsTr("Produced") - anchors.verticalCenter: parent.verticalCenter - font: Style.smallFont - } - } - } - } - MouseArea { id: mouseArea anchors.fill: parent @@ -526,15 +487,33 @@ Item { font: Style.smallFont } - Label { - Layout.fillWidth: true - elide: Text.ElideRight - text: toolTip.value === null - ? qsTr("No data") - : root.stateType.type.toLowerCase() == "bool" - ? root.stateType.displayName + ": " + (toolTip.value ? qsTr("Yes") : qsTr("No")) - : Types.toUiValue(toolTip.value, root.stateType.unit).toFixed(root.roundTo) + Types.toUiUnit(root.stateType.unit) - font: Style.smallFont + RowLayout { + + ColorIcon { + id: icon + size: Style.smallIconSize + name: root.iconSource + color: root.color + visible: name != "" + } + + Rectangle { + width: Style.extraSmallFont.pixelSize + height: width + color: root.color + visible: !icon.visible + } + + Label { + Layout.fillWidth: true + elide: Text.ElideRight + text: toolTip.value === null + ? qsTr("No data") + : root.stateType.type.toLowerCase() == "bool" + ? root.stateType.displayName + ": " + (toolTip.value ? qsTr("Yes") : qsTr("No")) + : Types.toUiValue(toolTip.value, root.stateType.unit).toFixed(root.roundTo) + Types.toUiUnit(root.stateType.unit) + font: Style.extraSmallFont + } } } diff --git a/nymea-app/ui/devicepages/SensorDevicePage.qml b/nymea-app/ui/devicepages/SensorDevicePage.qml index 7a858dbb..7f0137c3 100644 --- a/nymea-app/ui/devicepages/SensorDevicePage.qml +++ b/nymea-app/ui/devicepages/SensorDevicePage.qml @@ -155,6 +155,7 @@ ThingPageBase { thing: root.thing stateType: parent.stateType color: app.interfaceToColor(interfaceName) + iconSource: app.interfaceToIcon(interfaceName) } } diff --git a/nymea-app/ui/mainviews/airconditioning/ACChartsPage.qml b/nymea-app/ui/mainviews/airconditioning/ACChartsPage.qml index 35bae847..939c9347 100644 --- a/nymea-app/ui/mainviews/airconditioning/ACChartsPage.qml +++ b/nymea-app/ui/mainviews/airconditioning/ACChartsPage.qml @@ -61,6 +61,7 @@ Page { for (var i = 0; i < vocRepeater.count; i++) { vocRepeater.itemAt(i).logsModel.fetchLogs() } + for (var i = 0; i < windowOpenRepeater.count; i++) { windowOpenRepeater.itemAt(i).logsModel.fetchLogs() } @@ -897,6 +898,7 @@ Page { thing: thermostatsRepeater.itemAt(index).thing entry: thermostatsRepeater.itemAt(index).logsModel.find(tooltips.timestamp) color: app.interfaceToColor("temperaturesensor") + iconSource: app.interfaceToIcon("temperaturesensor") valueName: "temperature" axis: temperatureAxis x: tooltips.tooltipX @@ -917,6 +919,7 @@ Page { entry: tempRepeater.itemAt(index).logsModel.find(tooltips.timestamp) valueName: "temperature" color: app.interfaceToColor("temperaturesensor") + iconSource: app.interfaceToIcon("temperaturesensor") axis: temperatureAxis x: tooltips.tooltipX width: tooltips.tooltipWidth @@ -935,6 +938,7 @@ Page { thing: humidityRepeater.itemAt(index).thing entry: humidityRepeater.itemAt(index).logsModel.find(tooltips.timestamp) color: app.interfaceToColor("humiditysensor") + iconSource: app.interfaceToIcon("humiditysensor") valueName: "humidity" axis: humidityAxis x: tooltips.tooltipX @@ -955,6 +959,7 @@ Page { entry: vocRepeater.itemAt(index).logsModel.find(tooltips.timestamp) valueName: "voc" color: app.interfaceToColor("vocsensor") + iconSource: app.interfaceToIcon("vocsensor") axis: vocAxis x: tooltips.tooltipX width: tooltips.tooltipWidth diff --git a/nymea-app/ui/mainviews/airconditioning/TooltipDelegate.qml b/nymea-app/ui/mainviews/airconditioning/TooltipDelegate.qml index 28a9b789..137c50d3 100644 --- a/nymea-app/ui/mainviews/airconditioning/TooltipDelegate.qml +++ b/nymea-app/ui/mainviews/airconditioning/TooltipDelegate.qml @@ -15,6 +15,7 @@ NymeaToolTip { property Thing thing: null property NewLogEntry entry: null property string valueName: "" + property alias iconSource: icon.name property alias color: rect.color property ValueAxis axis: null property int unit: Types.UnitNone @@ -29,10 +30,18 @@ NymeaToolTip { anchors.fill: parent anchors.margins: Style.smallMargins + ColorIcon { + id: icon + size: Style.smallIconSize + color: root.color + visible: name != "" + } + Rectangle { id: rect width: Style.extraSmallFont.pixelSize height: width + visible: !icon.visible } Label { text: "%1: %2%3".arg(thing.name).arg(entry ? round(Types.toUiValue(root.value, unit)) : "-").arg(Types.toUiUnit(unit))