diff --git a/src/kiconeffect.h b/src/kiconeffect.h --- a/src/kiconeffect.h +++ b/src/kiconeffect.h @@ -217,6 +217,8 @@ */ static void overlay(QImage &src, QImage &overlay); + KIconEffect& operator=(const KIconEffect &other); + private: KIconEffectPrivate *const d; }; diff --git a/src/kiconeffect.cpp b/src/kiconeffect.cpp --- a/src/kiconeffect.cpp +++ b/src/kiconeffect.cpp @@ -71,6 +71,12 @@ delete d; } +KIconEffect& KIconEffect::operator=(const KIconEffect &other) +{ + memcpy(d, other.d, sizeof(*d)); + return *this; +} + void KIconEffect::init() { KSharedConfig::Ptr config = KSharedConfig::openConfig(); diff --git a/src/kiconloader.h b/src/kiconloader.h --- a/src/kiconloader.h +++ b/src/kiconloader.h @@ -478,7 +478,9 @@ * Returns a pointer to the KIconEffect object used by the icon loader. * @return the KIconEffect. */ - KIconEffect *iconEffect() const; +#ifndef KICONTHEMES_NO_DEPRECATED + KICONTHEMES_DEPRECATED KIconEffect *iconEffect() const; +#endif /** * Reconfigure the icon loader, for instance to change the associated app name or extra search paths. @@ -520,7 +522,7 @@ /** * Sets the colors for this KIconLoader. - * NOTE: if you set a custom palette, if you are using some colors from + * NOTE: if you set a custom palette, if you are using some colors from * application's palette, you need to track the application palette changes by yourself. * If you no longer wish to use a custom palette, use resetPalette() * @see resetPalette diff --git a/src/kiconloader.cpp b/src/kiconloader.cpp --- a/src/kiconloader.cpp +++ b/src/kiconloader.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include // kdecore @@ -320,7 +321,7 @@ * icon metadata. Ensure the metadata is normalized first. */ QString makeCacheKey(const QString &name, KIconLoader::Group group, const QStringList &overlays, - int size, qreal scale, int state) const; + int size, qreal scale, int state); /** * @internal @@ -355,7 +356,7 @@ /** * Find the given file in the search paths. */ - QString locate(const QString &fileName); + QString locate(const QString &fileName) const; /** * @internal @@ -372,6 +373,45 @@ return true; } + void addAppDir(const QString &appname, const QString &themeBaseDir); + + QString iconPath(const QString &_name, int group_or_size, bool canReturnNull); + + QString iconPath(const QString &_name, int group_or_size, bool canReturnNull, qreal scale); + + QPixmap loadMimeTypeIcon(const QString &_iconName, KIconLoader::Group group, int size, + int state, const QStringList &overlays, QString *path_store); + + QPixmap loadIcon(const QString &_name, KIconLoader::Group group, int size, + int state, const QStringList &overlays, + QString *path_store, bool canReturnNull); + + QPixmap loadScaledIcon(const QString &_name, KIconLoader::Group group, qreal scale, + int size, int state, const QStringList &overlays, + QString *path_store, bool canReturnNull); + + QString moviePath(const QString &name, KIconLoader::Group group, int size); + + QStringList loadAnimated(const QString &name, KIconLoader::Group group, int size); + + KIconTheme *theme(); + + int currentSize(KIconLoader::Group group) const; + + QStringList queryIconsByContext(int group_or_size, KIconLoader::Context context); + + QStringList queryIcons(int group_or_size, KIconLoader::Context context); + + bool hasContext(KIconLoader::Context context); + + bool alphaBlending(KIconLoader::Group group) const; + + bool hasIcon(const QString &name); + + void setCustomPalette(const QPalette &palette); + + void resetPalette(); + KIconLoader *const q; QStringList mThemesInTree; @@ -393,7 +433,7 @@ bool mIconThemeInited : 1; QString appname; - void drawOverlays(const KIconLoader *loader, KIconLoader::Group group, int state, QPixmap &pix, const QStringList &overlays); + void drawOverlays(const QStringList &overlays, QPixmap &pixmap, KIconLoader::Group group, int state); QHash mIconAvailability; // icon name -> true (known to be available) or false (known to be unavailable) QElapsedTimer mLastUnknownIconCheck; // recheck for unknown icons after kiconloader_ms_between_checks @@ -470,7 +510,7 @@ Q_GLOBAL_STATIC(KIconLoaderGlobalData, s_globalData) -void KIconLoaderPrivate::drawOverlays(const KIconLoader *iconLoader, KIconLoader::Group group, int state, QPixmap &pix, const QStringList &overlays) +void KIconLoaderPrivate::drawOverlays(const QStringList &overlays, QPixmap &pix, KIconLoader::Group group, int state) { if (overlays.isEmpty()) { return; @@ -508,7 +548,7 @@ //TODO: should we pass in the kstate? it results in a slower // path, and perhaps emblems should remain in the default state // anyways? - QPixmap pixmap = iconLoader->loadIcon(overlay, group, overlaySize, state, QStringList(), nullptr, true); + QPixmap pixmap = loadIcon(overlay, group, overlaySize, state, QStringList(), nullptr, true); if (pixmap.isNull()) { continue; @@ -565,29 +605,60 @@ } q->newIconLoader(); - mIconAvailability.clear(); emit q->iconChanged(group); } +class SafePrivate : public KIconLoaderPrivate +{ + struct Proxy + { + QMutex &mutex; + KIconLoaderPrivate *d; + Proxy(QMutex &m, KIconLoaderPrivate *p) : mutex(m), d(p) + { + mutex.lock(); + } + ~Proxy() + { + mutex.unlock(); + } + KIconLoaderPrivate* operator->() + { + return d; + } + }; + QMutex mutex; +public: + using KIconLoaderPrivate::KIconLoaderPrivate; + Proxy lock() + { + return Proxy{ mutex, this }; + } +}; + +#define S_D(d) static_cast(d)->lock() + KIconLoader::KIconLoader(const QString &_appname, const QStringList &extraSearchPaths, QObject *parent) : QObject(parent) { setObjectName(_appname); - d = new KIconLoaderPrivate(this); + d = new SafePrivate(this); - connect(s_globalData, SIGNAL(iconChanged(int)), SLOT(_k_refreshIcons(int))); + connect(s_globalData, &KIconLoaderGlobalData::iconChanged, this, [this](int group) { + S_D(d)->mIconAvailability.clear(); + d->_k_refreshIcons(group); + }, Qt::QueuedConnection); d->init(_appname, extraSearchPaths); } void KIconLoader::reconfigure(const QString &_appname, const QStringList &extraSearchPaths) { - d->mIconCache->clear(); - d->clear(); - d->init(_appname, extraSearchPaths); + S_D(d)->init(_appname, extraSearchPaths); } void KIconLoaderPrivate::init(const QString &_appname, const QStringList &extraSearchPaths) { + clear(); extraDesktopIconsLoaded = false; mIconThemeInited = false; mpThemeRoot = nullptr; @@ -672,15 +743,20 @@ QStringList KIconLoader::searchPaths() const { - return d->searchPaths; + QStringList paths = S_D(d)->searchPaths; + return paths; } void KIconLoader::addAppDir(const QString &appname, const QString &themeBaseDir) { - d->initIconThemes(); + S_D(d)->addAppDir(appname, themeBaseDir); +} - d->searchPaths.append(appname + QStringLiteral("/pics")); - d->addAppThemes(appname, themeBaseDir); +void KIconLoaderPrivate::addAppDir(const QString &appname, const QString &themeBaseDir) +{ + initIconThemes(); + searchPaths.append(appname + QStringLiteral("/pics")); + addAppThemes(appname, themeBaseDir); } void KIconLoaderPrivate::addAppThemes(const QString &appname, const QString &themeBaseDir) @@ -808,7 +884,7 @@ void KIconLoader::drawOverlays(const QStringList &overlays, QPixmap &pixmap, KIconLoader::Group group, int state) const { - d->drawOverlays(this, group, state, pixmap, overlays); + S_D(d)->drawOverlays(overlays, pixmap, group, state); } QString KIconLoaderPrivate::removeIconExtension(const QString &name) const @@ -857,7 +933,7 @@ } QString KIconLoaderPrivate::makeCacheKey(const QString &name, KIconLoader::Group group, - const QStringList &overlays, int size, qreal scale, int state) const + const QStringList &overlays, int size, qreal scale, int state) { // The KSharedDataCache is shared so add some namespacing. The following code // uses QStringBuilder (new in Qt 4.6) @@ -876,7 +952,7 @@ : NULL_EFFECT_FINGERPRINT()) % QLatin1Char('_') % paletteId(mCustomPalette ? mPalette : qApp->palette()) - % (q->theme() && q->theme()->followsColorScheme() && state == KIconLoader::SelectedState ? QStringLiteral("_selected") : QString()); + % (theme() && theme()->followsColorScheme() && state == KIconLoader::SelectedState ? QStringLiteral("_selected") : QString()); } QByteArray KIconLoaderPrivate::processSvg(const QString &path, KIconLoader::States state) const @@ -935,7 +1011,7 @@ QScopedPointer reader; QBuffer buffer; - if (q->theme()->followsColorScheme() && (path.endsWith(QLatin1String("svg")) || path.endsWith(QLatin1String("svgz")))) { + if (theme()->followsColorScheme() && (path.endsWith(QLatin1String("svg")) || path.endsWith(QLatin1String("svgz")))) { buffer.setData(processSvg(path, state)); reader.reset(new QImageReader(&buffer)); } else { @@ -1142,7 +1218,7 @@ return path; } -QString KIconLoaderPrivate::locate(const QString &fileName) +QString KIconLoaderPrivate::locate(const QString &fileName) const { Q_FOREACH (const QString &dir, searchPaths) { const QString path = dir + QLatin1Char('/') + fileName; @@ -1164,6 +1240,13 @@ QString KIconLoader::iconPath(const QString &_name, int group_or_size, bool canReturnNull) const +{ + QString path = S_D(d)->iconPath(_name, group_or_size, canReturnNull, 1 /*scale*/); + return path; +} + +QString KIconLoaderPrivate::iconPath(const QString &_name, int group_or_size, + bool canReturnNull) { return iconPath(_name, group_or_size, canReturnNull, 1 /*scale*/); } @@ -1171,7 +1254,14 @@ QString KIconLoader::iconPath(const QString &_name, int group_or_size, bool canReturnNull, qreal scale) const { - if (!d->initIconThemes()) { + QString path = S_D(d)->iconPath(_name, group_or_size, canReturnNull, scale); + return path; +} + +QString KIconLoaderPrivate::iconPath(const QString &_name, int group_or_size, + bool canReturnNull, qreal scale) +{ + if (initIconThemes()) { return QString(); } @@ -1180,19 +1270,19 @@ return _name; } - QString name = d->removeIconExtension(_name); + QString name = removeIconExtension(_name); QString path; if (group_or_size == KIconLoader::User) { - path = d->locate(name + QLatin1String(".png")); + path = locate(name + QLatin1String(".png")); if (path.isEmpty()) { - path = d->locate(name + QLatin1String(".svgz")); + path = locate(name + QLatin1String(".svgz")); } if (path.isEmpty()) { - path = d->locate(name + QLatin1String(".svg")); + path = locate(name + QLatin1String(".svg")); } if (path.isEmpty()) { - path = d->locate(name + QLatin1String(".xpm")); + path = locate(name + QLatin1String(".xpm")); } return path; } @@ -1204,7 +1294,7 @@ int size; if (group_or_size >= 0) { - size = d->mpGroups[group_or_size].size; + size = mpGroups[group_or_size].size; } else { size = -group_or_size; } @@ -1213,11 +1303,11 @@ if (canReturnNull) { return QString(); } else { - return d->unknownIconPath(size, scale); + return unknownIconPath(size, scale); } } - path = d->findMatchingIconWithGenericFallbacks(name, size, scale); + path = findMatchingIconWithGenericFallbacks(name, size, scale); if (path.isEmpty()) { // Try "User" group too. @@ -1226,13 +1316,20 @@ return path; } - return d->unknownIconPath(size, scale); + return unknownIconPath(size, scale); } return path; } QPixmap KIconLoader::loadMimeTypeIcon(const QString &_iconName, KIconLoader::Group group, int size, int state, const QStringList &overlays, QString *path_store) const +{ + QPixmap pixmap = S_D(d)->loadMimeTypeIcon(_iconName, group, size, state, overlays, path_store); + return pixmap; +} + +QPixmap KIconLoaderPrivate::loadMimeTypeIcon(const QString &_iconName, KIconLoader::Group group, int size, + int state, const QStringList &overlays, QString *path_store) { QString iconName = _iconName; const int slashindex = iconName.indexOf(QLatin1Char('/')); @@ -1240,12 +1337,12 @@ iconName[slashindex] = QLatin1Char('-'); } - if (!d->extraDesktopIconsLoaded) { + if (!extraDesktopIconsLoaded) { const QPixmap pixmap = loadIcon(iconName, group, size, state, overlays, path_store, true); if (!pixmap.isNull()) { return pixmap; } - d->addExtraDesktopThemes(); + addExtraDesktopThemes(); } const QPixmap pixmap = loadIcon(iconName, group, size, state, overlays, path_store, true); if (pixmap.isNull()) { @@ -1255,18 +1352,32 @@ return pixmap; } - - QPixmap KIconLoader::loadIcon(const QString &_name, KIconLoader::Group group, int size, int state, const QStringList &overlays, QString *path_store, bool canReturnNull) const { -return loadScaledIcon(_name, group, 1.0 /*scale*/, size, state, overlays, path_store, canReturnNull); + QPixmap pixmap = S_D(d)->loadIcon(_name, group, size, state, overlays, path_store, canReturnNull); + return pixmap; +} + +QPixmap KIconLoaderPrivate::loadIcon(const QString &_name, KIconLoader::Group group, int size, + int state, const QStringList &overlays, + QString *path_store, bool canReturnNull) +{ + return loadScaledIcon(_name, group, 1.0 /*scale*/, size, state, overlays, path_store, canReturnNull); } QPixmap KIconLoader::loadScaledIcon(const QString &_name, KIconLoader::Group group, qreal scale, int size, int state, const QStringList &overlays, QString *path_store, bool canReturnNull) const +{ + QPixmap pixmap = S_D(d)->loadScaledIcon(_name, group, scale, size, state, overlays, path_store, canReturnNull); + return pixmap; +} + +QPixmap KIconLoaderPrivate::loadScaledIcon(const QString &_name, KIconLoader::Group group, qreal scale, + int size, int state, const QStringList &overlays, + QString *path_store, bool canReturnNull) { QString name = _name; bool favIconOverlay = false; @@ -1293,7 +1404,7 @@ bool absolutePath = !pathIsRelative(name); if (!absolutePath) { - name = d->removeIconExtension(name); + name = removeIconExtension(name); } // Don't bother looking for an icon with no name. @@ -1303,16 +1414,16 @@ // May modify group, size, or state. This function puts them into sane // states. - d->normalizeIconMetadata(group, size, state); + normalizeIconMetadata(group, size, state); // See if the image is already cached. - QString key = d->makeCacheKey(name, group, overlays, size, scale, state); + QString key = makeCacheKey(name, group, overlays, size, scale, state); QPixmap pix; bool iconWasUnknown = false; QString path; - if (d->findCachedPixmapWithPath(key, pix, path)) { + if (findCachedPixmapWithPath(key, pix, path)) { pix.setDevicePixelRatio(scale); if (path_store) { @@ -1324,14 +1435,14 @@ } else { // path is empty for "unknown" icons, which should be searched for // anew regularly - if (!d->shouldCheckForUnknownIcons()) { + if (!shouldCheckForUnknownIcons()) { return canReturnNull ? QPixmap() : pix; } } } // Image is not cached... go find it and apply effects. - if (!d->initIconThemes()) { + if (!initIconThemes()) { return QPixmap(); } @@ -1343,7 +1454,7 @@ if (absolutePath && !favIconOverlay) { path = name; } else { - path = d->findMatchingIconWithGenericFallbacks(favIconOverlay ? QStringLiteral("text-html") : name, size, scale); + path = findMatchingIconWithGenericFallbacks(favIconOverlay ? QStringLiteral("text-html") : name, size, scale); } } @@ -1356,17 +1467,17 @@ // Still can't find it? Use "unknown" if we can't return null. // We keep going in the function so we can ensure this result gets cached. if (path.isEmpty() && !canReturnNull) { - path = d->unknownIconPath(size, scale); + path = unknownIconPath(size, scale); iconWasUnknown = true; } QImage img; if (!path.isEmpty()) { - img = d->createIconImage(path, size, scale, static_cast(state)); + img = createIconImage(path, size, scale, static_cast(state)); } if (group >= 0) { - img = d->mpEffect.apply(img, group, state); + img = mpEffect.apply(img, group, state); } if (favIconOverlay) { @@ -1389,7 +1500,7 @@ // TODO: If we make a loadIcon that returns the image we can convert // drawOverlays to use the image instead of pixmaps as well so we don't // have to transfer so much to the graphics card. - d->drawOverlays(this, group, state, pix, overlays); + drawOverlays(overlays, pix, group, state); // Don't add the path to our unknown icon to the cache, only cache the // actual image. @@ -1397,7 +1508,7 @@ path.clear(); } - d->insertCachedPixmapWithPath(key, pix, path); + insertCachedPixmapWithPath(key, pix, path); if (path_store) { *path_store = path; @@ -1432,11 +1543,17 @@ QString KIconLoader::moviePath(const QString &name, KIconLoader::Group group, int size) const { - if (!d->mpGroups) { + QString path = S_D(d)->moviePath(name, group, size); + return path; +} + +QString KIconLoaderPrivate::moviePath(const QString &name, KIconLoader::Group group, int size) +{ + if (mpGroups) { return QString(); } - d->initIconThemes(); + initIconThemes(); if ((group < -1 || group >= KIconLoader::LastGroup) && group != KIconLoader::User) { qCDebug(KICONTHEMES) << "Illegal icon group:" << group; @@ -1449,15 +1566,15 @@ QString file = name + QStringLiteral(".mng"); if (group == KIconLoader::User) { - file = d->locate(file); + file = locate(file); } else { if (size == 0) { - size = d->mpGroups[group].size; + size = mpGroups[group].size; } QString path; - foreach (KIconThemeNode *themeNode, d->links) { + foreach (KIconThemeNode *themeNode, links) { path = themeNode->theme->iconPath(file, size, KIconLoader::MatchExact); if (!path.isEmpty()) { break; @@ -1465,7 +1582,7 @@ } if (path.isEmpty()) { - foreach (KIconThemeNode *themeNode, d->links) { + foreach (KIconThemeNode *themeNode, links) { path = themeNode->theme->iconPath(file, size, KIconLoader::MatchBest); if (!path.isEmpty()) { break; @@ -1479,14 +1596,20 @@ } QStringList KIconLoader::loadAnimated(const QString &name, KIconLoader::Group group, int size) const +{ + QStringList list = S_D(d)->loadAnimated(name, group, size); + return list; +} + +QStringList KIconLoaderPrivate::loadAnimated(const QString &name, KIconLoader::Group group, int size) { QStringList lst; - if (!d->mpGroups) { + if (!mpGroups) { return lst; } - d->initIconThemes(); + initIconThemes(); if ((group < -1) || (group >= KIconLoader::LastGroup)) { qCDebug(KICONTHEMES) << "Illegal icon group: " << group; @@ -1499,12 +1622,12 @@ QString file = name + QStringLiteral("/0001"); if (group == KIconLoader::User) { - file = d->locate(file + QStringLiteral(".png")); + file = locate(file + QStringLiteral(".png")); } else { if (size == 0) { - size = d->mpGroups[group].size; + size = mpGroups[group].size; } - file = d->findMatchingIcon(file, size, 1); // FIXME scale + file = findMatchingIcon(file, size, 1); // FIXME scale } if (file.isEmpty()) { return lst; @@ -1529,16 +1652,28 @@ KIconTheme *KIconLoader::theme() const { - d->initIconThemes(); - if (d->mpThemeRoot) { - return d->mpThemeRoot->theme; + KIconTheme *theme = S_D(d)->theme(); + return theme; +} + +KIconTheme *KIconLoaderPrivate::theme() +{ + initIconThemes(); + if (mpThemeRoot) { + return mpThemeRoot->theme; } return nullptr; } int KIconLoader::currentSize(KIconLoader::Group group) const { - if (!d->mpGroups) { + int size = S_D(d)->currentSize(group); + return size; +} + +int KIconLoaderPrivate::currentSize(KIconLoader::Group group) const +{ + if (!mpGroups) { return -1; } @@ -1546,7 +1681,7 @@ qCDebug(KICONTHEMES) << "Illegal icon group:" << group; return -1; } - return d->mpGroups[group].size; + return mpGroups[group].size; } QStringList KIconLoader::queryIconsByDir(const QString &iconsDir) const @@ -1561,10 +1696,15 @@ return result; } -QStringList KIconLoader::queryIconsByContext(int group_or_size, - KIconLoader::Context context) const +QStringList KIconLoader::queryIconsByContext(int group_or_size, KIconLoader::Context context) const +{ + QStringList list = S_D(d)->queryIconsByContext(group_or_size, context); + return list; +} + +QStringList KIconLoaderPrivate::queryIconsByContext(int group_or_size, KIconLoader::Context context) { - d->initIconThemes(); + initIconThemes(); QStringList result; if (group_or_size >= KIconLoader::LastGroup) { @@ -1573,12 +1713,12 @@ } int size; if (group_or_size >= 0) { - size = d->mpGroups[group_or_size].size; + size = mpGroups[group_or_size].size; } else { size = -group_or_size; } - foreach (KIconThemeNode *themeNode, d->links) { + foreach (KIconThemeNode *themeNode, links) { themeNode->queryIconsByContext(&result, size, context); } @@ -1593,19 +1733,24 @@ } else { name = (*it).mid(n + 1); } - name = d->removeIconExtension(name); + name = removeIconExtension(name); if (!entries.contains(name)) { entries += name; res2 += *it; } } return res2; - } QStringList KIconLoader::queryIcons(int group_or_size, KIconLoader::Context context) const { - d->initIconThemes(); + QStringList list = S_D(d)->queryIcons(group_or_size, context); + return list; +} + +QStringList KIconLoaderPrivate::queryIcons(int group_or_size, KIconLoader::Context context) +{ + initIconThemes(); QStringList result; if (group_or_size >= KIconLoader::LastGroup) { @@ -1614,12 +1759,12 @@ } int size; if (group_or_size >= 0) { - size = d->mpGroups[group_or_size].size; + size = mpGroups[group_or_size].size; } else { size = -group_or_size; } - foreach (KIconThemeNode *themeNode, d->links) { + foreach (KIconThemeNode *themeNode, links) { themeNode->queryIcons(&result, size, context); } @@ -1634,7 +1779,7 @@ } else { name = (*it).mid(n + 1); } - name = d->removeIconExtension(name); + name = removeIconExtension(name); if (!entries.contains(name)) { entries += name; res2 += *it; @@ -1646,23 +1791,40 @@ // used by KIconDialog to find out which contexts to offer in a combobox bool KIconLoader::hasContext(KIconLoader::Context context) const { - d->initIconThemes(); + bool hasContext = S_D(d)->hasContext(context); + return hasContext; +} - foreach (KIconThemeNode *themeNode, d->links) +bool KIconLoaderPrivate::hasContext(KIconLoader::Context context) +{ + initIconThemes(); + + foreach (KIconThemeNode *themeNode, links) if (themeNode->theme->hasContext(context)) { return true; } return false; } +// deprecated +#ifndef KICONTHEMES_NO_DEPRECATED KIconEffect *KIconLoader::iconEffect() const { - return &d->mpEffect; + static KIconEffect effect; + effect = S_D(d)->mpEffect; + return &effect; } +#endif bool KIconLoader::alphaBlending(KIconLoader::Group group) const { - if (!d->mpGroups) { + bool alphaBlending = S_D(d)->alphaBlending(group); + return alphaBlending; +} + +bool KIconLoaderPrivate::alphaBlending(KIconLoader::Group group) const +{ + if (!mpGroups) { return false; } @@ -1794,9 +1956,15 @@ bool KIconLoader::hasIcon(const QString &name) const { - auto it = d->mIconAvailability.constFind(name); - const auto end = d->mIconAvailability.constEnd(); - if (it != end && !it.value() && !d->shouldCheckForUnknownIcons()) { + bool hasIcon = S_D(d)->hasIcon(name); + return hasIcon; +} + +bool KIconLoaderPrivate::hasIcon(const QString &name) +{ + auto it = mIconAvailability.constFind(name); + const auto end = mIconAvailability.constEnd(); + if (it != end && !it.value() && !shouldCheckForUnknownIcons()) { return false; // known to be unavailable } bool found = it != end && it.value(); @@ -1804,26 +1972,37 @@ if (!iconPath(name, KIconLoader::Desktop, KIconLoader::MatchBest).isEmpty()) { found = true; } - d->mIconAvailability.insert(name, found); // remember whether the icon is available or not + mIconAvailability.insert(name, found); // remember whether the icon is available or not } return found; } void KIconLoader::setCustomPalette(const QPalette &palette) { - d->mCustomPalette = true; - d->mPalette = palette; + S_D(d)->setCustomPalette(palette); +} + +void KIconLoaderPrivate::setCustomPalette(const QPalette &palette) +{ + mCustomPalette = true; + mPalette = palette; } QPalette KIconLoader::customPalette() const { - return d->mPalette; + QPalette palette = S_D(d)->mPalette; + return palette; } void KIconLoader::resetPalette() { - d->mCustomPalette = false; - d->mPalette = QPalette(); + S_D(d)->resetPalette(); +} + +void KIconLoaderPrivate::resetPalette() +{ + mCustomPalette = false; + mPalette = QPalette(); } /*** the global icon loader ***/