File 2002-line-chart.patch of Package libksysguard6
diff --git a/faces/facepackages/linechart/contents/ui/FullRepresentation.qml b/faces/facepackages/linechart/contents/ui/FullRepresentation.qml
index 0f4b2c1518d274db67f67057df7da41890206d63..243c1e69bb89fde7032a33413dab53f3a30535d2 100644
--- a/faces/facepackages/linechart/contents/ui/FullRepresentation.qml
+++ b/faces/facepackages/linechart/contents/ui/FullRepresentation.qml
@@ -88,8 +88,6 @@ Faces.SensorFace {
controller: root.controller
- highlight: legend.highlightedIndex
-
ChartsControls.GridLines {
id: horizontalLines
visible: showGridLines
@@ -108,15 +106,85 @@ Faces.SensorFace {
}
}
- Faces.ExtendedLegend {
- id: legend
+ Item {
Layout.fillWidth: true
- Layout.minimumHeight: implicitHeight
- visible: root.showLegend
- chart: compactRepresentation
- sourceModel: root.showLegend ? compactRepresentation.sensorsModel : null
- sensorIds: root.showLegend ? root.controller.lowPrioritySensorIds : []
- updateRateLimit: root.controller.updateRateLimit
+ Layout.preferredHeight: legend.implicitHeight
+
+ RowLayout {
+ id: legend
+ anchors.left: parent.left
+ width: Math.min(parent.width, implicitWidth)
+ spacing: Kirigami.Units.gridUnit
+ visible: root.showLegend
+
+ readonly property real maximumCellWidth: (parent.width - spacing * (legendDelegateRepeater.count - 1)) / legendDelegateRepeater.count
+
+ Repeater {
+ id: legendDelegateRepeater
+ model: root.showLegend ? root.controller.highPrioritySensorIds : []
+
+ RowLayout {
+ id: legendDelegate
+ Layout.fillWidth: true
+ Layout.maximumWidth: sensorColor.Layout.preferredWidth + sensorName.Layout.preferredWidth + sensorValue.Layout.preferredWidth + 2 * spacing
+ spacing: Kirigami.Units.smallSpacing
+
+ readonly property QtObject sensor: Sensors.Sensor {
+ sensorId: modelData
+ updateRateLimit: root.controller.updateRateLimit
+ }
+
+ Rectangle {
+ id: sensorColor
+ Layout.fillHeight: true
+ Layout.preferredWidth: height / 3
+ radius: width / 2
+ color: {
+ let color = root.controller.sensorColors[sensor.sensorId] || "white";
+ if (compactRepresentation.highlight >= 0 && compactRepresentation.highlight !== index) {
+ // desaturate sensor color
+ color = Qt.hsla(color.hslHue, 0.5 * color.hslSaturation, 0.5 * color.hslLightness, 0.5 * color.a);
+ }
+ return color;
+ }
+ }
+
+ QQC2.Label {
+ id: sensorName
+ Layout.preferredWidth: implicitWidth
+ text: "%1:".arg(root.controller.sensorLabels[sensor.sensorId] || sensor.name)
+ visible: legendDelegate.Layout.maximumWidth <= legend.maximumCellWidth
+ }
+
+ QQC2.Label {
+ id: sensorValue
+ Layout.fillWidth: true
+ Layout.preferredWidth: Math.max(Formatter.Formatter.maximumLength(sensor.unit, font), implicitWidth)
+ text: sensor.formattedValue
+ }
+
+ HoverHandler {
+ id: hoverHandler
+
+ onHoveredChanged: {
+ if (hovered) {
+ compactRepresentation.highlight = index;
+ } else if (compactRepresentation.highlight === index) {
+ compactRepresentation.highlight = -1;
+ }
+ }
+ }
+
+ QQC2.ToolTip {
+ closePolicy: QQC2.Popup.CloseOnReleaseOutside
+ x: (parent.width - implicitWidth) / 2
+ y: parent.height + 3
+ text: i18nc("name: value", "%1: %2").arg(parent.sensor.name).arg(parent.sensor.formattedValue)
+ visible: hoverHandler.hovered && !sensorName.visible
+ }
+ }
+ }
+ }
}
}
}