kdecore Library API Documentation

KIconLoader Class Reference

Iconloader for KDE. More...

#include <kiconloader.h>

List of all members.

Public Methods

 KIconLoader (const QString &appname=QString::null, KStandardDirs *dirs=0)
 ~KIconLoader ()
void addAppDir (const QString &appname)
QPixmap loadIcon (const QString &name, KIcon::Group group, int size=0, int state=KIcon::DefaultState, QString *path_store=0L, bool canReturnNull=false) const
QIconSet loadIconSet (const QString &name, KIcon::Group group, int size, bool canReturnNull)
QIconSet loadIconSet (const QString &name, KIcon::Group group, int size=0)
QString iconPath (const QString &name, int group_or_size, bool canReturnNull=false) const
QMovie loadMovie (const QString &name, KIcon::Group group, int size=0) const
QString moviePath (const QString &name, KIcon::Group group, int size=0) const
QStringList loadAnimated (const QString &name, KIcon::Group group, int size=0) const
QStringList queryIcons (int group_or_size, KIcon::Context context=KIcon::Any) const
QStringList queryIconsByContext (int group_or_size, KIcon::Context context=KIcon::Any) const
QStringList queryIconsByDir (const QString &iconsDir) const
int currentSize (KIcon::Group group) const
KIconThemetheme () const
KIconEffecticonEffect () const
void reconfigure (const QString &_appname, KStandardDirs *_dirs)
bool alphaBlending (KIcon::Group group) const
void addExtraDesktopThemes ()
bool extraDesktopThemesAdded () const
void enableDelayedIconSetLoading (bool enable)
bool isDelayedIconSetLoadingEnabled () const

Static Public Methods

QPixmap unknown ()

Related Functions

(Note that these are not member functions.)

QPixmap DesktopIcon (const QString &name, int size=0, int state=KIcon::DefaultState, KInstance *instance=KGlobal::instance())
QPixmap DesktopIcon (const QString &name, KInstance *instance)
QIconSet DesktopIconSet (const QString &name, int size=0, KInstance *instance=KGlobal::instance())
QPixmap BarIcon (const QString &name, int size=0, int state=KIcon::DefaultState, KInstance *instance=KGlobal::instance())
QPixmap BarIcon (const QString &name, KInstance *instance)
QIconSet BarIconSet (const QString &name, int size=0, KInstance *instance=KGlobal::instance())
QPixmap SmallIcon (const QString &name, int size=0, int state=KIcon::DefaultState, KInstance *instance=KGlobal::instance())
QPixmap SmallIcon (const QString &name, KInstance *instance)
QIconSet SmallIconSet (const QString &name, int size=0, KInstance *instance=KGlobal::instance())
QPixmap MainBarIcon (const QString &name, int size=0, int state=KIcon::DefaultState, KInstance *instance=KGlobal::instance())
QPixmap MainBarIcon (const QString &name, KInstance *instance)
QIconSet MainBarIconSet (const QString &name, int size=0, KInstance *instance=KGlobal::instance())
QPixmap UserIcon (const QString &name, int state=KIcon::DefaultState, KInstance *instance=KGlobal::instance())
QPixmap UserIcon (const QString &name, KInstance *instance)
QIconSet UserIconSet (const QString &name, KInstance *instance=KGlobal::instance())
int IconSize (KIcon::Group group, KInstance *instance=KGlobal::instance())


Detailed Description

Iconloader for KDE.

KIconLoader will load the current icon theme and all its base themes. Icons will be searched in any of these themes. Additionally, it caches icons and applies effects according the the user's preferences.

In KDE, it is encouraged to load icons by "Group". An icon group is a location on the screen where icons are being used. Standard groups are: Desktop, Toolbar, MainToolbar, Small and Panel. Each group has some centrally configured properties bound to it, including the icon size and effects. This makes it possible to offer a consistent icon look in all KDE applications.

The standard groups are defined below.

The icons are stored on disk in an icon theme or in a standalone directory. The icon theme directories contain multiple sizes and/or depths for the same icon. The iconloader will load the correct one based on the icon group and the current theme. Icon themes are stored globally in share/icons, or, application specific in share/apps/$appdir/icons.

The standalone directories contain just one version of an icon. The directories that are searched are: $appdir/pics and $appdir/toolbar. Icons in these directories can be loaded by using the special group "User".

Definition at line 79 of file kiconloader.h.


Constructor & Destructor Documentation

KIconLoader::KIconLoader const QString   appname = QString::null,
KStandardDirs   dirs = 0
 

Constructs an iconloader.

Parameters:
appname  Add the data directories of this application to the icon search path for the "User" group. The default argument adds the directories of the current application.
dirs  the KStandardDirs object to use. If null the global one is used
Usually, you use the default iconloader, which can be accessed via KGlobal::iconLoader(), so you hardly ever have to create an iconloader object yourself. That one is the current KInstance's (typically KApplication's) iconloader.
See also:
KGlobal::iconLoader() , KInstance::iconLoader()

Definition at line 141 of file kiconloader.cpp.

KIconLoader::~KIconLoader  
 

Cleanup.

Definition at line 240 of file kiconloader.cpp.


Member Function Documentation

void KIconLoader::addAppDir const QString   appname
 

Adds appname to the list of application specific directories.

Parameters:
appname  The application name.

Definition at line 259 of file kiconloader.cpp.

References KStandardDirs::kde_default().

QPixmap KIconLoader::loadIcon const QString   name,
KIcon::Group    group,
int    size = 0,
int    state = KIcon::DefaultState,
QString   path_store = 0L,
bool    canReturnNull = false
const
 

Loads an icon.

It will try very hard to find an icon which is suitable. If no exact match is found, a close match is searched. If neither an exact nor a close match is found, a null pixmap or the "unknown" pixmap is returned, depending on the value of the canReturnNull parameter.

Parameters:
name  The name of the icon, without extension.
group  The icon group. This will specify the size of and effects to be applied to the icon.
size  If nonzero, this overrides the size specified by group. See KIcon::StdSizes.
state  The icon state: DefaultState, ActiveState or DisabledState. Depending on the user's preferences, the iconloader may apply a visual effect to hint about its state.
path_store  If not null, the path of the icon is stored here.
canReturnNull  Can return a null pixmap? If false, the "unknown" pixmap is returned when no appropriate icon has been found.
Returns:
the QPixmap. Can be null when not found, depending on canReturnNull.

Definition at line 544 of file kiconloader.cpp.

References KIcon::Any, QString::at(), KIcon::context, QPixmap::convertFromImage(), QImage::copy(), QPixmap::createHeuristicMask(), KIcon::DefaultState, QPixmapCache::find(), QString::fromLatin1(), KIcon::Group, QPixmap::height(), QImage::height(), KIcon::HiddenOverlay, iconPath(), QPixmapCache::insert(), QString::isEmpty(), QImage::isNull(), QPixmap::isNull(), KIcon::isValid(), KStdAccel::key(), KIcon::LastState, QString::latin1(), KIconTheme::linkOverlay(), KIcon::LinkOverlay, KIconTheme::lockOverlay(), KIcon::LockOverlay, QPixmap::mask(), QString::number(), KIconEffect::overlay(), KIcon::path, QString::right(), KIcon::Scalable, QImage::scanLine(), QPixmap::setMask(), KIconTheme::shareOverlay(), KIcon::ShareOverlay, QImage::smoothScale(), QString::startsWith(), KGlobal::staticQString(), theme(), KIcon::Threshold, KIcon::threshold, KIcon::type, QPixmap::width(), QImage::width(), KIconTheme::zipOverlay(), and KIcon::ZipOverlay.

Referenced by BarIcon(), DesktopIcon(), KWin::icon(), loadIconSet(), MainBarIcon(), SmallIcon(), and UserIcon().

QIconSet KIconLoader::loadIconSet const QString   name,
KIcon::Group    group,
int    size,
bool    canReturnNull
 

Creates an icon set, that will do on-demand loading of the icon.

Loading itself is done by calling loadIcon .

Parameters:
name  The name of the icon, without extension.
group  The icon group. This will specify the size of and effects to be applied to the icon.
size  If nonzero, this overrides the size specified by group. See KIcon::StdSizes.
canReturnNull  Can return a null iconset? If false, iconset containing the "unknown" pixmap is returned when no appropriate icon has been found.
Returns:
the icon set. Can be null when not found, depending on canReturnNull.
Since:
3.1

Definition at line 1107 of file kiconloader.cpp.

References KIcon::DefaultState, KIcon::Group, QIconSet::installIconFactory(), QPixmap::isNull(), and loadIcon().

Referenced by BarIconSet(), DesktopIconSet(), loadIconSet(), MainBarIconSet(), SmallIconSet(), and UserIconSet().

QIconSet KIconLoader::loadIconSet const QString   name,
KIcon::Group    group,
int    size = 0
 

Creates an icon set, that will do on-demand loading of the icon.

Loading itself is done by calling loadIcon .

Parameters:
name  The name of the icon, without extension.
group  The icon group. This will specify the size of and effects to be applied to the icon.
size  If nonzero, this overrides the size specified by group. See KIcon::StdSizes.
Returns:
the icon set. Can be null when not found

Definition at line 1085 of file kiconloader.cpp.

References KIcon::Group, and loadIconSet().

QString KIconLoader::iconPath const QString   name,
int    group_or_size,
bool    canReturnNull = false
const
 

Returns the path of an icon.

Parameters:
name  The name of the icon, without extension. If an absolute path is supplied for this parameter, iconPath will return it directly.
group_or_size  If positive, search icons whose size is specified by the icon group group_or_size. If negative, search icons whose size is - group_or_size. See KIcon::Group and KIcon::StdSizes
canReturnNull  Can return a null string? If not, a path to the "unknown" icon will be returned.
Returns:
the path of an icon, can be null or the "unknown" icon when not found, depending on canReturnNull.

Definition at line 477 of file kiconloader.cpp.

References QString::at(), QString::isEmpty(), KIcon::isValid(), KIcon::path, and KGlobal::staticQString().

Referenced by loadIcon(), loadMovie(), and unknown().

QMovie KIconLoader::loadMovie const QString   name,
KIcon::Group    group,
int    size = 0
const
 

Loads an animated icon.

Parameters:
name  The name of the icon.
group  The icon group. See loadIcon().
size  Override the default size for group. See KIcon::StdSizes.
Returns:
A QMovie object. Can be null if not found.

Definition at line 846 of file kiconloader.cpp.

References QString::findRev(), KIcon::Group, iconPath(), QString::isEmpty(), QString::left(), and moviePath().

QString KIconLoader::moviePath const QString   name,
KIcon::Group    group,
int    size = 0
const
 

Returns the path to an animated icon.

Parameters:
name  The name of the icon.
group  The icon group. See loadIcon().
size  Override the default size for group. See KIcon::StdSizes.
Returns:
the full path to the movie, ready to be passed to QMovie's constructor. Empty string if not found.

Definition at line 858 of file kiconloader.cpp.

References KIcon::Group, KIcon::isValid(), KIcon::MatchBest, KIcon::MatchExact, and KIcon::path.

Referenced by loadMovie().

QStringList KIconLoader::loadAnimated const QString   name,
KIcon::Group    group,
int    size = 0
const
 

Loads an animated icon as a series of still frames.

If you want to load a .mng animation as QMovie instead, please use loadMovie() instead.

Parameters:
name  The name of the icon.
group  The icon group. See loadIcon().
size  Override the default size for group. See KIcon::StdSizes.
Returns:
A QStringList containing the absolute path of all the frames making up the animation.

Definition at line 910 of file kiconloader.cpp.

References QFile::decodeName(), QFile::encodeName(), KIcon::Group, QString::isEmpty(), KIcon::isValid(), QString::left(), QString::length(), KIcon::path, and QStringList::sort().

QStringList KIconLoader::queryIcons int    group_or_size,
KIcon::Context    context = KIcon::Any
const
 

Queries all available icons for a specific group, having a specific context.

Parameters:
group_or_size  If positive, search icons whose size is specified by the icon group group_or_size. If negative, search icons whose size is - group_or_size. See KIcon::Group and KIcon::StdSizes
context  The icon context.
Returns:
a list of all icons

Definition at line 1030 of file kiconloader.cpp.

References KIcon::Context, and QString::mid().

QStringList KIconLoader::queryIconsByContext int    group_or_size,
KIcon::Context    context = KIcon::Any
const
 

Queries all available icons for a specific context.

Parameters:
group_or_size  The icon preferred group or size. If available at this group or size, those icons will be returned, in other case, icons of undefined size will be returned. Positive numbers are groups, negative numbers are negated sizes. See KIcon::Group and KIcon::StdSizes
context  The icon context.
Returns:
A QStringList containing the icon names available for that context

Definition at line 990 of file kiconloader.cpp.

References KIcon::Context, and QString::mid().

QStringList KIconLoader::queryIconsByDir const QString   iconsDir const
 

Returns a list of all icons (*.png or *.xpm extension) in the given directory.

Parameters:
iconsDir  the directory to search in
Returns:
A QStringList containing the icon paths
Since:
3.1

Definition at line 979 of file kiconloader.cpp.

References QDir::entryList().

int KIconLoader::currentSize KIcon::Group    group const
 

Returns the current size of the group.

Parameters:
group  the group to check.
Returns:
the current size for an icon group.

Definition at line 967 of file kiconloader.cpp.

References KIcon::Group.

Referenced by IconSize().

KIconTheme * KIconLoader::theme   const
 

Returns a pointer to the current theme.

Can be used to query available and default sizes for groups.

Returns:
a pointer to the current theme. 0 if no theme set.

Definition at line 961 of file kiconloader.cpp.

Referenced by loadIcon().

KIconEffect * KIconLoader::iconEffect   const
 

Returns a pointer to the KIconEffect object used by the icon loader.

Returns:
the KIconEffect.

Definition at line 1068 of file kiconloader.cpp.

void KIconLoader::reconfigure const QString   _appname,
KStandardDirs   _dirs
 

Called by KInstance::newIconLoader to reconfigure the icon loader.

Parameters:
_appname  the new application name
_dirs  the new standard directories. If 0, the directories from KGlobal will be taken.

Definition at line 146 of file kiconloader.cpp.

Referenced by KInstance::newIconLoader().

QPixmap KIconLoader::unknown   [static]
 

Returns the unknown icon.

An icon that is used when no other icon can be found.

Returns:
the unknown pixmap

Definition at line 1276 of file kiconloader.cpp.

References QPixmapCache::find(), KGlobal::iconLoader(), iconPath(), QPixmapCache::insert(), QString::isEmpty(), QPixmap::load(), and QPixmap::resize().

bool KIconLoader::alphaBlending KIcon::Group    group const
 

Checks whether the user wants to blend the icons with the background using the alpha channel information for a given group.

Parameters:
group  the group to check
Returns:
true if alpha blending is desired
Deprecated:

Definition at line 1073 of file kiconloader.cpp.

References KIcon::Group.

void KIconLoader::addExtraDesktopThemes  
 

Adds all the default themes from other desktops at the end of the list of icon themes.

Since:
3.1

Definition at line 311 of file kiconloader.cpp.

References QDir::dirName(), KGlobal::dirs(), QFile::encodeName(), QDir::entryList(), KStandardDirs::exists(), QDir::exists(), and KStandardDirs::resourceDirs().

bool KIconLoader::extraDesktopThemesAdded   const
 

Returns if the default icon themes of other desktops have been added to the list of icon themes where icons are searched.

Since:
3.1

Definition at line 362 of file kiconloader.cpp.

void KIconLoader::enableDelayedIconSetLoading bool    enable
 

Enables on-demand icon loading for QIconSets using QIconFactory.

Icons loaded via loadIconSet() will be loaded as soon as they need to be displayed, not earlier.

Note that enabling or disabling this only affects loadIconSet() calls after this setting is changed.

The default is disabled, as the iconloader object must not be destroyed before all those iconsets are destroyed.

(Some broken applications use temporary KIconLoader objects). Every KInstance 's iconloader has this feature enabled.

Parameters:
enable  true to enable delayed icon loading, false to disable
See also:
isDelayedIconSetLoadingEnabled() , QIconFactory
Since:
3.1

Definition at line 249 of file kiconloader.cpp.

Referenced by KInstance::iconLoader().

bool KIconLoader::isDelayedIconSetLoadingEnabled   const
 

Checks whether delayed loading for QIconSet is enabled.

Returns:
whether icons for QIconSets will be loaded on demand.
See also:
enableDelayedIconSetLoading() , QIconFactory
Since:
3.1

Definition at line 254 of file kiconloader.cpp.


Friends And Related Function Documentation

QPixmap DesktopIcon const QString   name,
int    size = 0,
int    state = KIcon::DefaultState,
KInstance   instance = KGlobal::instance()
[related]
 

Load a desktop icon.

Definition at line 1181 of file kiconloader.cpp.

References KInstance::iconLoader(), KNotifyClient::instance(), and loadIcon().

QPixmap DesktopIcon const QString   name,
KInstance   instance
[related]
 

Load a desktop icon.

Definition at line 1188 of file kiconloader.cpp.

References KIcon::DefaultState, and KNotifyClient::instance().

QIconSet DesktopIconSet const QString   name,
int    size = 0,
KInstance   instance = KGlobal::instance()
[related]
 

Load a desktop icon, and apply the necessary effects to get an IconSet.

Definition at line 1193 of file kiconloader.cpp.

References KInstance::iconLoader(), KNotifyClient::instance(), and loadIconSet().

QPixmap BarIcon const QString   name,
int    size = 0,
int    state = KIcon::DefaultState,
KInstance   instance = KGlobal::instance()
[related]
 

Load a toolbar icon.

Definition at line 1199 of file kiconloader.cpp.

References KInstance::iconLoader(), KNotifyClient::instance(), and loadIcon().

QPixmap BarIcon const QString   name,
KInstance   instance
[related]
 

Load a toolbar icon.

Definition at line 1206 of file kiconloader.cpp.

References KIcon::DefaultState, and KNotifyClient::instance().

QIconSet BarIconSet const QString   name,
int    size = 0,
KInstance   instance = KGlobal::instance()
[related]
 

Load a toolbar icon, and apply the necessary effects to get an IconSet.

Definition at line 1211 of file kiconloader.cpp.

References KInstance::iconLoader(), KNotifyClient::instance(), and loadIconSet().

QPixmap SmallIcon const QString   name,
int    size = 0,
int    state = KIcon::DefaultState,
KInstance   instance = KGlobal::instance()
[related]
 

Load a small icon.

Definition at line 1217 of file kiconloader.cpp.

References KInstance::iconLoader(), KNotifyClient::instance(), and loadIcon().

QPixmap SmallIcon const QString   name,
KInstance   instance
[related]
 

Load a small icon.

Definition at line 1224 of file kiconloader.cpp.

References KIcon::DefaultState, and KNotifyClient::instance().

QIconSet SmallIconSet const QString   name,
int    size = 0,
KInstance   instance = KGlobal::instance()
[related]
 

Load a small icon, and apply the necessary effects to get an IconSet.

Definition at line 1229 of file kiconloader.cpp.

References KInstance::iconLoader(), KNotifyClient::instance(), and loadIconSet().

QPixmap MainBarIcon const QString   name,
int    size = 0,
int    state = KIcon::DefaultState,
KInstance   instance = KGlobal::instance()
[related]
 

Load a main toolbar icon.

Definition at line 1235 of file kiconloader.cpp.

References KInstance::iconLoader(), KNotifyClient::instance(), and loadIcon().

QPixmap MainBarIcon const QString   name,
KInstance   instance
[related]
 

Load a main toolbar icon.

Definition at line 1242 of file kiconloader.cpp.

References KIcon::DefaultState, and KNotifyClient::instance().

QIconSet MainBarIconSet const QString   name,
int    size = 0,
KInstance   instance = KGlobal::instance()
[related]
 

Load a main toolbar icon, and apply the effects to get an IconSet.

Definition at line 1247 of file kiconloader.cpp.

References KInstance::iconLoader(), KNotifyClient::instance(), and loadIconSet().

QPixmap UserIcon const QString   name,
int    state = KIcon::DefaultState,
KInstance   instance = KGlobal::instance()
[related]
 

Load a user icon.

Definition at line 1253 of file kiconloader.cpp.

References KInstance::iconLoader(), KNotifyClient::instance(), and loadIcon().

QPixmap UserIcon const QString   name,
KInstance   instance
[related]
 

Load a user icon.

Definition at line 1259 of file kiconloader.cpp.

References KIcon::DefaultState, and KNotifyClient::instance().

QIconSet UserIconSet const QString   name,
KInstance   instance = KGlobal::instance()
[related]
 

Load a user icon, and apply the effects to get an IconSet.

Definition at line 1264 of file kiconloader.cpp.

References KInstance::iconLoader(), KNotifyClient::instance(), and loadIconSet().

int IconSize KIcon::Group    group,
KInstance   instance = KGlobal::instance()
[related]
 

Returns the current icon size for a specific group.

Definition at line 1270 of file kiconloader.cpp.

References currentSize(), KIcon::Group, KInstance::iconLoader(), and KNotifyClient::instance().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdecore Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun May 16 22:01:28 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003