Jens
Qt
KDE
Posted by Jens
 in Qt, KDE
 on Tuesday, October 27, 2009 @ 10:09

Someone sent me an e-mail asking what happened to the freedesktop icons I blogged about back in february so I realized I should probably write a followup. I’m happy to say that it has been merged into Qt 4.6 for some time already. If you look up the documentation for QIcon, you will find a new function QIcon::fromTheme(…) which essentially does what QtIconLoader::icon(…) did. Meaning Qt applications can now make use of the icon themes that KDE and GNOME ship with and use by default.

Since freedesktop icon themes only come as standard on X11 based desktops, you cannot use themed icons on other platforms such as Windows and Mac directly. This will simply return the fallback icon you provide. Allowing this would have forced us to decide on a standard icon theme as well as bloat the application by an extra few megabytes that many applications do not need. Instead we decided to leave this choice entirely up to the developer by making it possible to bundle themes such as Oxygen or Tango as part of the application resources and pointing to it using QIcon::setThemeName(…) instead.

This should make those pure Qt applications look a lot more integrated into the X11 desktop! Among other things, our trusty old Assistant client was modified to use the theme icons:

assistant

Screenshot showing of Assistant running on GNOME in 4.6.

Assistant KDE

Here is the same application running on KDE 4.

16 Responses to “Update on standard icons in Qt”

» Posted by SABROG
 on Tuesday, October 27, 2009 @ 15:55

Can i use themes and icons for commercial application on Qt? They all in GPL license?

» Reply from Jens
 on Tuesday, October 27, 2009 @ 16:25
Jens

SABROG: Yes you can. When you use standard icons on X11 you will load them dynamically from the computer using the current system configuration. This should not have any impact on the licensing of your application. This is no different to what you are already doing with current folder and file icons in Qt.

The question really only becomes relevant if you bundle a theme together with your application. (which is really not recommended on X11 as it beats the purpose of standard icons) In this case you have to read the license that the theme comes with. For instance the Oxygen has a few restrictions as listed in the legal part of their site:
http://www.oxygen-icons.org/?page_id=4 while the Tango project recently became public domain, meaning you can essentially do whatever you want with it.

» Posted by GNOME user
 on Tuesday, October 27, 2009 @ 21:19

Great development. We need look-like-native qt apps in GNOME/Ubuntu ;] does it suports also icons inside menu and context menu?

» Reply from Jens
 on Wednesday, October 28, 2009 @ 08:37
Jens

GNOME user: Certainly, the icons are normal scalable QIcons that adjust to your desktop settings dynamically. You use them wherever you would place normal Qt icons. Keep in mind that in the new GNOME 2.28, menus no longer have icons by default and Qt will respect. If you want icons to show in menus on the next iteration of GNOME/Ubuntu you will need to specifically enable this in the Appearance/Interface tab or force it by explicitly setting the iconsVisibleInMenu property on QAction.

» Posted by EuroElessar
 on Wednesday, October 28, 2009 @ 19:14

It’s great possibility! But what about fallbacks? If there is no icon “input-mouse-usb” in theme will IconLoader engine try to load icon “input-mouse”?

» Reply from Jens
 on Wednesday, October 28, 2009 @ 19:47
Jens

The fallbacks for devices are part of the naming convention not the icon lookup itself. But QIcon::fromTheme has a second and optional fallback argument that makes it possible to do this :

QIcon genericIcon = QIcon::fromTheme(”input-mouse”); // or alternatively use a pixmap
QIcon usbMouseIcon = QIcon::fromTheme(”input-mouse-usb”, genericIcon);
QIcon ps2MouseIcon = QIcon::fromTheme(”input-mouse-ps2″, genericIcon);

If you do not pass a fallback the function will simply return a null icon.

» Posted by tatami
 on Thursday, October 29, 2009 @ 01:09

Good job.

Is there a function to get a icon’s name in a icon theme directory in Qt, by default ?

» Posted by tatami
 on Thursday, October 29, 2009 @ 01:17

Sorry, I posted wrong question. The question I wanted to post is as follows.

Is there a function to get a icon’s names list in a icon theme directory from in Qt, by default ?

» Posted by tatami
 on Thursday, October 29, 2009 @ 01:42

Sorry, The question I wanted to post is as follows.

Is there a function to get a icon’s names list in a icon theme directory in Qt, by default ?

» Posted by EuroElessar
 on Thursday, October 29, 2009 @ 05:40

Thanks, Jens.
By the way, there is well known fact that there are animated icons in freedesktop.org standart… so are there any plans for supporting of them?

» Posted by EuroElessar
 on Thursday, October 29, 2009 @ 11:45

And also I hope the last question: will be there any api for getting paths to icons? i.e. path to input-mouse-usb.png with size 32×32 or to svg one.

» Posted by Pat
 on Friday, October 30, 2009 @ 14:25

Now if only that font hinting bug that gets triggered when ttf-arphic-uming is installed were fixed…

» Posted by Alessandro
 on Saturday, October 31, 2009 @ 09:57

@Pat: Which bug ID on http://bugreports.qt.nokia.com/ is the one you mean?

» Posted by Pat
 on Tuesday, November 03, 2009 @ 21:11

This used to be in the Qt bug database, though I can’t find it. I have it noted that:

http://ubuntuforums.org/showthread.php?t=672272

had a link to the bug, but that URL is dead now.

Anyway, it seems to be worked around in most distributions. Whereas ttf-arphic-uming used to set:

false
true
false

They now set:

true

Whereas the former magically propagated to all fonts under Qt, the latter works, because it only applies to fonts with embedded bitmap information. Also, in recent versions, upstream has turned on the embeddedbitmap flag to true by default for all fonts.

» Posted by Pat
 on Tuesday, November 03, 2009 @ 21:13

Hm. It stripped out all of the fontconfig XML. I’ll type it out differently.

edit name=antialias -> false
edit name=hinting -> true
edit name=autohint -> false

Now it’s just:

edit name=embeddedbitmap -> true

» Posted by Julien
 on Wednesday, November 11, 2009 @ 13:48

That is such a cool feature !!!! Thanks !
How about integrating it into the Designer (and integrating the QStyle::StandardPixmap as well :-) ) ?



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.