QToolBar Icons not loaded properly.

Bug #1306472 reported by Giles Bathgate
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
appmenu-qt5
Fix Released
High
Łukasz Zemczak
appmenu-qt5 (Ubuntu)
Fix Released
Undecided
Łukasz Zemczak

Bug Description

When using a QToolBar with a basic Qt application, the icons can be populated from a theme. Either using QIcon::FromTheme(), or setting them in the associated action using the forms designer in Qt. (The name given for the icon is the freedesktop.org standard naming convention)

Under appmenu-qt5 these icons do not appear to be being loaded correctly, resulting in a toolbar populated with just the action text.

A minimal example illustrates the problem here: https://github.com/GilesBathgate/appmenu-bug

Related branches

Revision history for this message
Giles Bathgate (gilesbathgate) wrote :

Prognosis: My understanding is that appmenu-qt5 is not reporting an IconThemeName. The QIconLoader needs this to figure out which icon set to load. If the IconThemeName is blank it falls back to a different ion theme, and if this fails it falls back to just no icons.

When using:

QIcon::themeName();

With QT_QPA_PLATFORMTHEME set, the function would return blank, but with it unset it would return "ubuntu-mono-dark"

Changed in appmenu-qt5:
assignee: nobody → Łukasz Zemczak (sil2100)
importance: Undecided → Medium
importance: Medium → High
status: New → In Progress
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Sadly, today I still didn't have time to look into this in detail, but it's as I already mentioned in the e-mail - your prognosis might be somewhat correct. appmenu-qt5 'inherits' from existing platformthemes, i.e. GnomeTheme and KdeTheme classes - theoretically it should normally return the theme name as if it was the default gnome theme. But there might be something going on because there's a separate gtk platformtheme plugin that's used by default now in Qt 5.2. But I have to look into that finally.

Thanks again for reporting!

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Now this is strange. I cannot reproduce it on my system. When switching to 'show the menus for a window: In the menu bar' with my appmenu-qt5 installed and latest Qt5.2.1 from the archives, I get the test application you have provided working as expected. I can see both the icons on the toolbar and in the menu entries.

Could you give me some more info about the system you are running? What Qt versions are you using, what is the currently installed appmenu-qt5? Is it a freshly installed system, or after an upgrade?

Changed in appmenu-qt5:
status: In Progress → Incomplete
Revision history for this message
Giles Bathgate (gilesbathgate) wrote :

Here is a complete transcript of how I set the system up:

* Fresh new virtualbox machine installed with ubuntu-14.04-beta2-desktop-amd64.iso
* Step through the wizard choosing all the defaults, English(UK) locale selected.
* Once the machine has booted, launch a terminal and run the following
* sudo apt-get install virtualbox-guest-x11
* sudo apt-get update && sudo apt-get dist-upgrade
* sudo reboot
* Open a terminal again after reboot
* sudo apt-get install qtcreator
* sudo apt-get install git
* git clone https://github.com/GilesBathgate/appmenu-bug
* cd appmenu-bug
* qmake
* make
* ./appmenu-bug

Revision history for this message
Giles Bathgate (gilesbathgate) wrote :

I have also discovered that, if you install gnome-icon-theme-full, then the toolbar icons are displayed again. But these are the incorrect icons. and you then get different icons if you run with:

QT_QPA_PLATFORMTHEME= ./appmenu-bug

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Yes, there will sadly be different icons due to the thing I mentioned before - since Qt 5.2 there is a separate gtk2 platformtheme, and it's most likely using a different icon theme than GnomeTheme which is used by appmenu-qt5 (and used by default in Qt5 below 5.2). There is no easy way to make appmenu-qt5 use the gtk2 platformtheme from Qt as it's implemented as a loadable platformplugin, just as appmenu-qt5. So, it means we would have to either:
- copy-paste the gtk2 platformthemeplugin code to appmenu-qt5, creating something that can easily desynchronize and get out-of-date
- edit appmenu-qt5 itself to override GnomeTheme's themeHint() to return the icontheme we want to have on our system

I would opt for the second approach, but since it's not something highly critical, I would still wait with that a bit.

On the other hand, I will look into why only gnome-icon-theme-full has the icons we need and how we can change that to at least have everything working without that package installed. From what I see gnome-icon-theme-full is not seeded by default in the images right now, so it's a serious problem nevertheless. But this part of the problem which is basically unrelated to appmenu-qt5 directly.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Just a quick update: I made a quick-workaround in appmenu-qt5 which works (i.e. implementing the second solution I mentioned in my earlier comment). I still will look for other ways to work-around this, since I would prefer not to include more theme-specific logic into appmenu-qt5, but if I won't find any other solution we'll go with this one.

Thanks for all the input!

Revision history for this message
Giles Bathgate (gilesbathgate) wrote :

After doing a bit more digging over the weekend, I build a debug version of qt from the trusty sources (apt-get source) which included your patches. I had come to the same conclusion that it was something involved with the "Theme Hint", so I think that would be the way to go...

One thing I did note with regard to your comment is that you imply that ubuntu-mono-dark is a gtk2 theme, whereas the new code is using gtk3, but I don't think this is the case. The package ubuntu-mono in trusty, which contains the ubuntu-mono-dark icons:

http://packages.ubuntu.com/trusty/ubuntu-mono depends on http://packages.ubuntu.com/trusty/gnome-icon-theme, which is a gtk3 theme, implied by the fact that it depends on libgtk-3-bin

I don't know if you noticed, but I added a diagnostic label to the project at : https://github.com/GilesBathgate/appmenu-bug

When I run this under QT_QPA_PLATFORMTHEME=appmenu-qt5 ./appmenu-bug The label shows 'gnome'
When I run this under QT_QPA_PLATFORMTHEME= ./appmenu-bug The label shows 'ubuntu-mono-dark'

It might be a good test for your fix to see if with the fix applied both invocations report the same theme (i.e. ubuntu-mono-dark)

Thanks for your work on this.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Yeah, it's all because the GnomeTheme which appmenu-qt5 uses returns a static "gnome" as the icontheme, while the gtk2 themeplugin picks up the icon-theme name from the settings. It's all a bit unfortunate all of this, and from what I see my quick-workaround will probably be the only way to resolve it nicely...

Changed in appmenu-qt5:
status: Incomplete → In Progress
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

I have pushed a package with the workaround to my test PPA, it's currently building but it should be available soon for testing:

ppa:sil2100/qt
Package: appmenu-qt5 0.3.0+14.04.20140314-0ubuntu2~ppa1

Revision history for this message
Giles Bathgate (gilesbathgate) wrote :

I've tested the proposed fix from the PPA. As far as I am concerned this solves the problem.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Thanks for testing! The merge got reviewed and I just scheduled it for release.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package appmenu-qt5 - 0.3.0+14.04.20140415-0ubuntu1

---------------
appmenu-qt5 (0.3.0+14.04.20140415-0ubuntu1) trusty; urgency=low

  [ Łukasz 'sil2100' Zemczak ]
  * When working with a Gnome/GTK theme, do the same thing as the gtk2
    platformtheme plugin does - fetch the SystemIconThemeName (and its
    fallback) from settings in the system (LP: #1306472)
 -- Ubuntu daily release <email address hidden> Tue, 15 Apr 2014 10:27:05 +0000

Changed in appmenu-qt5 (Ubuntu):
status: New → Fix Released
Changed in appmenu-qt5:
status: In Progress → Fix Released
Changed in appmenu-qt5 (Ubuntu):
assignee: nobody → Łukasz Zemczak (sil2100)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.