Skip to content

ScrollView: Port to new stuff, Clean up old hacks

ivan tkachenko requested to merge work/ratijas/scrollview into master

Port internal method to new optional chaining syntax

It's not any considerably longer this way, and does not require an extra meta-data for redundant method.

Port implicit size bindings to modern conventional expressions

Since long ago QtQuick.Controls have convenient shortcuts like implicitBackgroundWidth and implicitBackgroundHeight, so we don't have to use extra conditionals in our markup code.

Get rid of workarounds for bad client code

Style implementation code is not a good place to defend against misuses incompatible with other styles. It only liters our code with hacks, for no real benefit (more on that later). Imagine, if every style would contain such hacks to account for what other styles are doing? That would be pretty terrible situation. Each style should do its best, and each client should comply with contracts of QQC Templates.

Now, in multiple observations, this hack never really worked as intended in the first place. Even here, in KDE, clients that needed a ScrollView with a background, they just did this:

Component.onCompleted: background.visible = true;

Do you see any null checks there to account for "upstream styles"? No, there are none. I fixed such components in couple of places, and if you encounter more you should replace it with this:

    QQC2.ScrollView {
        // ...
        Component.onCompleted: {
            if (background) {
                background.visible = true/false;
            }
        }
    }

See also:

Merge request reports