Checking if a Plasma6 Plasmoid is in the System Tray

Hi,

Is there any way to test whether my plasmoid is running in the Status and Notifications panel, rather than a standalone widget in the panel?

Alternatively, can I query the maximum width/height that is available for my Plasmoid CompactRepresentation? I need to make sure my content can’t overflow into other widgets…

In Plasma5 I could test the parent properties , but that just comes up as NULL now.

Not sure if there is a straight forward way but you could try checking if is a child of 'org.kde.plasma.private.systemtray maybe like this plasmoid-wunderground/plasmoid/contents/ui/main.qml at aadacf980870eb0fa918b1b0f10817b85e8c3ed1 · k-donn/plasmoid-wunderground · GitHub

Or the plasmoid.containmentDisplayHints like this plasma-panel-colorizer/package/contents/ui/main.qml at 5359f493209613c9ba24f221a88f090bc1ab3b38 · luisbocanegra/plasma-panel-colorizer · GitHub the second worked for me to find all icons that are in the tray.

Alternatively, can I query the maximum width/height that is available for my Plasmoid CompactRepresentation? I need to make sure my content can’t overflow into other widgets…

Looks like those still work. At least I see them as properties of main.parent where main is the PlasmoidItem.

PlasmoidItem {
    id: main
    ...
    Component.onCompleted: console.log(main.parent.height) // or just parent.height since this is a direct child.
}

Can you share the code?

The wunderground code is almost identical to mine, but it doesn’t work on plasma6 - it throws the following error:
TypeError: Cannot read property 'pluginName' of undefined

And console.log(main.parent.height) and console.log(parent.height)
both throw the following error.
TypeError: Cannot read property 'height' of null

Looks like you can’t query the parent at all in Plasma 6…

Hello, I may have come to a solution.

The parent property is gone from the plasmoid (Applet) context property; however, there are the containment.containmentType and formFactor properties.

Debugging some, if formFactor is 2, which means it is vertically constrained, (which happens when a plasmoid is in the system tray) and the containmentType is 129, which means the plasmoid is custom embedded in a containment, then the widget is in the system tray.

I have tried this out in my Wunderground widget and it seems to work.

Yes, that seems to work, thank you.
Now onto the next bug!