Bug 344469 - Icon themes from inside Qt5 application resources are ignored
Summary: Icon themes from inside Qt5 application resources are ignored
Status: RESOLVED UPSTREAM
Alias: None
Product: frameworks-frameworkintegration
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL: http://i.imgur.com/PKww9sH.jpg
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-22 23:54 UTC by Petr Mrázek
Modified: 2016-07-15 22:42 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Bug demo (43.05 KB, application/zip)
2015-05-17 10:06 UTC, Minh Ngo
Details
new bug_demo (88.52 KB, application/zip)
2015-06-13 10:24 UTC, Fl@sh
Details
attachment-28603-0.html (870 bytes, text/html)
2015-08-15 17:20 UTC, Petr Mrázek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Mrázek 2015-02-22 23:54:16 UTC
I have multiple icon themes inside a Qt5 application: 
https://github.com/MultiMC/MultiMC5/tree/develop/resources

These resources are registered in Qt and one of the themes is set as the icon theme for Qt:
https://github.com/MultiMC/MultiMC5/blob/develop/main.cpp#L7

Without the platformintegration package, this works. It works on all platforms, including KDE4.

With platformintegration, I get blank icons. Apparently, the logic for loading icons is completely replaced by the QPA plugin. This is not desirable.

Note that: I would still like to have platform integration - the widget themes, dialogs, color scheme.


Reproducible: Always

Steps to Reproduce:
1. Use platformintegration
2. Use a Qt5 application that includes icon themes as resources

Actual Results:  
Icons are invisible (with latest KDE from git), or replaced by a generic placeholder (current Arch packages). See bug https://bugs.kde.org/show_bug.cgi?id=342906

Expected Results:  
Icons are rendered using the themes included with the application, using the system themes as a fallback only.

I've tried many different workarounds and none of them seem desirable, or they simply didn't work:
* patching Qt to remove calls to QPA in QIcon
* Fooling the KDE icon loader to look at the resource paths instead (adding to XDG_DATA_DIRS, didn't work)
* removing the plugins added by the package from the QT_PLUGIN_PATH (setting it only to the plugins that the application includes, didn't work)
* Setting other QPA and theme plugin related Qt options (didn't work)
* Just ripping out the Qt icon theme loading code out and putting it into a standalone library (ended up being too nasty, so I scrapped that effort - it is quite interconnected with various platform-specific things)

None of this worked.
Comment 1 Petr Mrázek 2015-02-22 23:56:12 UTC
Application issue: https://github.com/MultiMC/MultiMC5/issues/796
Comment 2 Petr Mrázek 2015-02-22 23:58:36 UTC
s/platfromintegration/frameworkintegration/g ... it's been a very long evening :)
Comment 3 Petr Mrázek 2015-02-23 10:47:34 UTC
https://qt.gitorious.org/qt/qtbase/source/73a1e8c60d894701f34806cc4b847aa2814bf389:src/gui/image/qicon.cpp#L1174 and the 2 lines below make it always use the platform theme when it's available.
Comment 4 Christoph Feck 2015-02-28 21:46:56 UTC
Petr, could you test this patch for "kiconthemes" framework? If it works, I will discuss with frameworks developers if it can be integrated.

diff --git a/src/kiconloader.cpp b/src/kiconloader.cpp
index c47eecb..6015fc1 100644
--- a/src/kiconloader.cpp
+++ b/src/kiconloader.cpp
@@ -556,6 +556,8 @@ bool KIconLoaderPrivate::initIconThemes()
     searchPaths.append("icons"); // was xdgdata-icon in KStandardDirs
     // These are not in the icon spec, but e.g. GNOME puts some icons there anyway.
     searchPaths.append("pixmaps"); // was xdgdata-pixmaps in KStandardDirs
+    // Fallback to Qt resources
+    searchPaths.append(":/icons");
 
 #ifndef NDEBUG
     QString dbgString = "Theme tree: ";
Comment 5 Petr Mrázek 2015-03-01 02:02:30 UTC
No. That just doesn't seem to change anything.

I also uncommented the debug code below and got this:
    0.065 D "Theme tree: (Oxygen)"

I have a bunch of different themes, which do not match any of the system theme names, but the user can switch them inside the application:

[peterix ~/projects/minecraft/src/MultiMC5/application/resources]$ find . | grep index.theme
./pe_dark/index.theme
./iOS/index.theme
./pe_light/index.theme
./pe_blue/index.theme
./OSX/index.theme
./pe_colored/index.theme
./multimc/index.theme
[peterix ~/projects/minecraft/src/MultiMC5/application/resources]$ find . | grep qrc
./pe_dark/pe_dark.qrc
./iOS/iOS.qrc
./pe_light/pe_light.qrc
./pe_blue/pe_blue.qrc
./instances/instances.qrc
./backgrounds/backgrounds.qrc
./OSX/OSX.qrc
./pe_colored/pe_colored.qrc
./multimc/multimc.qrc

The themes exist in the resources in :/icons/$themeName/

Example qrc:
<!DOCTYPE RCC>
<RCC version="1.0">
	<qresource prefix="/icons/pe_colored">
		<file>index.theme</file>
		<file>scalable/about.svg</file>
		<file>scalable/accounts.svg</file>
		<file>scalable/bug.svg</file>
		<file>scalable/centralmods.svg</file>
		<file>scalable/checkupdate.svg</file>
		<file>scalable/copy.svg</file>
		<file>scalable/coremods.svg</file>
		<file>scalable/externaltools.svg</file>
		<file>scalable/instance-settings.svg</file>
		<file>scalable/jarmods.svg</file>
		<file>scalable/java.svg</file>
		<file>scalable/loadermods.svg</file>
		<file>scalable/log.svg</file>
		<file>scalable/minecraft.svg</file>
		<file>scalable/multimc.svg</file>
		<file>scalable/new.svg</file>
		<file>scalable/news.svg</file>
		<file>scalable/notes.svg</file>
		<file>scalable/patreon.svg</file>
		<file>scalable/proxy.svg</file>
		<file>scalable/quickmods.svg</file>
		<file>scalable/refresh.svg</file>
		<file>scalable/resourcepacks.svg</file>
		<file>scalable/screenshots.svg</file>
		<file>scalable/settings.svg</file>
		<file>scalable/status-bad.svg</file>
		<file>scalable/status-good.svg</file>
		<file>scalable/status-yellow.svg</file>
		<file>scalable/viewfolder.svg</file>
	</qresource>
</RCC>

Example theme file:
[Icon Theme]
Name=pe_colored
Comment=Icons by pexner (colored)
Inherits=multimc
Directories=scalable

[scalable]
Size=48
Type=Scalable
MinSize=16
MaxSize=256


Everything inherits from the main (multimc) theme.
Comment 6 Minh Ngo 2015-05-17 10:03:46 UTC
Possibly there is the same problem in this small demo https://github.com/F1ash/bug-demo

It can be built for Qt4 and Qt5 via following commands:
1) for Qt4: mkdir build && cd build && cmake ../ -DBUILD_QT_VERSION=4
2) for Qt5: mkdir build && cd build && cmake ../ -DBUILD_QT_VERSION=5

And then an icon also doesn't appear in the Qt5 demo on the KDE5 (Fedora 22).
Comment 7 Minh Ngo 2015-05-17 10:06:51 UTC
Created attachment 92651 [details]
Bug demo

Adding a source archive here in the case if the author (not me :) ) of this bug demo will decide to remove the repository.
Comment 8 Fl@sh 2015-06-13 10:22:43 UTC
i'm created the new, more correctly test. It tested on openbox and within KF5/Plasma5. Bug is still.
If iconTheme is uploaded, then Terminator is visible, else system "face-sad" icon is visible.
Comment 9 Fl@sh 2015-06-13 10:24:23 UTC
Created attachment 93148 [details]
new bug_demo
Comment 10 Sune Vuorela 2015-06-16 06:06:01 UTC
I've submitted the following patch upstream https://codereview.qt-project.org/#/c/114415/
Comment 11 Petr Mrázek 2015-08-15 16:22:58 UTC
Hello again.

I tried removing the QIcon fork from my application and using normal QIcon from Qt 5.5.0 (Arch linux packages).

It's still a problem.

Was this pushed to the actual 5.5(.0), or will this appear in some later Qt release?
Comment 12 Rex Dieter 2015-08-15 16:51:20 UTC
It was committed after 5.5.0 tag/release
Comment 13 Petr Mrázek 2015-08-15 17:20:54 UTC
Created attachment 94047 [details]
attachment-28603-0.html

Alright. Good to know. I'll upgrade to a later 5.5 release :)

On Sat, Aug 15, 2015 at 6:51 PM, Rex Dieter <rdieter@math.unl.edu> wrote:

> https://bugs.kde.org/show_bug.cgi?id=344469
>
> --- Comment #12 from Rex Dieter <rdieter@math.unl.edu> ---
> It was committed after 5.5.0 tag/release
>
> --
> You are receiving this mail because:
> You reported the bug.
>
Comment 14 David Faure 2016-07-15 22:42:58 UTC
So this is fixed in Qt, right ?
 (-> closing, please reopen if I misunderstood)