Icons on the system tray
Antonio Larrosa Jiménez
larrosa at kde.org
Wed Aug 27 20:32:32 BST 2003
Recently Martijn Klingens made me notice the situation of the icons in the
system tray. The problem is that every application currently loads the
icon in a different way, as a result, some are applied the Toolbar icon
effects, others are applied the Small icon effects, others are User icons
(with no effects). Evenmore, some of them had hardcoded sizes which made
it even less homogeneous.
What I've done is to add a method to KSystemTray that you can pass the name
of your icon (standard themed icon, not user icons!) and it returns the
pixmap with the correct effects applied for the panel icons and the
correct size for the icons (so that they're all the same size, look at
I've gone all though cvs and fixed all the applications that I found to use
this scheme. In the meantime, I've also fixed a couple of icon issues of
some of these applications.
Usually you should just do setPixmap( loadIcon( "mystate" ) ) in the
constructor of the class that inherits from KSystemTray in your app.
mystate should be the name of a standard 22x22 action (or app) icon
usually, that is, you should have cr22-action-mystate.png icon in your
sources and use
myappicondir = $(kde_datadir)/myapp/icons
myappicon_ICON = AUTO
in your Makefile.am.
If your application has some special needs and you prefer to load the icon
by yourself (like kxkb, which loads the icon and then uses them for the
system tray and for the popup menu), then you better load them using the
NoGroup group (please don't ask if "NoGroup" is a group :) ) calling
KGlobal::instance()->iconLoader()->loadIcon(...) and then
apply the effect by yourself using KIconEffect::apply(pixmap/image,
If you are working on an application in cvs which hasn't been fixed, or are
working on an application outside of KDE's cvs which opens an icon in the
system tray, please modify your app to use the guides above or include
code similar to the implementation of KSystemTray::loadIcon in your app if
you have to mantain compatibility to 3.x (x<2).
I've already modified the following applications to use this scheme:
kppp (I fixed this one, but won't commit until someone which uses kppp can
test that it works as expected, if you can help, please send me a email).
I'll commit those fixes in the next minutes. If something doesn't compile
for you, remember to do "cvs update ksystemtray.cpp ksystemtray.h" on
Antonio Larrosa Jimenez
KDE developer - larrosa at kde.org
Premature optimization is the root of all evil. -- D.E. Knuth
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
More information about the kde-core-devel