From 2482eb193c1783df97c87fb992447eae1ac58444 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 7 Aug 2014 16:26:51 +0200 Subject: [PATCH 1/3] allow applets specify a different root than pluginname introduce X-Plasma-RootPath: it would be used instead of the plugin name for package root path if present --- src/plasma/data/servicetypes/plasma-applet.desktop | 3 +++ src/plasma/private/applet_p.cpp | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plasma/data/servicetypes/plasma-applet.desktop b/src/plasma/data/servicetypes/plasma-applet.desktop index dfd6fe8ba..247bbfb5d 100644 --- a/src/plasma/data/servicetypes/plasma-applet.desktop +++ b/src/plasma/data/servicetypes/plasma-applet.desktop @@ -38,6 +38,9 @@ Comment[zh_TW]=Plasma 小程式 [PropertyDef::X-Plasma-API] Type=QString +[PropertyDef::X-Plasma-RootPath] +Type=QString + [PropertyDef::X-Plasma-DropMimeTypes] Type=QStringList diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index 4f00d90e3..684350570 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -132,7 +132,10 @@ void AppletPrivate::init(const QString &packagePath, const QVariantList &args) return; } - const QString path = packagePath.isEmpty() ? appletDescription.pluginName() : packagePath; + QString path = appletDescription.property("X-Plasma-RootPath").toString(); + if (path.isEmpty()) { + path = packagePath.isEmpty() ? appletDescription.pluginName() : packagePath; + } package = new Package(PluginLoader::self()->loadPackage("Plasma/Applet", api)); package->setPath(path); From d7e0a9f0bcf5232caf689debeacc9ca38c46aeb1 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 12 Aug 2014 10:25:11 +0200 Subject: [PATCH 2/3] check X-Plasma-RootPath as well for privates --- src/plasmaquick/packageurlinterceptor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plasmaquick/packageurlinterceptor.cpp b/src/plasmaquick/packageurlinterceptor.cpp index f1e8adcaa..440659d7a 100644 --- a/src/plasmaquick/packageurlinterceptor.cpp +++ b/src/plasmaquick/packageurlinterceptor.cpp @@ -129,7 +129,8 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept QString pathCheck(path.path()); pathCheck = pathCheck.replace(QRegExp(".*org/kde/plasma/private/(.*)/.*"), "org.kde.plasma.\\1"); - if (pathCheck == m_package.metadata().pluginName()) { + if (pathCheck == m_package.metadata().pluginName() || + pathCheck == m_package.metadata().property("X-Plasma-RootPath").toString()) { return path; } else { return QUrl("file://" + allowed + "/org/kde/plasma/accessdenied/qmldir"); From bcf653b9d40f7cc89570465a450fe9e109efb8b6 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 12 Aug 2014 10:34:07 +0200 Subject: [PATCH 3/3] Revert "check X-Plasma-RootPath as well for privates" This reverts commit d7e0a9f0bcf5232caf689debeacc9ca38c46aeb1. --- src/plasmaquick/packageurlinterceptor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plasmaquick/packageurlinterceptor.cpp b/src/plasmaquick/packageurlinterceptor.cpp index 440659d7a..f1e8adcaa 100644 --- a/src/plasmaquick/packageurlinterceptor.cpp +++ b/src/plasmaquick/packageurlinterceptor.cpp @@ -129,8 +129,7 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept QString pathCheck(path.path()); pathCheck = pathCheck.replace(QRegExp(".*org/kde/plasma/private/(.*)/.*"), "org.kde.plasma.\\1"); - if (pathCheck == m_package.metadata().pluginName() || - pathCheck == m_package.metadata().property("X-Plasma-RootPath").toString()) { + if (pathCheck == m_package.metadata().pluginName()) { return path; } else { return QUrl("file://" + allowed + "/org/kde/plasma/accessdenied/qmldir");