Broken sensor face for Plasma 6.1 widget

Hi,

I’ve just updated my system to Plasma 6.1 from 5.x (don’t remember, probably the last one). I’m excited about all the new goodness but I can’t get my Panel widgets to work as they did.

Back in 5.x, I’ve created a simple sensor face for “System Monitor Sensor” widget. It was a plain text in compact view (used in panel).

sensorface

Back then, when creating this sensor face, I’d followed this guide: Creating sensor faces | Developer
The QML I used was just:

Faces.SensorFace {
    contentItem: RowLayout {
        Repeater {
            model: controller.highPrioritySensorIds
            delegate: Label {
                text: i18n(sensor.formattedValue)
                Layout.alignment: Qt.AlignHCenter

                Sensors.Sensor {
                    id: sensor
                    sensorId: modelData
                }
            }
        }
    }
}

Unfortunately, it no longer works (nothing gets displayed) in Plasma 6.1.

As a temporary solution, I’ve managed to get the values showing by “adapting” (stripping down) the org.kde.ksysguard.textonly preinstalled sensor face. This is clearly not the proper way to achieve what I intent to (displaying just text value, without any labels), and it does not look good (black bars in the background).

charts

Faces.CompactSensorFace {
    id: root

    contentItem: ChartsControls.LegendLayout {
        Repeater {
            model: root.controller.highPrioritySensorIds

            ChartsControls.LegendDelegate {
                value: sensor.formattedValue

                Sensors.Sensor {
                    id: sensor
                    sensorId: modelData
                    updateRateLimit: root.controller.updateRateLimit
                }
            }
        }
    }
}

I “have to” create the sensor face, because the default org.kde.ksysguard.textonly displays the label and color bar, both of which I don’t need.

textonly

I suspect the solution might be to use another class instead of ChartsControls.LegendLayout. But, even if my assumption is correct, I don’t know which one. Can anyone please help me in getting my text sensors in KDE Plasma 6+ back?

It is even worse in light theme.
light

I worked around it by using a color property to match the panel color. I then use a script to discard the inappropriate one when switching Plasma Themes during the day/night.

            ChartsControls.LegendDelegate {
                value: sensor.formattedValue
                color: "#eff0f1" // light
                color: "#2a2e32" // dark

This is still a hack, but is usable.

There was no margin between the top of the panel and widget top.

nomargin

But thanks to the example at KQuickCharts - KQuickCharts I was able to resolve it by adding: anchors.centerIn: parent to ChartsControls.LegendDelegate properties.

It is still created totally not how it should have been (by striping down and background-coloring the chart) but at least it’s usable again.

center
darkChart

I’ll still appreciate the correct approach very much.

Still not the correct approach (i.e. still just masking the bar instead of not displaying it in the first place), but a little better. Hopefully, this would help someone. I look on.

Instead of setting the correct value in QML by an external script, I now use QML’s property binding:

color: (Qt.formatTime(new Date(), "hh") > 22) || (Qt.formatTime(new Date(), "hh") < 6) ? "#2a2e32" : "#eff0f1"

Oh, even better (but not there yet), there is transparency in QML.

color: "#00000000"