From 35e376b0b83032d1ffc63dd97ca25e0ef67fffb0 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Fri, 6 Aug 2010 01:28:09 +0000 Subject: [PATCH] give datanegines their own package description; gets rid of various bits of cruft inherited unduly from PlasmoidPackage as well as adds a services/ dir for .operation files. svn path=/trunk/KDE/kdelibs/; revision=1159709 --- private/packages.cpp | 34 ++++++++++++++++++++++++++++++++++ private/packages_p.h | 11 +++++++++++ scripting/scriptengine.cpp | 4 +++- 3 files changed, 48 insertions(+), 1 deletion(-) 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;