Verified Commit fd3ef7c3 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

shell: add images_dark definition in WallpaperPackage

parent b9a3005f
......@@ -7,6 +7,7 @@
#include "wallpaperpackage.h"
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <klocalizedstring.h>
......@@ -19,12 +20,17 @@ WallpaperPackage::WallpaperPackage(QObject *parent, const QVariantList &args)
void WallpaperPackage::initPackage(KPackage::Package *package)
{
package->addDirectoryDefinition("images", QStringLiteral("images/"), i18n("Images"));
package->addDirectoryDefinition(QByteArrayLiteral("images_dark"),
QStringLiteral("images_dark%1").arg(QDir::separator()),
i18n("Images for dark color scheme"));
QStringList mimetypes;
mimetypes << QStringLiteral("image/svg") << QStringLiteral("image/png") << QStringLiteral("image/jpeg") << QStringLiteral("image/jpg");
package->setMimeTypes("images", mimetypes);
package->setMimeTypes(QByteArrayLiteral("images_dark"), mimetypes);
package->setRequired("images", true);
package->setRequired(QByteArrayLiteral("images_dark"), false);
package->addFileDefinition("screenshot", QStringLiteral("screenshot.png"), i18n("Screenshot"));
package->setAllowExternalPaths(true);
}
......@@ -49,13 +55,16 @@ void WallpaperPackage::pathChanged(KPackage::Package *package)
QFileInfo info(ppath);
const bool isFullPackage = info.isDir();
package->removeDefinition("preferred");
package->removeDefinition(QByteArrayLiteral("preferredDark"));
package->setRequired("images", isFullPackage);
package->setRequired(QByteArrayLiteral("images_dark"), false);
if (isFullPackage) {
package->setContentsPrefixPaths(QStringList() << QStringLiteral("contents/"));
} else {
package->addFileDefinition("screenshot", info.fileName(), i18n("Preview"));
package->addFileDefinition("preferred", info.fileName(), QString());
package->addFileDefinition(QByteArrayLiteral("preferredDark"), info.fileName(), QString());
package->setContentsPrefixPaths(QStringList());
package->setPath(info.path());
}
......
......@@ -145,8 +145,6 @@ void PackageFinder::findPreferredImageInPackage(KPackage::Package &package, cons
return preferred;
};
package.addDirectoryDefinition(QByteArrayLiteral("images_dark"), QStringLiteral("images_dark"), QStringLiteral("Dark Images"));
const QString preferred = findBestMatch(QByteArrayLiteral("images"));
const QString preferredDark = findBestMatch(QByteArrayLiteral("images_dark"));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment