From 8b72b0b3ef2a55deb40accd527a7d5ac1d9d0bca Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Fri, 9 Nov 2012 14:05:45 +0100 Subject: [PATCH] provide a containment package specialization this will allow containments to have a different qml file --- private/packages.cpp | 16 +++++++++++++--- private/packages_p.h | 11 +++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/private/packages.cpp b/private/packages.cpp index 2651968a9..9b1a68ff2 100644 --- a/private/packages.cpp +++ b/private/packages.cpp @@ -44,17 +44,22 @@ void ChangeableMainScriptPackage::initPackage(Package *package) package->setRequired("mainscript", true); } -QString ChangeableMainScriptPackage::findMainScript(Package *package) +QString ChangeableMainScriptPackage::findMainScript(Package *package) const { Q_UNUSED(package) return QString(); } +QString ChangeableMainScriptPackage::mainScriptConfigKey() const +{ + return QLatin1String("X-Plasma-MainScript"); +} + void ChangeableMainScriptPackage::pathChanged(Package *package) { KDesktopFile config(package->path() + "/metadata.desktop"); KConfigGroup cg = config.desktopGroup(); - QString mainScript = cg.readEntry("X-Plasma-MainScript", QString()); + QString mainScript = cg.readEntry(mainScriptConfigKey(), QString()); if (mainScript.isEmpty()) { mainScript = findMainScript(package); @@ -71,7 +76,7 @@ void ChangeableMainScriptPackage::pathChanged(Package *package) } } -QString PlasmoidPackage::findMainScript(Package *package) +QString PlasmoidPackage::findMainScript(Package *package) const { const QString mainScript = package->path() + "/ui/main.qml"; if (QFile::exists(mainScript)) { @@ -125,6 +130,11 @@ void PlasmoidPackage::initPackage(Package *package) package->addDirectoryDefinition("animations", "animations", i18n("Animation scripts")); } +QString ContainmentPackage::mainScriptConfigKey() const +{ + return QLatin1String("X-Plasma-Containment-MainScript"); +} + void DataEnginePackage::initPackage(Package *package) { ChangeableMainScriptPackage::initPackage(package); diff --git a/private/packages_p.h b/private/packages_p.h index 0a65b16d7..0fb11e453 100644 --- a/private/packages_p.h +++ b/private/packages_p.h @@ -33,7 +33,8 @@ public: void initPackage(Package *package); protected: - virtual QString findMainScript(Package *package); + virtual QString findMainScript(Package *package) const; + virtual QString mainScriptConfigKey() const; void pathChanged(Package *package); }; @@ -43,7 +44,13 @@ public: void initPackage(Package *package); protected: - QString findMainScript(Package *package); + QString findMainScript(Package *package) const; +}; + +class ContainmentPackage : public PlasmoidPackage +{ +public: + QString mainScriptConfigKey() const; }; class DataEnginePackage : public ChangeableMainScriptPackage