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 0a51156b26e3c137fb353a466bea0bb5b206035b..bc3d07ab7bd0046ee16bb6890096f6240fc6c33f 100644
--- a/faces/facepackages/linechart/contents/ui/FullRepresentation.qml
+++ b/faces/facepackages/linechart/contents/ui/FullRepresentation.qml
@@ -106,14 +106,82 @@ Faces.SensorFace {
             }
         }
 
-        Faces.ExtendedLegend {
+        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 {
+                            text: i18nc("name: value", "%1: %2").arg(parent.sensor.name).arg(parent.sensor.formattedValue)
+                            visible: hoverHandler.hovered && !sensorName.visible
+                        }
+                    }
+                }
+            }
         }
     }
 }
openSUSE Build Service is sponsored by