Respect QIcon::fallbackSearchpaths()
ClosedPublic

Authored by nicolasfella on May 3 2020, 7:29 PM.

Details

Reviewers
mart
Group Reviewers
Plasma
Frameworks
Summary

When an icon isn't found within a theme we are supposed to look for it in QIcon::fallbackSearchpaths() (https://doc.qt.io/qt-5/qicon.html#fromTheme).

BUG: 405522

Test Plan

Create /home/nico/foo.svg
Add QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << QStringLiteral("/home/nico/myicons")); to my app
Use foo icon somewhere

Diff Detail

Repository
R302 KIconThemes
Branch
fallback
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 26743
Build 26761: arc lint + arc unit
nicolasfella created this revision.May 3 2020, 7:29 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 3 2020, 7:29 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
nicolasfella requested review of this revision.May 3 2020, 7:29 PM
aacid added a subscriber: aacid.May 3 2020, 9:13 PM
aacid added inline comments.
src/kiconloader.cpp
1142

Would it make sense trying to use QIconLoader::lookupFallbackIcon ? This way we "upstream" Qt behaviour? For example you're supporting svgz while Qt doesn't. Which would mean different QIcon::fallbackSearchPaths whether you're using KIconLoader or not which doesn't seem totally great?

aacid added inline comments.May 3 2020, 9:18 PM
src/kiconloader.cpp
1142

I just realized that function is private, not really easy to use :/

anyhow do you think we should remove svgz?

Also i think using

const QStringList extensions = { QStringLiteral(".png"), QStringLiteral(".svg"), QStringLiteral(".svgz"), QStringLiteral(".xpm") };

should be a bit faster

kossebau added inline comments.
src/kiconloader.cpp
1142

You could make this even a stack-only array, even more fast due to no heap alloc ;)

const QString extensions[] = { QStringLiteral(".png"), QStringLiteral(".svg"), QStringLiteral(".svgz") << QStringLiteral(".xpm" };
nicolasfella added inline comments.May 11 2020, 6:13 PM
src/kiconloader.cpp
1142

I copied that list from somewhere else in KIconLoader. It would seem weird to me to support a different set of formats in the fallback than in the regular path

  • Use array
mart accepted this revision.Jun 13 2020, 3:27 PM
mart added a subscriber: mart.

go for it :)

This revision is now accepted and ready to land.Jun 13 2020, 3:27 PM
nicolasfella closed this revision.Jun 13 2020, 10:30 PM