diff --git a/private/packages.cpp b/private/packages.cpp index 91ae23a47..151202fe1 100644 --- a/private/packages.cpp +++ b/private/packages.cpp @@ -103,6 +103,40 @@ void PlasmoidPackage::createNewWidgetBrowser(QWidget *parent) #endif } +DataEnginePackage::DataEnginePackage(QObject *parent) + : Plasma::PackageStructure(parent, QString("DataEngine")) +{ + addDirectoryDefinition("data", "data", i18n("Data Files")); + + addDirectoryDefinition("scripts", "code", i18n("Executable Scripts")); + QStringList mimetypes; + mimetypes << "text/plain"; + setMimetypes("scripts", mimetypes); + + addDirectoryDefinition("services", "services/", i18n("Service Descriptions")); + setMimetypes("services", mimetypes); + + addDirectoryDefinition("translations", "locale", i18n("Translations")); + + addFileDefinition("mainscript", "code/main", i18n("Main Script File")); + setRequired("mainscript", true); +} + +DataEnginePackage::~DataEnginePackage() +{ +} + +void DataEnginePackage::pathChanged() +{ + KDesktopFile config(path() + "/metadata.desktop"); + KConfigGroup cg = config.desktopGroup(); + QString mainScript = cg.readEntry("X-Plasma-MainScript", QString()); + if (!mainScript.isEmpty()) { + addFileDefinition("mainscript", mainScript, i18n("Main Script File")); + setRequired("mainscript", true); + } +} + ThemePackage::ThemePackage(QObject *parent) : Plasma::PackageStructure(parent, QString("Plasma Theme")) { diff --git a/private/packages_p.h b/private/packages_p.h index 79d6cd713..dfce64d8a 100644 --- a/private/packages_p.h +++ b/private/packages_p.h @@ -53,6 +53,17 @@ private: #endif }; +class DataEnginePackage : public PackageStructure +{ + Q_OBJECT +public: + explicit DataEnginePackage(QObject *parent = 0); + ~DataEnginePackage(); + +protected: + void pathChanged(); +}; + class ThemePackage : public PackageStructure { Q_OBJECT diff --git a/scripting/scriptengine.cpp b/scripting/scriptengine.cpp index e466f55c2..3ca5ee1b6 100644 --- a/scripting/scriptengine.cpp +++ b/scripting/scriptengine.cpp @@ -251,11 +251,13 @@ PackageStructure::Ptr defaultPackageStructure(ComponentType type) { switch (type) { case AppletComponent: - case DataEngineComponent: case WallpaperComponent: case RunnerComponent: return PackageStructure::Ptr(new PlasmoidPackage()); break; + case DataEngineComponent: + return PackageStructure::Ptr(new DataEnginePackage()); + break; default: // TODO: we don't have any special structures for other components yet break;