class KIconLoader

Icon loader with caching. More...

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

Public Types

Public Methods

Protected Methods

Protected Members


Detailed Description

Icon loader with caching.

Multiple loads of the same icon using this class will be cached using QPixmapCache, saving memory and loading time.

Within KDE there are two distinct groups of Icons:

Icons are searched for according to the KDE file system standard using KStandardDirs. Look up the various methods for details how.

All keys used in QPixmapCache by this class have the "$kico_.." prefix.

enum Size {Small = 0, Medium, Large, Default }

Specifies the size of the requested icon:

 KIconLoader ( const QString &app_name = QString::null )

Constructor. Adds some application specific paths to lookup toolbar icons. These are below the application's data dir (@see KStandardDirs for details) and are namely pics/ and toolbar/

Parameters:
app_namespecifies the name of the application to add paths of. If the name is null (default) the name from KGlobal::instance() is used.

 KIconLoader ( const KInstance* library )

Constructs an KIconLoader for a component stored in a shared library. Objects constructed with this constructor access all instance related data (search paths, application name) from the given library instead of KGlobal::instance().

QPixmap  reloadIcon ( const QString& name)

Load an icon from disk without cache.

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. The returned pixmap will be inserted in the cache so you use loadIcon after that.

QPixmap  loadIcon ( const QString& name, Size size = Default, QString *path_store = 0, bool can_return_null = true )

This method should be used for loading most non-toolbar icons (it @bf will load toolbar icons, but the recommended way is to use BarIcon).

Parameters:
nameIcon name without extension. An example is @p "konqueror" or @p "mimetypes/postscript"
sizeThe prefered size to load.
path_storeThis output parameter will contain the full path to the icon if not 0.
canReturnNullIf this is false, this function will return the "unknown" icon if the requested icon is not found. The default is to return null.

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

Get the complete path for a toolbar icon name.

Parameters:
nameThe name of the icon to search for.
always_validIf true, the function will return the path to "unknown" if the icon is not found. Note that it will return null if "unknown" was also not found.

Returns: The physical path to the named icon.

QStringList  iconDirs (const QString& type = QString::fromLatin1("all"), const QString& depth = QString::fromLatin1("all"), const QString& size = QString::fromLatin1("all"), bool trim = true)

[const]

This will return a list of all icon directories that match the given parameters. With the default params, this will return all KDE recognized icon directories that currently exist. By changing the params, you can narrow this down to specifics.

For instance:


 iconDirs("all", "hicolor", "large");

Will return all directories that have large hicolor icons.

Parameters:
typeThe icon type (apps, devices, filesystems, mimetypes, toolbars, or all)
depthThe color depth (hicolor, locolor, or all)
sizeThe icon size (large, medium, small, or all)
trimIf true, then only existing directories will be returned

Returns: A list of all icon directories that match the params

QPixmap  loadInternal ( const QString& name, bool honourcache = true )

[protected]

honourcache will check if the icon is contained in the cache before trying to load it. Used by loadIcon and reloadIcon (with different honourcache parameter)