class KIconLoader

KIconLoader is a derived class from QObject. More...

Definition#include <kiconloader.h>
InheritsQObject (qt)
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Members

Protected Members


Detailed Description

KIconLoader is a derived class from QObject. It supports loading of icons from disk. It puts the icon and its name into a QList and if you call loadIcon() for a second time, the icon is taken out of the list and not reread from disk. So you can call loadIcon() as many times as you wish and you don't have to take care about multiple copies of the icon in memory.

KIconLoader ( KConfig *conf, const QString &app_name, const QString &var_name )

config is the pointer to a KConfig object; normally the global KConfig object. group is the name of a group in a config file. key is the name of an entry within this group.

Normaly group == "KDE Setup" and key == "IconPath" Example for an entry in .kderc: [KDE Setup] IconPath=/usr/local/lib/kde/lib/pics:/usr/local/lib/kde/lib/pics/toolbar

This gives KIconLoader the path to search the icons in.

If you want to use another path in your application then write into your .my_application_rc: [MyApplication] PixmapPath=/..../my_pixmap_path and call KIconLoader( config, "MyApplication", "PixmapPath" ).

KIconLoader ()

There now exists a simple-to-use version of KIconLoader. If you create a KIconLoader without giving arguments, KIconLoader searches for the path in [KDE Setup]:IconPath=... as a default.

QPixmap loadIcon ( const QString &name, int w = 0, int h = 0 )

This function searches for the icon called name and returns a QPixmap object of this icon if it was found and 0 otherwise. If name starts with "/..." loadIcon treats it as an absolut pathname. LoadIcon() creates a list of all loaded icons, so calling loadIcon() a second time with the same name argument won't load the icon again, but gets it out of its cache. By this you don't have to worry about multiple copies of one and the same icon in memory, and you can call loadIcon() as often as you like.

If the icon is larger then the specified size, it is scaled down automatically. If the specified size is 0, the icon is not scaled at all.

QPixmap reloadIcon ( const QString &name, int w = 0, int h = 0)

Same like loadIcon, except that cached icons will be reloaded. This is useful if the icon has changed on the filesystem and you want to be sure that you get the new version, not the old one from the cache.

QPixmap loadMiniIcon ( const QString &name , int w = 0, int h = 0 )

Same like loadIcon, but looks for "mini/name" first.

bool insertDirectory ( int index, const QString &dir_name )

This functions inserts a new directory into the searchpath at position index. It returns TRUE if successful, or FALSE if index is out of range. Note that the default searchpath looks like this:

1: $HOME/.kde/share/apps/<appName>/pics 2: $KDEDIR/share/apps/<appName>/pics 3: $HOME/.kde/share/apps/<appName>/toolbar 4: $KDEDIR/share/apps/<appName>/toolbar

5: $HOME/.kde/share/icons 6: $HOME/.kde/share/toolbar

7: $KDEDIR/share/icons 8: $KDEDIR/share/toolbar

9-x: list of directories in [KDE Setup]:IconPath=...

QString getIconPath ( const QString &name, bool always_valid=false)

Set always_valid to true if you want this function to return a valid pixmap is your wishes cannot be satisfied (Be aware, that if unknown.xpm is not found you will receive a null string)

void flush ( const QString &name )

Remove an icon from the cache given it's name


Generated by: root@porky.devel.redhat.com on Mon Feb 21 16:51:01 200.