Add the "theme" directory to the plasmoid directory structure

This adds an extra step to the lookup of SVG images created with the
Svg() global function: after looking in images/ in the plasmoid and then
in the desktop theme, it looks in theme/$DESKTOP_THEME_NAME and then
theme/ in the plasmoid.

This allows plasmoid authors to add images that they want to allow theme
authors to override.

Forward-port of review request 109857.
This commit is contained in:
Alex Merry 2013-05-11 12:25:35 +01:00
parent 355a95fe92
commit 33d41aea3d
2 changed files with 5 additions and 1 deletions

View File

@ -83,7 +83,7 @@ void PackageStructureTest::multiplePaths()
void PackageStructureTest::directories()
{
QList<const char*> dirs;
dirs << "config" << "data" << "images" << "scripts" << "translations" << "ui";
dirs << "config" << "data" << "images" << "theme" << "scripts" << "translations" << "ui";
QList<const char*> psDirs = ps.directories();
@ -156,6 +156,7 @@ void PackageStructureTest::requiredFiles()
void PackageStructureTest::path()
{
QCOMPARE(ps.filePath("images"), QDir(m_packagePath + QString("/contents/images")).canonicalPath());
QCOMPARE(ps.filePath("theme"), QDir(m_packagePath + QString("/contents/theme")).canonicalPath());
QCOMPARE(ps.filePath("mainscript"), QFileInfo(m_packagePath + QString("/contents/ui/main.qml")).canonicalFilePath());
}
@ -175,6 +176,7 @@ void PackageStructureTest::mimeTypes()
QStringList mimeTypes;
mimeTypes << "image/svg+xml" << "image/png" << "image/jpeg";
QCOMPARE(ps.mimeTypes("images"), mimeTypes);
QCOMPARE(ps.mimeTypes("theme"), mimeTypes);
}
QTEST_MAIN(PackageStructureTest)

View File

@ -82,9 +82,11 @@ void GenericPackage::initPackage(Package *package)
package->setDefaultPackageRoot("plasma/packages/");
package->addDirectoryDefinition("images", "images", i18n("Images"));
package->addDirectoryDefinition("theme", "theme", i18n("Themed Images"));
QStringList mimetypes;
mimetypes << "image/svg+xml" << "image/png" << "image/jpeg";
package->setMimeTypes("images", mimetypes);
package->setMimeTypes("theme", mimetypes);
package->addDirectoryDefinition("config", "config", i18n("Configuration Definitions"));
mimetypes.clear();