diff --git a/wallpapers/image/backgroundlistmodel.h b/wallpapers/image/backgroundlistmodel.h --- a/wallpapers/image/backgroundlistmodel.h +++ b/wallpapers/image/backgroundlistmodel.h @@ -130,7 +130,7 @@ QString token() const; - static const QSet &suffixes(); + static const QStringList &suffixes(); Q_SIGNALS: void backgroundsFound(const QStringList &paths, const QString &token); @@ -142,7 +142,7 @@ QStringList m_paths; QString m_token; - static QSet m_suffixes; + static QStringList m_suffixes; }; #endif // BACKGROUNDLISTMODEL_H diff --git a/wallpapers/image/backgroundlistmodel.cpp b/wallpapers/image/backgroundlistmodel.cpp --- a/wallpapers/image/backgroundlistmodel.cpp +++ b/wallpapers/image/backgroundlistmodel.cpp @@ -29,6 +29,9 @@ #include #include #include +#include +#include +#include #include #include @@ -42,7 +45,7 @@ #include "image.h" -QSet BackgroundFinder::m_suffixes; +QStringList BackgroundFinder::m_suffixes; ImageSizeFinder::ImageSizeFinder(const QString &path, QObject *parent) : QObject(parent), @@ -500,10 +503,20 @@ return m_token; } -const QSet &BackgroundFinder::suffixes() +const QStringList &BackgroundFinder::suffixes() { - if(m_suffixes.isEmpty()) { - m_suffixes << QString::fromLatin1("png") << QString::fromLatin1("jpeg") << QString::fromLatin1("jpg") << QString::fromLatin1("svg") << QString::fromLatin1("svgz"); + if (m_suffixes.isEmpty()) { + QSet suffixes; + + QMimeDatabase db; + Q_FOREACH (const QByteArray &mimeType, QImageReader::supportedMimeTypes()) { + QMimeType mime(db.mimeTypeForName(mimeType)); + Q_FOREACH (const QString &pattern, mime.globPatterns()) { + suffixes.insert(pattern); + } + } + + m_suffixes = suffixes.toList(); } return m_suffixes; @@ -513,12 +526,12 @@ { QTime t; t.start(); - const QSet &fileSuffixes = suffixes(); QStringList papersFound; QDir dir; dir.setFilter(QDir::AllDirs | QDir::Files | QDir::Hidden | QDir::Readable); + dir.setNameFilters(suffixes()); KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Wallpaper/Images")); int i; @@ -550,7 +563,7 @@ // add this to the directories we should be looking at m_paths.append(filePath); - } else if (fileSuffixes.contains(wp.suffix().toLower())) { + } else { //qDebug() << "adding image file" << wp.filePath(); papersFound << wp.filePath(); }