Bug 433433

Summary: Components that use StylePrivate.StyleItem to render content can't handle icon.source
Product: [Frameworks and Libraries] frameworks-qqc2-desktop-style Reporter: Nate Graham <nate>
Component: generalAssignee: Marco Martin <notmart>
Status: CONFIRMED ---    
Severity: normal CC: ahiemstra, kde, kde, noahadvs
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description Nate Graham 2021-02-22 17:14:43 UTC
This is because the base QWidgets component that's being called can only support taking an icon string, not a URL. As a result, using icon.source produces no result in Button, ToolButton, RoundButton, CheckBox, and MenuItem.

Simple test case:


import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.13

Item {
    implicitWidth: 400
    implicitHeight: 400

    ColumnLayout {
        anchors.centerIn: parent

        Button {
            Layout.alignment: Qt.AlignHCenter
            text: "I wish I had an icon"
            icon.source: "https://dl.flathub.org/repo/logo.svg"
        }

        Button {
            Layout.alignment: Qt.AlignHCenter
            text: "Look at my beautiful icon"
            icon.name: "edit-bomb"
        }
    }
}
Comment 1 David Redondo 2021-02-23 08:13:07 UTC
Probably  need to do it like Kirigami
https://invent.kde.org/frameworks/kirigami/-/blob/master/src/icon.cpp#L402
Comment 2 Bug Janitor Service 2021-04-19 21:15:13 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/67
Comment 3 Nate Graham 2021-04-23 14:37:12 UTC
Git commit 35e6076565d565922939eeca11e93abe67f7b664 by Nate Graham.
Committed on 19/04/2021 at 21:11.
Pushed by ngraham into branch 'master'.

Draw icon in QQStyleItem

Checkbox already knew how to do this, but it was doing so internally to
itself. Let's move that logic to CheckDelegate.qml so that everything
that uses it gains the same feature. This functionality can be optionally
disabled in case a control using it already handles icon-drawing by itself.

M  +4    -4    org.kde.desktop/CheckBox.qml
M  +5    -2    org.kde.desktop/CheckDelegate.qml
M  +12   -1    org.kde.desktop/CheckIndicator.qml
M  +2    -0    org.kde.desktop/MenuItem.qml
M  +4    -4    org.kde.desktop/RadioButton.qml
M  +5    -2    org.kde.desktop/RadioDelegate.qml

https://invent.kde.org/frameworks/qqc2-desktop-style/commit/35e6076565d565922939eeca11e93abe67f7b664