Support icons from local files in buttons
ClosedPublic

Authored by nicolasfella on Jan 17 2019, 10:08 PM.

Details

Summary

Trying to assign an icon from a file to a button like in

import QtQuick 2.2
import QtQuick.Controls 2.4

Button {
    icon.source: "/usr/share/icons/breath/emotes/22/face-smirk.svg"
}

results in no icon being shown. The current code interprets the filename as QString and tries to load an icon with that name from the theme, which obviously doesn't exist. This patch checks whether the icon points to a local file
and if it is loads it. If not it falls back to loading it from the theme.

Test Plan

Above code now correctly displays a face.
Ran systemsettings, checked QML KCMs' buttons for icons

Diff Detail

Repository
R858 Qt Quick Controls 2: Desktop Style
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nicolasfella created this revision.Jan 17 2019, 10:08 PM
Restricted Application added a project: Plasma. · View Herald TranscriptJan 17 2019, 10:08 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
nicolasfella requested review of this revision.Jan 17 2019, 10:08 PM

/foo/bar is not a local URL? file:///foo/bar would be. I think you now broke the QString case?

/foo/bar is not a local URL? file:///foo/bar would be. I think you now broke the QString case?

qDebug() << icon.value<QUrl>();
gives QUrl("file:///foo/bar"), even when the original URL was specified without scheme

The QString case still works

mart accepted this revision.Feb 6 2019, 9:52 PM
This revision is now accepted and ready to land.Feb 6 2019, 9:52 PM
This revision was automatically updated to reflect the committed changes.