From b01b03aa84dc62e48b04657bb90476228c0fd8f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 7 Jul 2015 08:48:24 +0200 Subject: [PATCH] [scripting] Find scripts through KPackage Another sycoca usage gone. --- scripting/scripting.cpp | 29 ++++++++++++++--------------- scripting/scripting.h | 1 - tabbox/autotests/CMakeLists.txt | 2 -- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/scripting/scripting.cpp b/scripting/scripting.cpp index 1be2c908ca..a32ba49378 100644 --- a/scripting/scripting.cpp +++ b/scripting/scripting.cpp @@ -33,8 +33,7 @@ along with this program. If not, see . #include "../workspace.h" // KDE #include -#include -#include +#include // Qt #include #include @@ -661,30 +660,30 @@ LoadScriptList KWin::Scripting::queryScriptsToLoad() s_started = true; } QMap pluginStates = KConfigGroup(_config, "Plugins").entryMap(); - KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("KWin/Script")); + const QString scriptFolder = QStringLiteral(KWIN_NAME) + QStringLiteral("/scripts/"); + const auto offers = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), scriptFolder); LoadScriptList scriptsToLoad; - foreach (const KService::Ptr & service, offers) { - KPluginInfo plugininfo(service); - const QString value = pluginStates.value(plugininfo.pluginName() + QString::fromLatin1("Enabled"), QString()); - plugininfo.setPluginEnabled(value.isNull() ? plugininfo.isPluginEnabledByDefault() : QVariant(value).toBool()); - const bool javaScript = service->property(QStringLiteral("X-Plasma-API")).toString() == QStringLiteral("javascript"); - const bool declarativeScript = service->property(QStringLiteral("X-Plasma-API")).toString() == QStringLiteral("declarativescript"); + for (const KPluginMetaData &service: offers) { + const QString value = pluginStates.value(service.pluginId() + QString::fromLatin1("Enabled"), QString()); + const bool enabled = value.isNull() ? service.isEnabledByDefault() : QVariant(value).toBool(); + const bool javaScript = service.value(QStringLiteral("X-Plasma-API")) == QStringLiteral("javascript"); + const bool declarativeScript = service.value(QStringLiteral("X-Plasma-API")) == QStringLiteral("declarativescript"); if (!javaScript && !declarativeScript) { continue; } - if (!plugininfo.isPluginEnabled()) { - if (isScriptLoaded(plugininfo.pluginName())) { + if (!enabled) { + if (isScriptLoaded(service.pluginId())) { // unload the script - unloadScript(plugininfo.pluginName()); + unloadScript(service.pluginId()); } continue; } - const QString pluginName = service->property(QStringLiteral("X-KDE-PluginInfo-Name")).toString(); - const QString scriptName = service->property(QStringLiteral("X-Plasma-MainScript")).toString(); - const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(KWIN_NAME) + QStringLiteral("/scripts/") + pluginName + QStringLiteral("/contents/") + scriptName); + const QString pluginName = service.pluginId(); + const QString scriptName = service.value(QStringLiteral("X-Plasma-MainScript")); + const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, scriptFolder + pluginName + QStringLiteral("/contents/") + scriptName); if (file.isNull()) { qDebug() << "Could not find script file for " << pluginName; continue; diff --git a/scripting/scripting.h b/scripting/scripting.h index 6873332635..fdc3ebe795 100644 --- a/scripting/scripting.h +++ b/scripting/scripting.h @@ -23,7 +23,6 @@ along with this program. If not, see . #define KWIN_SCRIPTING_H #include -#include #include #include diff --git a/tabbox/autotests/CMakeLists.txt b/tabbox/autotests/CMakeLists.txt index 8d6d14c908..071ba04f53 100644 --- a/tabbox/autotests/CMakeLists.txt +++ b/tabbox/autotests/CMakeLists.txt @@ -22,7 +22,6 @@ target_link_libraries( testTabBoxClientModel Qt5::X11Extras KF5::I18n KF5::Package - KF5::Service KF5::WindowSystem XCB::XCB ) @@ -51,7 +50,6 @@ target_link_libraries( testTabBoxHandler Qt5::X11Extras KF5::I18n KF5::Package - KF5::Service KF5::WindowSystem XCB::XCB )