Skip to content

Material: Drop "attached property enforcement"

ivan tkachenko requested to merge work/ratijas/material-attached into master

As can be easily demonstrated, attached properties are getting created on any Qt object any time it is accessed in any way in QML, be it property read or write, or even simply querying the object itself like delegate.Layout or this.Material. Thus, no such "enforcement" is needed.

The output is identical when running the following snippet with both Qt 5.15 and 6.5 QML runtimes.

import QtQuick 2.15
import QtQuick.Controls.Material 2.0
import org.kde.kirigami 2.20 as Kirigami

Item {
    Kirigami.BasicThemeDefinition {
        id: hack

        Material.elevation: 2

        textColor: hack.Material.foreground
    }

    Kirigami.BasicThemeDefinition {
        id: nohack

        textColor: nohack.Material.foreground
    }

    Kirigami.BasicThemeDefinition {
        id: nothing

        textColor: "#111111"
    }

    Component.onCompleted: {
        print(hack, hack.Material)
        print(hack.textColor, hack.Material.foreground)
        print(hack.highlightColor, hack.Material.accent)

        print(nohack, nohack.Material)
        print(nohack.textColor, nohack.Material.foreground)
        print(nohack.highlightColor, nohack.Material.accent)

        print(nothing, nothing.Material)
        print(nothing.textColor, nothing.Material.foreground)
        print(nothing.highlightColor, nothing.Material.accent)
    }
}

Merge request reports

Loading