[Development] Supporting freedesktop icon themes in Qt5

Olivier Goffart olivier at woboq.com
Thu May 10 13:43:26 CEST 2012


On Thursday 10 May 2012 11:54:45 Jerome Leclanche wrote:
> On Thu, May 10, 2012 at 8:27 AM, Pier Luigi 
<pierluigi.fiorini at gmail.com>wrote:
> > 2012/5/10 Jerome Leclanche <adys.wh at gmail.com>:
> > > Morning
> > > 
> > > Qt currently does not properly support icon themes on Linux. This is a
> > 
> > big
> > 
> > > issue here for Razor [1] as we're a non-KDE-based DE trying to use pure
> > > Qt. QIcon::fromTheme has some heuristics for KDE and Gnome, but other
> > > DEs
> > > are not supported. [2]
> > > We'd like to get this fixed for Qt5.0. My first attempt at getting it
> > 
> > fixed
> > 
> > > was through a proposal for icon theme configuration, which was (rightly)
> > > rejected by the GTK team. After talking with them, they explained how
> > 
> > they
> > 
> > > use xsettings for it [3] -- kde has a kde-xsettings plugin which
> > 
> > implements
> > 
> > > xsettings on KDE too, so that could theoretically be used there too.
> > 
> > However
> > 
> > > it also means Qt is going to need an xsettings backend.
> > > 
> > > I linked a discussion post about it on #qt-labs yesterday, log below:
> > > <girishr_> Adys: sounds acceptable to me. we only don't allow api
> > 
> > changes at
> > 
> > > this point
> > > <girishr_> Adys: any fixes to make desktop integration better are
> > > welcome
> > > <Adys> girishr_: it would be an internal change, but depending on how
> > > big
> > > xsettings support would have to be, it'd be a large changeset
> > > <girishr_> Adys: i don't think we had xsettings in qt, so i think the
> > 
> > post
> > 
> > > is correct that Qt needs to have an implementation of that first
> > > <girishr_> Adys: it affects only xcb plugin, so shouldn't be a problem
> > > <girishr_> Adys: sroedal is the xcb maintainer afaik
> > > 
> > > I'm not qualified to work on something like this, and the rest of the
> > 
> > Razor
> > 
> > > team isn't too available currently, so this is mostly a FYI post. I was
> > > really hopeful to have this issue fixed for Qt 5.0, so if someone wants
> > 
> > to
> > 
> > > or is planning to work on it I'd love to know.
> > > 
> > > [1] http://razor-qt.org/
> > > [2]
> > 
> > https://qt.gitorious.org/qt/qt/blobs/4.8/src/gui/kernel/qguiplatformplugin
> > .cpp#line201> 
> > > [3] http://git.gnome.org/browse/gtk+/tree/gdk/x11/gdksettings.c
> > 
> > Icon themes works very well for me in my desktop environment, you
> > should write a platform theme plugin (QPlatformTheme) which reads
> > Razor settings.
> > If the DESKTOP_SESSION environment variable contains the name of your
> > plugin, it will be used.
> > 
> > --
> > "Don't let the noise of other's opinions drown out your own inner
> > voice." (Steve Jobs)
> 
> I've never heard of that method until now. It doesn't seem like the correct
> answer for a few reasons though:
>  - $DESKTOP_SESSION has been deprecated in multiple DEs in favour of
> $XDG_CURRENT_DESKTOP
>  - That method requires every DE to write their own Qt plugin *and* their
> own icon theme settings engine.
> That's to say, it assumes that the DE itself wants to store icon theme
> settings, when a simple third party app could be doing it. (Razor is
> extremely lightweight and tries to rely as much as possible on third party
> application integration)
> 
> However, if the DE stores the icon theme in xsettings:
>  - Any app is able to change it without having to read every custom
> settings engine known to mankind
>  - Any app is able to tell the *current* icon theme, not specifically the
> *preferred* one (Reading settings only gets you so far)
>  - The DE gets automatic integration with Qt *without* having to write its
> own plugin.

I think you don't have to convince us to the supperiority of XSettings.
But I wrote the code in QGuiPlarformPlugin.cpp that way because at the time, 
this was the only way, and there was no XSettings for this.

Qt used to read other things from the XSettings. In the function 
qt_set_x11_resources Qt 4's qapplication_x11.h, we read the color scheme.
I think with the move to QPA, this code has been lost. (notice that the color 
scheme read there is less complete than the color scheme read by the config 
file)

The theme plugins are just the way Qt choose to integrate best into every unix 
environement. It the best way since a lot of things or settings are not part 
of any common specification between DE.
This is why you probably will need to create a "razor" theme plugin anyway for 
every settings for which you have no choice (eg, if you want to implement a 
file dialog).

But I agree XSettings should be handled.
So you probably should open a bug report about this issue. (And the best would 
be that you also contribute the patches for it, else, I don't know who will 
:-) )

-- 
Olivier

Woboq - Qt services and support - http://woboq.com




More information about the Development mailing list