8#include "private/imageset_p.h"
9#include "private/svg_p.h"
15#include <QMutableListIterator>
17#include <QStringBuilder>
21#include <KConfigGroup>
32 if (!ImageSetPrivate::globalImageSet) {
33 ImageSetPrivate::globalImageSet =
new ImageSetPrivate;
38 ImageSetPrivate::globalImageSet->ref.ref();
39 d = ImageSetPrivate::globalImageSet;
47 auto &priv = ImageSetPrivate::themes[imageSetName];
49 priv =
new ImageSetPrivate;
59 bool useCache = d->cacheImageSet;
60 d->cacheImageSet =
false;
62 d->basePath = basePath;
63 if (!d->basePath.endsWith(QDir::separator())) {
64 d->basePath += QDir::separator();
67 d->setImageSetName(imageSetName,
false);
68 d->cacheImageSet = useCache;
75 if (d == ImageSetPrivate::globalImageSet) {
76 if (!d->ref.deref()) {
77 disconnect(ImageSetPrivate::globalImageSet,
nullptr,
this,
nullptr);
78 delete ImageSetPrivate::globalImageSet;
79 ImageSetPrivate::globalImageSet =
nullptr;
83 if (!d->ref.deref()) {
84 delete ImageSetPrivate::themes.take(d->imageSetName);
89void ImageSet::setBasePath(
const QString &basePath)
91 if (d->basePath == basePath) {
95 d->basePath = basePath;
103 d->discardCache(PixmapCache | SvgElementsCache);
104 d->cachesToDiscard = NoCache;
106 Q_EMIT basePathChanged(basePath);
107 Q_EMIT imageSetChanged(d->imageSetName);
117 d->selectors = selectors;
118 d->scheduleImageSetChangeNotification(PixmapCache | SvgElementsCache);
126void ImageSet::setImageSetName(
const QString &imageSetName)
128 if (d->imageSetName == imageSetName) {
132 if (d != ImageSetPrivate::globalImageSet) {
134 if (!d->ref.deref()) {
135 delete ImageSetPrivate::themes.take(d->imageSetName);
138 auto &priv = ImageSetPrivate::themes[imageSetName];
140 priv =
new ImageSetPrivate;
147 connect(d, &ImageSetPrivate::imageSetChanged,
this, &ImageSet::imageSetChanged);
150 d->setImageSetName(imageSetName,
true);
155 return d->imageSetName;
168 QString path = d->findInImageSet(svgzName, d->imageSetName);
173 path = d->findInImageSet(svgName, d->imageSetName);
176 for (
int i = 0; path.
isEmpty() && i < d->fallbackImageSets.count(); ++i) {
177 if (d->imageSetName == d->fallbackImageSets[i]) {
182 path = d->findInImageSet(svgzName, d->fallbackImageSets[i]);
186 path = d->findInImageSet(svgName, d->fallbackImageSets[i]);
203 QString path = d->findInImageSet(name, d->imageSetName);
207 for (
int i = 0; path.
isEmpty() && i < d->fallbackImageSets.count(); ++i) {
208 if (d->imageSetName == d->fallbackImageSets[i]) {
212 path = d->findInImageSet(name, d->fallbackImageSets[i]);
219bool ImageSet::currentImageSetHasImage(
const QString &name)
const
228 path = d->findInImageSet(name %
QLatin1String(
".svg"), d->imageSetName);
230 return path.
contains(d->basePath % d->imageSetName);
233void ImageSet::setUseGlobalSettings(
bool useGlobal)
235 if (d->useGlobal == useGlobal) {
239 d->useGlobal = useGlobal;
241 d->imageSetName.clear();
244bool ImageSet::useGlobalSettings()
const
249void ImageSet::setCacheLimit(
int kbytes)
251 d->cacheSize = kbytes;
252 delete d->pixmapCache;
253 d->pixmapCache =
nullptr;
258 return d->pluginMetaData;
263#include "moc_imageset.cpp"
void imageSetChanged(const QString &basePath)
@brif This signal is emitted when the user makes changes to the theme.
ImageSet(QObject *parent=nullptr)
Default constructor.
QCoreApplication * instance()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:08 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.