# class KIconLoader

###

Module | kdeui
Namespace |
Class | KIconLoader
Inherits | QObject

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.

- KIconLoader.Desktop: Icons in the iconview of konqueror, kdesktop and similar apps.
- KIconLoader.Toolbar: Icons in toolbars.
- KIconLoader.MainToolbar: Icons in the main toolbars.
- KIconLoader.Small: Various small (typical 16x16) places: titlebars, listviews
and menu entries.
- KIconLoader.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".

### enums

- Context { Any, Action, Application, Device, FileSystem, MimeType, Animation, Category, Emblem, Emote, International, Place, StatusIcon }
- Group { NoGroup, Desktop, FirstGroup, Toolbar, MainToolbar, Small, Panel, Dialog, LastGroup, User }
- MatchType { MatchExact, MatchBest }
- States { DefaultState, ActiveState, DisabledState, LastState }
- StdSizes { SizeSmall, SizeSmallMedium, SizeMedium, SizeLarge, SizeHuge, SizeEnormous }
- Type { Fixed, Scalable, Threshold }

enum details

### methods

- KIconLoader (appname, dirs, parent)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  appname | QString | QString()
  dirs | KStandardDirs | 0
  parent | QObject | 0

  Constructs an iconloader.

  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 KIconLoader.global(), so you hardly ever have to create an iconloader object yourself. That one is the current KComponentData's (typically KApplication's) iconloader.

- KIconLoader (componentData, parent)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  componentData | KComponentData |
  parent | QObject | 0

  Constructs an iconloader.

  componentData - the KComponentData to use to create this icon loader.

  Usually, you use the default iconloader, which can be accessed via KIconLoader.global(), so you hardly ever have to create an iconloader object yourself. That one is the current KComponentData's (typically KApplication's) iconloader.

- KIconLoader (a0, a1, a2)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QString | QString()
  a1 | KStandardDirs | 0
  a2 | QObject | 0

- KIconLoader (a0, a1)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | KComponentData |
  a1 | QObject | 0

- addAppDir (appname)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  appname | QString |

  Adds appname to the list of application specific directories.

  appname - The application name.

- addExtraDesktopThemes ( )

  returns Nothing

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

- alphaBlending (group)

  returns bool
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  group | KIconLoader.Group |

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

  group - the group to check Returns true if alpha blending is desired Obsolete

- currentSize (group)

  returns int
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  group | KIconLoader.Group |

  Returns the current size of the group.

  group - the group to check. Returns the current size for an icon group.

- extraDesktopThemesAdded ( )

  returns bool

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

- global ( )

  returns KIconLoader
  static

  Returns the global icon loader initialized with the global KComponentData. Therefore you must have a KComponentData instantiated before calling this. Returns global icon loader

- hasContext (context)

  returns bool
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  context | KIconLoader.Context |

  Internal

- iconEffect ( )

  returns KIconEffect

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

- iconPath (name, group_or_size, canReturnNull)

  returns QString

  Argument | Type | Default
  --- | --- | ---
  name | QString |
  group_or_size | int |
  canReturnNull | bool | 0

  Returns the path of an icon.

  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 KIconLoader.Group and KIconLoader.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.

- loadAnimated (name, group, size)

  returns QStringList
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  name | QString |
  group | KIconLoader.Group |
  size | int | 0

  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.

  name - The name of the icon.

  group - The icon group. See loadIcon().

  size - Override the default size for group. See KIconLoader.StdSizes. Returns A QStringList containing the absolute path of all the frames making up the animation.

- loadIcon (name, group, size, state, overlays, path_store, canReturnNull)

  returns QPixmap

  Argument | Type | Default
  --- | --- | ---
  name | QString |
  group | KIconLoader.Group |
  size | int | 0
  state | int | KIconLoader.DefaultState
  overlays | QStringList | QStringList()
  path_store | QString | 0
  canReturnNull | bool | 0

  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.

  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 KIconLoader.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.

  overlays - a list of emblem icons to overlay, by name. the emblem prefix is applied automatically to each name, e.g. "zip" becomes "emblem-zip"

  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.

- loadIconSet (name, group, size, canReturnNull)

  returns QIcon
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  name | QString |
  group | KIconLoader.Group |
  size | int | 0
  canReturnNull | bool | 0

  Creates an icon set, that will do on-demand loading of the icon. Loading itself is done by calling loadIcon .

  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 KIconLoader.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.

  Deprecated use KIcon instead, which uses the iconloader internally

- loadMimeTypeIcon (iconName, group, size, state, overlays, path_store)

  returns QPixmap

  Argument | Type | Default
  --- | --- | ---
  iconName | QString |
  group | KIconLoader.Group |
  size | int | 0
  state | int | KIconLoader.DefaultState
  overlays | QStringList | QStringList()
  path_store | QString | 0

  Loads an icon for a mimetype. This is basically like loadIcon except that extra desktop themes are loaded if necessary.

  iconName - The name of the icon, without extension, usually from KMimeType.

  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 KIconLoader.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.

  overlays - a list of emblem icons to overlay, by name. the emblem prefix is applied automatically to each name, e.g. "zip" becomes "emblem-zip" Returns the QPixmap. Can not be null, the "unknown" pixmap is returned when no appropriate icon has been found.

- loadMovie (name, group, size, parent)

  returns QMovie
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  name | QString |
  group | KIconLoader.Group |
  size | int | 0
  parent | QObject | 0

  Loads an animated icon.

  name - The name of the icon.

  group - The icon group. See loadIcon().

  size - Override the default size for group. See KIconLoader.StdSizes.

  parent - The parent object of the returned QMovie. Returns A QMovie object. Can be null if not found or not valid. Ownership is passed to the caller.

- moviePath (name, group, size)

  returns QString
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  name | QString |
  group | KIconLoader.Group |
  size | int | 0

  Returns the path to an animated icon.

  name - The name of the icon.

  group - The icon group. See loadIcon().

  size - Override the default size for group. See KIconLoader.StdSizes. Returns the full path to the movie, ready to be passed to QMovie's constructor. Empty string if not found.

- newIconLoader ( )

  returns Nothing

  Re-initialize the global icon loader

- queryIcons (group_or_size, context)

  returns QStringList
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  group_or_size | int |
  context | KIconLoader.Context | KIconLoader.Any

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

  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 KIconLoader.Group and KIconLoader.StdSizes

  context - The icon context. Returns a list of all icons

- queryIconsByContext (group_or_size, context)

  returns QStringList
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  group_or_size | int |
  context | KIconLoader.Context | KIconLoader.Any

  Queries all available icons for a specific context.

  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 KIconLoader.Group and KIconLoader.StdSizes

  context - The icon context. Returns A QStringList containing the icon names available for that context

- queryIconsByDir (iconsDir)

  returns QStringList

  Argument | Type | Default
  --- | --- | ---
  iconsDir | QString |

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

  iconsDir - the directory to search in Returns A QStringList containing the icon paths

- reconfigure (_appname, _dirs)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  _appname | QString |
  _dirs | KStandardDirs |

  Called by KComponentData.newIconLoader to reconfigure the icon loader.

  _appname - the new application name

  _dirs - the new standard directories. If 0, the directories from KGlobal will be taken.

- theme ( )

  returns KIconTheme

  Returns a pointer to the current theme. Can be used to query available and default sizes for groups. The KIconTheme will change if reconfigure() is called and therefore it's not recommed to store the pointer somewhere. Returns a pointer to the current theme. 0 if no theme set.

- unknown ( )

  returns QPixmap
  static

  Returns the unknown icon. An icon that is used when no other icon can be found. Returns the unknown pixmap

### enums - detail

- Context { Any, Action, Application, Device, FileSystem, MimeType, Animation, Category, Emblem, Emote, International, Place, StatusIcon }

  Defines the context of the icon.

  | Any | - | - |
  | Action | - | - |
  | Application | - | - |
  | Device | - | - |
  | FileSystem | - | - |
  | MimeType | - | - |
  | Animation | - | - |
  | Category | - | - |
  | Emblem | - | - |
  | Emote | - | - |
  | International | - | - |
  | Place | - | - |
  | StatusIcon | - | - |

- Group { NoGroup, Desktop, FirstGroup, Toolbar, MainToolbar, Small, Panel, Dialog, LastGroup, User }

  No group

  | NoGroup | - -1 | - |
  | Desktop | - 0 | - |
  | FirstGroup | - 0 | - |
  | Toolbar | - | - |
  | MainToolbar | - | - |
  | Small | - | - |
  | Panel | - | - |
  | Dialog | - | - |
  | LastGroup | - | - |
  | User | - | - |

- MatchType { MatchExact, MatchBest }

  The type of a match.

  | MatchExact | - | - |
  | MatchBest | - | - |

- States { DefaultState, ActiveState, DisabledState, LastState }

  Defines the possible states of an icon.

  | DefaultState | - | - |
  | ActiveState | - | - |
  | DisabledState | - | - |
  | LastState | - | - |

- StdSizes { SizeSmall, SizeSmallMedium, SizeMedium, SizeLarge, SizeHuge, SizeEnormous }

  small icons for menu entries

  | SizeSmall | - 16 | - |
  | SizeSmallMedium | - 22 | - |
  | SizeMedium | - 32 | - |
  | SizeLarge | - 48 | - |
  | SizeHuge | - 64 | - |
  | SizeEnormous | - 128 | - |

- Type { Fixed, Scalable, Threshold }

  The type of the icon.

  | Fixed | - | - |
  | Scalable | - | - |
  | Threshold | - | - |