Comment 4 for bug 1559724

Revision history for this message
Stefano Verzegnassi (verzegnassi-stefano) wrote :

Hey Roman, I can think at three alternatives:

1) Set MainView.backgroundColor according to the nightMode status.

MainView {
    backgroundColor: nightModeEnabled ? "black" : "white"
}

I'm almost sure you'll also have to disable auto-theming (i.e. UITK switches the app theme between Ambiance and SuruDark according to the set background color).

2) Add a QML Rectangle to the MainView, in order to restore the previous code. Anyway, you'll lose the performance boost mentioned in the bug report above.

MainView {
    id: root

    Rectangle {
        anchors.fill: parent
        color: root.backgroundColor
    }
}

3) Don't use a shader on the whole view, but use individual shaders on each QML Image (if required). Set the app theme according to the current mode.

MainView {
    property bool nightModeEnabled: true

    theme.name: nightModeEnabled ? "Ubuntu.Components.Themes.SuruDark" : "Ubuntu.Components.Themes.Ambiance"

    ArticleItem {
        Image {
            [...]

            layer.enabled: nightModeEnabled
            layer.item: NightModeShader {}
        }
    }
}

I'd probably choose 2), which is faster to implement and safer (i.e. less unexpected issues - that's how it used to work until now).
This is something we should fix in DocViewer too, but I'd probably move to a different solution (the first one) in a longer term.

I guess the shader usage (currently it's used only in DocViewer and Shorts) hasn't been considered by the SDK team when they did that change. So yes, we should fix it.
However, it could be worth to ask them which solution they would suggest (and eventually suggest a similar feature for the next UITK release).