[.qml+python3] How to determine whether icons are enabled?

Like

I want to know how to determine whether icons are enabled in the relevant KCM. I found

                leading: Item {
                    width: iconItem.width

                    PlasmaCore.IconItem {
                        id: iconItem

                        source: model.decoration
                        visible: source !== "" && iconItem.valid

                        implicitWidth: PlasmaCore.Units.roundToIconSize(parent.height)
                        implicitHeight: PlasmaCore.Units.roundToIconSize(parent.height)
                    }
                    // Fall back to a generic icon if the application doesn't provide a valid one
                    PlasmaCore.IconItem {
                        source: "preferences-system-windows"
                        visible: !iconItem.valid

                        implicitWidth: PlasmaCore.Units.roundToIconSize(parent.height)
                        implicitHeight: PlasmaCore.Units.roundToIconSize(parent.height)
                    }
                }

in file:///usr/share/plasma/plasmoids/org.kde.plasma.windowlist/contents/ui/main.qml, but it wasn’t commented, so I don’t know whether it’s useful nor do I understand the code.

What do you mean by enabling icons :thinking: ?

I didn’t know such option existed. I’m quite sure that this setting doesn’t affect any qml applications (Kalendar for example) so I don’t think there would be any easy way to do that.

Again I’m not an expert

Indeed, none that I’ve seen, but it shall if I configure my .qml software to read from its configuration state and enable or disable iconography accordantly.

Use kconfig to get the value (if any) of the ToolButtonStyle key in the Toolbar style group of the global config. If the value isn’t “TextOnly”, then there are icons somewhere in the buttons.

Note that the setting is going away in Plasma 6 because its scope is ill-defined and it doesn’t affect more places than it does. So I wouldn’t recommend depending on it for the future.

1 Like

I actually wanted to add it for a little backward compatibility, and to understand a little better why it’s being removed. There’s no better way to learn to hate a feature you love than to try supporting it as a developer, eh?