Improve tooltips in new charts

pull/1017/head
Michael Zanetti 2023-05-07 12:27:38 +02:00
parent 1ad2f8f759
commit e06510134f
4 changed files with 42 additions and 48 deletions

View File

@ -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,6 +487,23 @@ Item {
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
@ -534,7 +512,8 @@ Item {
: 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
font: Style.extraSmallFont
}
}
}

View File

@ -155,6 +155,7 @@ ThingPageBase {
thing: root.thing
stateType: parent.stateType
color: app.interfaceToColor(interfaceName)
iconSource: app.interfaceToIcon(interfaceName)
}
}

View File

@ -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

View File

@ -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))