• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdecore
 

kdecore

Public Member Functions | Static Public Member Functions | Related Functions | List of all members
KIconLoader Class Reference

#include <kiconloader.h>

Public Member Functions

 KIconLoader (const TQString &appname=TQString::null, KStandardDirs *dirs=0)
 
 ~KIconLoader ()
 
void addAppDir (const TQString &appname)
 
TQPixmap loadIcon (const TQString &name, KIcon::Group group, int size=0, int state=KIcon::DefaultState, TQString *path_store=0L, bool canReturnNull=false) const
 
TQIconSet loadIconSet (const TQString &name, KIcon::Group group, int size, bool canReturnNull, bool immediateExistenceCheck)
 
TQIconSet loadIconSet (const TQString &name, KIcon::Group group, int size, bool canReturnNull)
 
TQIconSet loadIconSet (const TQString &name, KIcon::Group group, int size=0)
 
TQString iconPath (const TQString &name, int group_or_size, bool canReturnNull=false) const
 
TQMovie loadMovie (const TQString &name, KIcon::Group group, int size=0) const
 
TQString moviePath (const TQString &name, KIcon::Group group, int size=0) const
 
TQStringList loadAnimated (const TQString &name, KIcon::Group group, int size=0) const
 
TQStringList queryIcons (int group_or_size, KIcon::Context context=KIcon::Any) const
 
TQStringList queryIconsByContext (int group_or_size, KIcon::Context context=KIcon::Any) const
 
bool hasContext (KIcon::Context context) const
 
TQStringList queryIconsByDir (const TQString &iconsDir) const
 
int currentSize (KIcon::Group group) const
 
KIconTheme * theme () const
 
KIconEffect * iconEffect () const
 
void reconfigure (const TQString &_appname, KStandardDirs *_dirs)
 
bool alphaBlending (KIcon::Group group) const
 
void addExtraDesktopThemes ()
 
bool extraDesktopThemesAdded () const
 
void enableDelayedIconSetLoading (bool enable)
 
bool isDelayedIconSetLoadingEnabled () const
 

Static Public Member Functions

static TQPixmap unknown ()
 

Related Functions

(Note that these are not member functions.)

TQPixmap DesktopIcon (const TQString &name, int size=0, int state=KIcon::DefaultState, KInstance *instance=KGlobal::instance())
 
TQPixmap DesktopIcon (const TQString &name, KInstance *instance)
 
TQIconSet DesktopIconSet (const TQString &name, int size=0, KInstance *instance=KGlobal::instance())
 
TQPixmap BarIcon (const TQString &name, int size=0, int state=KIcon::DefaultState, KInstance *instance=KGlobal::instance())
 
TQPixmap BarIcon (const TQString &name, KInstance *instance)
 
TQIconSet BarIconSet (const TQString &name, int size=0, KInstance *instance=KGlobal::instance())
 
TQPixmap SmallIcon (const TQString &name, int size=0, int state=KIcon::DefaultState, KInstance *instance=KGlobal::instance())
 
TQPixmap SmallIcon (const TQString &name, KInstance *instance)
 
TQIconSet SmallIconSet (const TQString &name, int size=0, KInstance *instance=KGlobal::instance())
 
TQPixmap MainBarIcon (const TQString &name, int size=0, int state=KIcon::DefaultState, KInstance *instance=KGlobal::instance())
 
TQPixmap MainBarIcon (const TQString &name, KInstance *instance)
 
TQIconSet MainBarIconSet (const TQString &name, int size=0, KInstance *instance=KGlobal::instance())
 
TQPixmap UserIcon (const TQString &name, int state=KIcon::DefaultState, KInstance *instance=KGlobal::instance())
 
TQPixmap UserIcon (const TQString &name, KInstance *instance)
 
TQIconSet UserIconSet (const TQString &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.

  • KIcon::Desktop: Icons in the iconview of konqueror, kdesktop and similar apps.
  • KIcon::Toolbar: Icons in toolbars.
  • KIcon::MainToolbar: Icons in the main toolbars.
  • KIcon::Small: Various small (typical 16x16) places: titlebars, listviews and menu entries.
  • KIcon::Panel: Icons in kicker's panel

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 77 of file kiconloader.h.

Constructor & Destructor Documentation

KIconLoader::KIconLoader ( const TQString &  appname = TQString::null,
KStandardDirs *  dirs = 0 
)

Constructs an iconloader.

Parameters
appnameAdd 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.
dirsthe 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 130 of file kiconloader.cpp.

KIconLoader::~KIconLoader ( )

Cleanup.

Definition at line 263 of file kiconloader.cpp.

Member Function Documentation

void KIconLoader::addAppDir ( const TQString &  appname)

Adds appname to the list of application specific directories.

Parameters
appnameThe application name.

Definition at line 295 of file kiconloader.cpp.

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 347 of file kiconloader.cpp.

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
groupthe group to check
Returns
true if alpha blending is desired
Deprecated:

Definition at line 1126 of file kiconloader.cpp.

int KIconLoader::currentSize ( KIcon::Group  group) const

Returns the current size of the group.

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

Definition at line 1008 of file kiconloader.cpp.

void KIconLoader::enableDelayedIconSetLoading ( bool  enable)

Enables on-demand icon loading for QIconSets using TQIconFactory.

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
enabletrue to enable delayed icon loading, false to disable
See Also
isDelayedIconSetLoadingEnabled()
QIconFactory
Since
3.1

Definition at line 285 of file kiconloader.cpp.

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 398 of file kiconloader.cpp.

KIconEffect * KIconLoader::iconEffect ( ) const

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

Returns
the KIconEffect.

Definition at line 1121 of file kiconloader.cpp.

TQString KIconLoader::iconPath ( const TQString &  name,
int  group_or_size,
bool  canReturnNull = false 
) const

Returns the path of an icon.

Parameters
nameThe name of the icon, without extension. If an absolute path is supplied for this parameter, iconPath will return it directly.
group_or_sizeIf 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
canReturnNullCan 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 512 of file kiconloader.cpp.

bool KIconLoader::isDelayedIconSetLoadingEnabled ( ) const

Checks whether delayed loading for TQIconSet is enabled.

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

Definition at line 290 of file kiconloader.cpp.

TQStringList KIconLoader::loadAnimated ( const TQString &  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 TQMovie instead, please use loadMovie() instead.

Parameters
nameThe name of the icon.
groupThe icon group. See loadIcon().
sizeOverride the default size for group. See KIcon::StdSizes.
Returns
A TQStringList containing the absolute path of all the frames making up the animation.

Definition at line 951 of file kiconloader.cpp.

TQPixmap KIconLoader::loadIcon ( const TQString &  name,
KIcon::Group  group,
int  size = 0,
int  state = KIcon::DefaultState,
TQString *  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
nameThe name of the icon, without extension.
groupThe icon group. This will specify the size of and effects to be applied to the icon.
sizeIf nonzero, this overrides the size specified by group. See KIcon::StdSizes.
stateThe 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_storeIf not null, the path of the icon is stored here.
canReturnNullCan return a null pixmap? If false, the "unknown" pixmap is returned when no appropriate icon has been found.
Returns
the TQPixmap. Can be null when not found, depending on canReturnNull.

Definition at line 579 of file kiconloader.cpp.

TQIconSet KIconLoader::loadIconSet ( const TQString &  name,
KIcon::Group  group,
int  size,
bool  canReturnNull,
bool  immediateExistenceCheck 
)

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

Loading itself is done by calling loadIcon .

Parameters
nameThe name of the icon, without extension.
groupThe icon group. This will specify the size of and effects to be applied to the icon.
sizeIf nonzero, this overrides the size specified by group. See KIcon::StdSizes.
canReturnNullCan return a null iconset? If false, iconset containing the "unknown" pixmap is returned when no appropriate icon has been found.
immediateExistenceCheckIf true on-demand icon loading will be disabled for canReturnNull and a null iconset may be returned immediately
Returns
the icon set. Can be null when not found, depending on canReturnNull.
Since
3.5

Definition at line 1168 of file kiconloader.cpp.

TQIconSet KIconLoader::loadIconSet ( const TQString &  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
nameThe name of the icon, without extension.
groupThe icon group. This will specify the size of and effects to be applied to the icon.
sizeIf nonzero, this overrides the size specified by group. See KIcon::StdSizes.
canReturnNullCan 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 1138 of file kiconloader.cpp.

TQIconSet KIconLoader::loadIconSet ( const TQString &  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
nameThe name of the icon, without extension.
groupThe icon group. This will specify the size of and effects to be applied to the icon.
sizeIf nonzero, this overrides the size specified by group. See KIcon::StdSizes.
Returns
the icon set. Can be null when not found

Definition at line 1143 of file kiconloader.cpp.

TQMovie KIconLoader::loadMovie ( const TQString &  name,
KIcon::Group  group,
int  size = 0 
) const

Loads an animated icon.

Parameters
nameThe name of the icon.
groupThe icon group. See loadIcon().
sizeOverride the default size for group. See KIcon::StdSizes.
Returns
A TQMovie object. Can be null if not found.

Definition at line 895 of file kiconloader.cpp.

TQString KIconLoader::moviePath ( const TQString &  name,
KIcon::Group  group,
int  size = 0 
) const

Returns the path to an animated icon.

Parameters
nameThe name of the icon.
groupThe icon group. See loadIcon().
sizeOverride 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 907 of file kiconloader.cpp.

TQStringList 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_sizeIf 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
contextThe icon context.
Returns
a list of all icons

Definition at line 1072 of file kiconloader.cpp.

TQStringList KIconLoader::queryIconsByContext ( int  group_or_size,
KIcon::Context  context = KIcon::Any 
) const

Queries all available icons for a specific context.

Parameters
group_or_sizeThe 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
contextThe icon context.
Returns
A TQStringList containing the icon names available for that context

Definition at line 1031 of file kiconloader.cpp.

TQStringList KIconLoader::queryIconsByDir ( const TQString &  iconsDir) const

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

Parameters
iconsDirthe directory to search in
Returns
A TQStringList containing the icon paths
Since
3.1

Definition at line 1020 of file kiconloader.cpp.

void KIconLoader::reconfigure ( const TQString &  _appname,
KStandardDirs *  _dirs 
)

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

Parameters
_appnamethe new application name
_dirsthe new standard directories. If 0, the directories from KGlobal will be taken.

Definition at line 162 of file kiconloader.cpp.

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 1002 of file kiconloader.cpp.

TQPixmap 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 1388 of file kiconloader.cpp.

Friends And Related Function Documentation

TQPixmap BarIcon ( const TQString &  name,
int  size = 0,
int  state = KIcon::DefaultState,
KInstance *  instance = KGlobal::instance() 
)
related

Load a toolbar icon.

Definition at line 1311 of file kiconloader.cpp.

TQPixmap BarIcon ( const TQString &  name,
KInstance *  instance 
)
related

Load a toolbar icon.

Definition at line 1318 of file kiconloader.cpp.

TQIconSet BarIconSet ( const TQString &  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 1323 of file kiconloader.cpp.

TQPixmap DesktopIcon ( const TQString &  name,
int  size = 0,
int  state = KIcon::DefaultState,
KInstance *  instance = KGlobal::instance() 
)
related

Load a desktop icon.

Definition at line 1293 of file kiconloader.cpp.

TQPixmap DesktopIcon ( const TQString &  name,
KInstance *  instance 
)
related

Load a desktop icon.

Definition at line 1300 of file kiconloader.cpp.

TQIconSet DesktopIconSet ( const TQString &  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 1305 of file kiconloader.cpp.

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

Returns the current icon size for a specific group.

Definition at line 1382 of file kiconloader.cpp.

TQPixmap MainBarIcon ( const TQString &  name,
int  size = 0,
int  state = KIcon::DefaultState,
KInstance *  instance = KGlobal::instance() 
)
related

Load a main toolbar icon.

Definition at line 1347 of file kiconloader.cpp.

TQPixmap MainBarIcon ( const TQString &  name,
KInstance *  instance 
)
related

Load a main toolbar icon.

Definition at line 1354 of file kiconloader.cpp.

TQIconSet MainBarIconSet ( const TQString &  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 1359 of file kiconloader.cpp.

TQPixmap SmallIcon ( const TQString &  name,
int  size = 0,
int  state = KIcon::DefaultState,
KInstance *  instance = KGlobal::instance() 
)
related

Load a small icon.

Definition at line 1329 of file kiconloader.cpp.

TQPixmap SmallIcon ( const TQString &  name,
KInstance *  instance 
)
related

Load a small icon.

Definition at line 1336 of file kiconloader.cpp.

TQIconSet SmallIconSet ( const TQString &  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 1341 of file kiconloader.cpp.

TQPixmap UserIcon ( const TQString &  name,
int  state = KIcon::DefaultState,
KInstance *  instance = KGlobal::instance() 
)
related

Load a user icon. User icons are searched in $appdir/pics.

Definition at line 1365 of file kiconloader.cpp.

TQPixmap UserIcon ( const TQString &  name,
KInstance *  instance 
)
related

Load a user icon. User icons are searched in $appdir/pics.

Definition at line 1371 of file kiconloader.cpp.

TQIconSet UserIconSet ( const TQString &  name,
KInstance *  instance = KGlobal::instance() 
)
related

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

Definition at line 1376 of file kiconloader.cpp.


The documentation for this class was generated from the following files:
  • kiconloader.h
  • kiconloader.cpp

kdecore

Skip menu "kdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |