27 #include <sys/types.h>
33 #include <QtCore/QCache>
34 #include <QtCore/QFileInfo>
35 #include <QtCore/QDir>
36 #include <QtCore/QBuffer>
37 #include <QtCore/QDataStream>
38 #include <QtCore/QByteArray>
39 #include <QtCore/QStringBuilder>
40 #include <QtGui/QIcon>
41 #include <QtGui/QImage>
42 #include <QtGui/QMovie>
43 #include <QtGui/QPainter>
44 #include <QtGui/QPixmap>
45 #include <QtGui/QPixmapCache>
47 #include <QtSvg/QSvgRenderer>
72 static
bool pathIsRelative(const
QString &path)
75 return (!path.isEmpty() && path[0] != QChar(
'/'));
77 return QDir::isRelativePath(path);
102 void printTree(
QString& dbgString)
const;
107 KIconThemeNode::KIconThemeNode(
KIconTheme *_theme)
112 KIconThemeNode::~KIconThemeNode()
117 void KIconThemeNode::printTree(
QString& dbgString)
const
122 dbgString += theme->name();
126 void KIconThemeNode::queryIcons(
QStringList *result,
130 *result += theme->queryIcons(size, context);
133 void KIconThemeNode::queryIconsByContext(
QStringList *result,
137 *result += theme->queryIconsByContext(size, context);
140 K3Icon KIconThemeNode::findIcon(
const QString&
name,
int size,
143 return theme->iconPath(name, size, match);
157 class KIconLoaderPrivate
167 ~KIconLoaderPrivate()
184 bool initIconThemes();
191 K3Icon findMatchingIcon(
const QString& name,
int size)
const;
199 K3Icon findMatchingIconWithGenericFallbacks(
const QString& name,
int size)
const;
205 void addAppThemes(
const QString& appname);
212 void addBaseThemes(KIconThemeNode *node,
const QString &appname);
219 void addInheritedThemes(KIconThemeNode *node,
const QString &appname);
227 void addThemeByName(
const QString &themename,
const QString &appname);
233 QString unknownIconPath(
int size )
const;
255 int size,
int state)
const;
263 QImage createIconImage(
const QString &path,
int size = 0);
269 void insertCachedPixmapWithPath(
const QString &key,
const QPixmap &data,
const QString &path);
276 bool findCachedPixmapWithPath(
const QString &key, QPixmap &data,
QString &path);
281 KIconGroup *mpGroups;
282 KIconThemeNode *mpThemeRoot;
291 QCache<QString, PixmapWithPath> mPixmapCache;
293 bool extraDesktopIconsLoaded :1;
296 bool mIconThemeInited :1;
302 class KIconLoaderGlobalData
305 KIconLoaderGlobalData() {
308 Q_FOREACH(
const QString& file, genericIconsFiles) {
309 parseGenericIconsFiles(file);
314 return m_genericIcons.value(icon);
318 void parseGenericIconsFiles(
const QString& fileName);
322 void KIconLoaderGlobalData::parseGenericIconsFiles(
const QString& fileName)
324 QFile file(fileName);
325 if (file.open(QIODevice::ReadOnly)) {
326 QTextStream stream(&file);
327 stream.setCodec(
"ISO 8859-1");
328 while (!stream.atEnd()) {
329 const QString line = stream.readLine();
330 if (line.isEmpty() || line[0] ==
'#')
332 const int pos = line.indexOf(
':');
335 QString mimeIcon = line.left(pos);
336 const int slashindex = mimeIcon.indexOf(QLatin1Char(
'/'));
337 if (slashindex != -1) {
338 mimeIcon[slashindex] = QLatin1Char(
'-');
341 const QString genericIcon = line.mid(pos+1);
342 m_genericIcons.insert(mimeIcon, genericIcon);
352 if (overlays.isEmpty()) {
356 const int width = pix.size().width();
357 const int height = pix.size().height();
358 const int iconSize = qMin(width, height);
363 }
else if (iconSize <= 48) {
365 }
else if (iconSize <= 96) {
367 }
else if (iconSize < 256) {
373 QPainter painter(&pix);
376 foreach (
const QString& overlay, overlays) {
380 if (overlay.isEmpty()) {
388 const QPixmap pixmap = iconLoader->loadIcon(overlay, group, overlaySize, state,
QStringList(), 0,
true);
390 if (pixmap.isNull()) {
398 startPoint =
QPoint(2, height - overlaySize - 2);
402 startPoint =
QPoint(width - overlaySize - 2,
403 height - overlaySize - 2);
407 startPoint =
QPoint(width - overlaySize - 2, 2);
411 startPoint =
QPoint(2, 2);
415 painter.drawPixmap(startPoint, pixmap);
427 setObjectName(_appname);
428 d =
new KIconLoaderPrivate(
this);
432 d->init( _appname, _dirs );
439 d =
new KIconLoaderPrivate(
this);
448 d->mIconCache->clear();
450 d =
new KIconLoaderPrivate(
this);
451 d->init( _appname, _dirs );
456 extraDesktopIconsLoaded=
false;
457 mIconThemeInited =
false;
466 if (appname.isEmpty())
473 mPixmapCache.setMaxCost(10 * 1024 * 1024);
476 static const char *
const groups[] = {
"Desktop",
"Toolbar",
"MainToolbar",
"Small",
"Panel",
"Dialog", 0L };
481 KIconTheme *defaultSizesTheme = links.empty() ? 0 : links.first()->theme;
484 if (groups[i] == 0L) {
488 KConfigGroup cg(config, QLatin1String(groups[i]) +
"Icons");
489 mpGroups[i].size = cg.readEntry(
"Size", 0);
490 if (QPixmap::defaultDepth() > 8) {
491 mpGroups[i].alphaBlending = cg.readEntry(
"AlphaBlending",
true);
493 mpGroups[i].alphaBlending =
false;
496 if (!mpGroups[i].size && defaultSizesTheme) {
497 mpGroups[i].size = defaultSizesTheme->
defaultSize(i);
502 bool KIconLoaderPrivate::initIconThemes()
504 if (mIconThemeInited) {
506 return (mpThemeRoot != 0);
509 mIconThemeInited =
true;
517 kDebug(264) <<
"Couldn't find current icon theme, falling back to default.";
526 mpThemeRoot =
new KIconThemeNode(def);
528 links.append(mpThemeRoot);
529 addBaseThemes(mpThemeRoot, appname);
532 mpDirs->addResourceType(
"appicon",
"data", appname +
"/pics/");
534 mpDirs->addResourceType(
"appicon",
"data", appname +
"/toolbar/");
538 dirs += mpDirs->resourceDirs(
"icon");
539 dirs += mpDirs->resourceDirs(
"pixmap");
540 dirs += mpDirs->resourceDirs(
"xdgdata-icon");
541 dirs +=
"/usr/share/pixmaps";
543 dirs += mpDirs->resourceDirs(
"xdgdata-pixmap");
544 for (QStringList::ConstIterator it = dirs.constBegin(); it != dirs.constEnd(); ++it)
545 mpDirs->addResourceDir(
"appicon", *it);
548 QString dbgString =
"Theme tree: ";
549 mpThemeRoot->printTree(dbgString);
565 d->mpDirs->addResourceType(
"appicon",
"data", appname +
"/pics/");
567 d->mpDirs->addResourceType(
"appicon",
"data", appname +
"/toolbar/");
568 d->addAppThemes(appname);
571 void KIconLoaderPrivate::addAppThemes(
const QString& appname)
580 KIconThemeNode* node =
new KIconThemeNode(def);
581 bool addedToLinks =
false;
583 if (!mThemesInTree.contains(node->theme->internalName())) {
584 mThemesInTree.append(node->theme->internalName());
588 addBaseThemes(node, appname);
596 void KIconLoaderPrivate::addBaseThemes(KIconThemeNode *node,
const QString &appname)
608 addInheritedThemes(node, appname);
610 addThemeByName(
"hicolor", appname);
613 void KIconLoaderPrivate::addInheritedThemes(KIconThemeNode *node,
const QString &appname)
617 for (QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it) {
618 if ((*it) ==
"hicolor") {
624 addThemeByName(*it, appname);
628 void KIconLoaderPrivate::addThemeByName(
const QString &themename,
const QString &appname)
630 if (mThemesInTree.contains(themename + appname)) {
638 KIconThemeNode *n =
new KIconThemeNode(theme);
639 mThemesInTree.append(themename + appname);
641 addInheritedThemes(n, appname);
646 if ( d->extraDesktopIconsLoaded )
return;
652 QStringList::ConstIterator it;
655 for (it=icnlibs.begin(); it!=icnlibs.end(); ++it)
661 QStringList::ConstIterator it2;
662 for (it2=lst.begin(); it2!=lst.end(); ++it2)
667 r=readlink( QFile::encodeName(*it + *it2) , buf,
sizeof(buf)-1);
671 const QDir dir2( buf );
672 QString themeName=dir2.dirName();
674 if (!list.contains(themeName))
675 list.append(themeName);
680 for (it = list.constBegin(); it != list.constEnd(); ++it)
683 if (*it == QLatin1String(
"default.kde")
684 || *it == QLatin1String(
"default.kde4")) {
687 d->addThemeByName(*it,
"");
690 d->extraDesktopIconsLoaded=
true;
696 return d->extraDesktopIconsLoaded;
701 d->drawOverlays(
this, group, state, pixmap, overlays);
704 QString KIconLoaderPrivate::removeIconExtension(
const QString &name)
const
706 if (name.endsWith(QLatin1String(
".png"))
707 || name.endsWith(QLatin1String(
".xpm"))
708 || name.endsWith(QLatin1String(
".svg"))) {
709 return name.left(name.length() - 4);
710 }
else if (name.endsWith(QLatin1String(
".svgz"))) {
711 return name.left(name.length() - 5);
717 void KIconLoaderPrivate::normalizeIconMetadata(
KIconLoader::Group &group,
int &size,
int &state)
const
721 kWarning(264) <<
"Illegal icon state: " << state;
735 if ((group < -1) || (group >= KIconLoader::LastGroup))
737 kWarning(264) <<
"Illegal icon group: " << group;
746 kWarning(264) <<
"Neither size nor group specified!";
749 size = mpGroups[group].size;
754 const QStringList &overlays,
int size,
int state)
const
760 ? QLatin1Literal(
"$kicou_")
761 : QLatin1Literal(
"$kico_"))
764 % QString::number(size)
767 % ( group >= 0 ? mpEffect.fingerprint(group, state)
768 : *NULL_EFFECT_FINGERPRINT);
771 QImage KIconLoaderPrivate::createIconImage(
const QString &path,
int size)
775 QString ext = path.right(3).toUpper();
778 if (ext !=
"SVG" && ext !=
"VGZ")
781 img = QImage(path, ext.toLatin1());
783 if (size != 0 && !img.isNull()) {
784 img = img.scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
792 if (renderer.isValid()) {
793 img = QImage(size, size, QImage::Format_ARGB32_Premultiplied);
804 void KIconLoaderPrivate::insertCachedPixmapWithPath(
814 output.open(QIODevice::WriteOnly);
816 QDataStream outputStream(&output);
817 outputStream.setVersion(QDataStream::Qt_4_6);
819 outputStream << path;
822 outputStream << data;
827 mIconCache->insert(key, output.buffer());
831 PixmapWithPath *pixmapPath =
new PixmapWithPath;
832 pixmapPath->pixmap = data;
833 pixmapPath->path = path;
835 mPixmapCache.insert(key, pixmapPath, data.width() * data.height() + 1);
838 bool KIconLoaderPrivate::findCachedPixmapWithPath(
const QString &key, QPixmap &data,
QString &path)
842 const PixmapWithPath *pixmapPath = mPixmapCache.object(key);
844 path = pixmapPath->path;
845 data = pixmapPath->pixmap;
854 if (!mIconCache->find(key, &result) || result.isEmpty()) {
859 buffer.setBuffer(&result);
860 buffer.open(QIODevice::ReadOnly);
862 QDataStream inputStream(&buffer);
863 inputStream.setVersion(QDataStream::Qt_4_6);
866 inputStream >> tempPath;
870 inputStream >> tempPixmap;
877 PixmapWithPath *newPixmapWithPath =
new PixmapWithPath;
878 newPixmapWithPath->pixmap = data;
879 newPixmapWithPath->path = path;
881 mPixmapCache.insert(key, newPixmapWithPath, data.width() * data.height() + 1);
890 K3Icon KIconLoaderPrivate::findMatchingIconWithGenericFallbacks(
const QString& name,
int size)
const
892 K3Icon icon = findMatchingIcon(name, size);
896 const QString genericIcon = s_globalData->genericIconFor(name);
897 if (!genericIcon.isEmpty()) {
898 icon = findMatchingIcon(genericIcon, size);
903 K3Icon KIconLoaderPrivate::findMatchingIcon(
const QString& name,
int size)
const
905 const_cast<KIconLoaderPrivate*
>(
this)->initIconThemes();
909 const char *
const ext[4] = {
".png",
".svgz",
".svg",
".xpm" };
910 bool genericFallback = name.endsWith(QLatin1String(
"-x-generic"));
912 foreach(KIconThemeNode *themeNode, links)
916 while (!currentName.isEmpty())
924 for (
int i = 0 ; i < 4 ; i++)
939 int rindex = currentName.lastIndexOf(
'-');
941 currentName.truncate(rindex);
943 if (currentName.endsWith(QLatin1String(
"-x")))
948 <<
"text" <<
"application" <<
"image" <<
"audio"
949 <<
"inode" <<
"video" <<
"message" <<
"model" <<
"multipart"
950 <<
"x-content" <<
"x-epoc";
955 if (mediaTypes.contains(currentName)) {
956 currentName += QLatin1String(
"-x-generic");
957 genericFallback =
true;
967 inline QString KIconLoaderPrivate::unknownIconPath(
int size )
const
971 K3Icon icon = findMatchingIcon(str_unknown, size);
974 kDebug(264) <<
"Warning: could not find \"Unknown\" icon for size = "
984 bool canReturnNull)
const
986 if (!d->initIconThemes()) {
990 if (_name.isEmpty() || !pathIsRelative(_name))
996 QString name = d->removeIconExtension( _name );
1003 path = d->mpDirs->findResource(
"appicon", name + png_ext);
1008 path = d->mpDirs->findResource(
"appicon", name + svgz_ext);
1010 path = d->mpDirs->findResource(
"appicon", name + svg_ext);
1012 path = d->mpDirs->findResource(
"appicon", name + xpm_ext);
1016 if (group_or_size >= KIconLoader::LastGroup)
1018 kDebug(264) <<
"Illegal icon group: " << group_or_size;
1023 if (group_or_size >= 0)
1024 size = d->mpGroups[group_or_size].size;
1026 size = -group_or_size;
1028 if (_name.isEmpty()) {
1032 return d->unknownIconPath(size);
1035 K3Icon icon = d->findMatchingIconWithGenericFallbacks(name, size);
1037 if (!icon.isValid())
1041 if (!path.isEmpty() || canReturnNull)
1044 return d->unknownIconPath(size);
1053 const int slashindex = iconName.indexOf(QLatin1Char(
'/'));
1054 if (slashindex != -1) {
1055 iconName[slashindex] = QLatin1Char(
'-');
1058 if ( !d->extraDesktopIconsLoaded )
1060 const QPixmap pixmap =
loadIcon( iconName, group, size, state, overlays, path_store,
true );
1061 if (!pixmap.isNull() ) {
1066 const QPixmap pixmap =
loadIcon(iconName, group, size, state, overlays, path_store,
true);
1067 if (pixmap.isNull()) {
1069 return loadIcon(
"application-octet-stream", group, size, state, overlays, path_store,
false);
1076 QString *path_store,
bool canReturnNull)
const
1079 bool favIconOverlay =
false;
1081 if (size < 0 || _name.isEmpty())
1095 if (name.startsWith(QLatin1String(
"favicons/")))
1097 favIconOverlay =
true;
1101 bool absolutePath = !pathIsRelative(name);
1102 if (!absolutePath) {
1103 name = d->removeIconExtension(name);
1107 if (name.isEmpty()) {
1113 d->normalizeIconMetadata(group, size, state);
1116 QString key = d->makeCacheKey(name, group, overlays, size, state);
1118 bool iconWasUnknown =
false;
1123 if (d->findCachedPixmapWithPath(key, pix, icon.path) && !icon.path.isEmpty()) {
1125 *path_store = icon.path;
1132 if (!d->initIconThemes()) {
1136 favIconOverlay = favIconOverlay && size > 22;
1143 if (absolutePath && !favIconOverlay)
1151 icon = d->findMatchingIconWithGenericFallbacks(favIconOverlay ?
QString(
"text-html") : name, size);
1155 if (icon.path.isEmpty()) {
1157 icon.path = (absolutePath) ? name :
1163 if (icon.path.isEmpty() && !canReturnNull) {
1164 icon.path = d->unknownIconPath(size);
1165 iconWasUnknown =
true;
1168 QImage img = d->createIconImage(icon.path, size);
1172 img = d->mpEffect.apply(img, group, state);
1177 QImage favIcon(name,
"PNG");
1178 if (!favIcon.isNull())
1183 QRect r(favIcon.rect());
1184 r.moveBottomRight(img.rect().bottomRight());
1185 r.adjust(-1, -1, -1, -1);
1188 p.drawImage(r, favIcon);
1192 pix = QPixmap::fromImage(img);
1197 d->drawOverlays(
this, group, state, pix, overlays);
1201 if (iconWasUnknown) {
1205 d->insertCachedPixmapWithPath(key, pix, icon.path);
1208 *path_store = icon.path;
1219 int dirLen = file.lastIndexOf(
'/');
1221 if (!icon.isEmpty() && file.left(dirLen) != icon.left(dirLen))
1223 QMovie *movie =
new QMovie(file, QByteArray(), parent);
1224 if (!movie->isValid())
1234 if (!d->mpGroups)
return QString();
1236 d->initIconThemes();
1238 if ( (group < -1 || group >= KIconLoader::LastGroup) && group !=
KIconLoader::User )
1240 kDebug(264) <<
"Illegal icon group: " << group;
1243 if (size == 0 && group < 0)
1245 kDebug(264) <<
"Neither size nor group specified!";
1252 file = d->mpDirs->findResource(
"appicon", file);
1257 size = d->mpGroups[group].size;
1261 foreach(KIconThemeNode *themeNode, d->links)
1268 if ( !icon.isValid() )
1270 foreach(KIconThemeNode *themeNode, d->links)
1278 file = icon.isValid() ? icon.path :
QString();
1288 if (!d->mpGroups)
return lst;
1290 d->initIconThemes();
1292 if ((group < -1) || (group >= KIconLoader::LastGroup))
1294 kDebug(264) <<
"Illegal icon group: " << group;
1297 if ((size == 0) && (group < 0))
1299 kDebug(264) <<
"Neither size nor group specified!";
1303 QString file = name +
"/0001";
1306 file = d->mpDirs->findResource(
"appicon", file +
".png");
1310 size = d->mpGroups[group].size;
1311 K3Icon icon = d->findMatchingIcon(file, size);
1312 file = icon.isValid() ? icon.path :
QString();
1318 QString path = file.left(file.length()-8);
1319 DIR* dp = opendir( QFile::encodeName(path) );
1323 KDE_struct_dirent* ep;
1324 while( ( ep = KDE_readdir( dp ) ) != 0L )
1326 QString fn(QFile::decodeName(ep->d_name));
1327 if(!(fn.left(4)).toUInt())
1339 d->initIconThemes();
1340 if (d->mpThemeRoot)
return d->mpThemeRoot->theme;
1346 if (!d->mpGroups)
return -1;
1348 if (group < 0 || group >= KIconLoader::LastGroup)
1350 kDebug(264) <<
"Illegal icon group: " << group;
1353 return d->mpGroups[group].size;
1358 const QDir dir(iconsDir);
1360 const QStringList lst = dir.entryList(formats, QDir::Files);
1362 QStringList::ConstIterator it;
1363 for (it=lst.begin(); it!=lst.end(); ++it)
1364 result += iconsDir +
'/' + *it;
1371 d->initIconThemes();
1374 if (group_or_size >= KIconLoader::LastGroup)
1376 kDebug(264) <<
"Illegal icon group: " << group_or_size;
1380 if (group_or_size >= 0)
1381 size = d->mpGroups[group_or_size].size;
1383 size = -group_or_size;
1385 foreach(KIconThemeNode *themeNode, d->links)
1386 themeNode->queryIconsByContext(&result, size, context);
1391 QStringList::ConstIterator it;
1392 for (it=result.constBegin(); it!=result.constEnd(); ++it)
1394 int n = (*it).lastIndexOf(
'/');
1398 name = (*it).mid(n+1);
1399 name = d->removeIconExtension(name);
1400 if (!entries.contains(name))
1412 d->initIconThemes();
1415 if (group_or_size >= KIconLoader::LastGroup)
1417 kDebug(264) <<
"Illegal icon group: " << group_or_size;
1421 if (group_or_size >= 0)
1422 size = d->mpGroups[group_or_size].size;
1424 size = -group_or_size;
1426 foreach(KIconThemeNode *themeNode, d->links)
1427 themeNode->queryIcons(&result, size, context);
1432 QStringList::ConstIterator it;
1433 for (it=result.constBegin(); it!=result.constEnd(); ++it)
1435 int n = (*it).lastIndexOf(
'/');
1439 name = (*it).mid(n+1);
1440 name = d->removeIconExtension(name);
1441 if (!entries.contains(name))
1453 d->initIconThemes();
1455 foreach(KIconThemeNode *themeNode, d->links)
1456 if( themeNode->theme->hasContext( context ))
1463 return &d->mpEffect;
1468 if (!d->mpGroups)
return false;
1470 if (group < 0 || group >= KIconLoader::LastGroup)
1472 kDebug(264) <<
"Illegal icon group: " << group;
1475 return d->mpGroups[group].alphaBlending;
1479 #ifndef KDE_NO_DEPRECATED
1481 bool canReturnNull )
1485 iconset.addPixmap( tmp, QIcon::Active, QIcon::On );
1488 iconset.addPixmap( tmp, QIcon::Disabled, QIcon::On );
1490 iconset.addPixmap( tmp, QIcon::Normal, QIcon::On );
1504 #ifndef KDE_NO_DEPRECATED
1519 #ifndef KDE_NO_DEPRECATED
1534 #ifndef KDE_NO_DEPRECATED
1549 #ifndef KDE_NO_DEPRECATED
1564 #ifndef KDE_NO_DEPRECATED
1587 kDebug(264) <<
"Warning: Cannot find \"unknown\" icon.";
1588 pix = QPixmap(32,32);
1603 return globalIconLoader;
1616 #include "kiconloader.moc"
static void reconfigure()
Reconfigure the theme.
QStringList loadAnimated(const QString &name, KIconLoader::Group group, int size=0) const
Loads an animated icon as a series of still frames.
int defaultSize(KIconLoader::Group group) const
The default size of this theme for a certain icon group.
void newIconLoader()
Re-initialize the global icon loader.
int IconSize(KIconLoader::Group group)
void addExtraDesktopThemes()
Adds all the default themes from other desktops at the end of the list of icon themes.
int currentSize(KIconLoader::Group group) const
Returns the current size of the icon group.
QMovie * loadMovie(const QString &name, KIconLoader::Group group, int size=0, QObject *parent=0) const
Loads an animated icon.
void addAppDir(const QString &appname)
Adds appname to the list of application specific directories.
QPixmap MainBarIcon(const QString &name, int size=0, int state=KIconLoader::DefaultState, const QStringList &overlays=QStringList())
bool hasContext(KIconLoader::Context context) const
static KIconLoader * global()
Returns the global icon loader initialized with the global KComponentData.
bool isValid() const
The icon theme exists?
#define K_GLOBAL_STATIC(TYPE, NAME)
const char * name(StandardAction id)
This will return the internal name of a given standard action.
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KAction * find(const QObject *recvr, const char *slot, QObject *parent)
Initiate a 'find' request in the current document.
bool alphaBlending(KIconLoader::Group group) const
Checks whether the user wants to blend the icons with the background using the alpha channel informat...
static KGlobalSettings * self()
Return the KGlobalSettings singleton.
QString moviePath(const QString &name, KIconLoader::Group group, int size=0) const
Returns the path to an animated icon.
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
static bool exists(const QString &fullPath)
QStringList queryIcons(int group_or_size, KIconLoader::Context context=KIconLoader::Any) const
Queries all available icons for a specific group, having a specific context.
QIcon UserIconSet(const QString &name)
KSharedConfigPtr config()
QStringList queryIconsByContext(int group_or_size, KIconLoader::Context context=KIconLoader::Any) const
Queries all available icons for a specific context.
QPixmap SmallIcon(const QString &name, int size=0, int state=KIconLoader::DefaultState, const QStringList &overlays=QStringList())
Some icon with unknown purpose.
QPixmap loadIcon(const QString &name, KIconLoader::Group group, int size=0, int state=KIconLoader::DefaultState, const QStringList &overlays=QStringList(), QString *path_store=0L, bool canReturnNull=false) const
Loads an icon.
Small icons, e.g. for buttons.
const KShortcut & insert()
Toggle insert/overwrite (with visual feedback, e.g.
void output(QList< Action > actions, QHash< QString, QString > domain)
Take the best match if there is no exact match.
QPixmap loadMimeTypeIcon(const QString &iconName, KIconLoader::Group group, int size=0, int state=KIconLoader::DefaultState, const QStringList &overlays=QStringList(), QString *path_store=0) const
Loads an icon for a mimetype.
QIcon SmallIconSet(const QString &name, int size=0)
QString componentName() const
K_GLOBAL_STATIC_WITH_ARGS(QString, NULL_EFFECT_FINGERPRINT,(QString::fromLatin1("noeffect"))) static bool pathIsRelative(const QString &path)
Checks for relative paths quickly on UNIX-alikes, slowly on everything else.
KIconTheme * theme() const
Returns a pointer to the current theme.
KIconEffect * iconEffect() const
Returns a pointer to the KIconEffect object used by the icon loader.
QPixmap DesktopIcon(const QString &name, int size=0, int state=KIconLoader::DefaultState, const QStringList &overlays=QStringList())
bool extraDesktopThemesAdded() const
Returns if the default icon themes of other desktops have been added to the list of icon themes where...
QStringList resourceDirs(const char *type) const
QPixmap UserIcon(const QString &name, int state=KIconLoader::DefaultState, const QStringList &overlays=QStringList())
QIcon BarIconSet(const QString &name, int size=0)
MatchType
The type of a match.
QIcon MainBarIconSet(const QString &name, int size=0)
Last state (last constant)
static QString locateLocal(const char *type, const QString &filename, const KComponentData &cData=KGlobal::mainComponent())
void iconLoaderSettingsChanged()
Emitted by newIconLoader once the new settings have been loaded.
Context
Defines the context of the icon.
Only try to find an exact match.
Group
The group of the icon.
void reconfigure(const QString &_appname, KStandardDirs *_dirs)
Called by KComponentData::newIconLoader to reconfigure the icon loader.
const KComponentData & mainComponent()
KIconLoader(const QString &appname=QString(), KStandardDirs *dirs=0, QObject *parent=0)
Constructs an iconloader.
static QString defaultThemeName()
Returns the default icon theme.
QIcon loadIconSet(const QString &name, KIconLoader::Group group, int size=0, bool canReturnNull=false)
Creates an icon set, that will do on-demand loading of the icon.
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
void drawOverlays(const QStringList &overlays, QPixmap &pixmap, KIconLoader::Group group, int state=KIconLoader::DefaultState) const
Draws overlays on the specified pixmap, it takes the width and height of the pixmap into consideratio...
const QString & staticQString(const char *str)
QStringList findAllResources(const char *type, const QString &filter=QString(), SearchOptions options=NoSearchOptions) const
QStringList queryIconsByDir(const QString &iconsDir) const
Returns a list of all icons (*.png or *.xpm extension) in the given directory.
Applies effects to icons.
static QPixmap unknown()
Returns the unknown icon.
static QString current()
Returns the current icon theme.
QIcon DesktopIconSet(const QString &name, int size=0)
QString internalName() const
The internal name of the icon theme (same as the name argument passed to the constructor).
QPixmap BarIcon(const QString &name, int size=0, int state=KIconLoader::DefaultState, const QStringList &overlays=QStringList())
KStandardDirs * dirs() const
QString iconPath(const QString &name, int group_or_size, bool canReturnNull=false) const
Returns the path of an icon.