From 06469f66a831342caf7504469339f872287ef324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 7 Jul 2015 09:49:15 +0200 Subject: [PATCH] [aurorae] Port loading of QML decos to KPackage Another sycoca usage gone. --- clients/aurorae/src/CMakeLists.txt | 2 +- clients/aurorae/src/aurorae.cpp | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/clients/aurorae/src/CMakeLists.txt b/clients/aurorae/src/CMakeLists.txt index f4d85fa12e..0435a1d451 100644 --- a/clients/aurorae/src/CMakeLists.txt +++ b/clients/aurorae/src/CMakeLists.txt @@ -18,7 +18,7 @@ target_link_libraries(kwin5_aurorae KDecoration2::KDecoration KF5::ConfigWidgets KF5::I18n - KF5::Service + KF5::Package KF5::WindowSystem Qt5::Quick Qt5::UiTools diff --git a/clients/aurorae/src/aurorae.cpp b/clients/aurorae/src/aurorae.cpp index 4ce2ee8bfc..0f3ace6a2a 100644 --- a/clients/aurorae/src/aurorae.cpp +++ b/clients/aurorae/src/aurorae.cpp @@ -33,8 +33,7 @@ along with this program. If not, see . #include #include #include -#include -#include +#include // Qt #include #include @@ -116,6 +115,7 @@ void Helper::unref() } static const QString s_defaultTheme = QStringLiteral("kwin4_decoration_qml_plastik"); +static const QString s_qmlPackageFolder = QStringLiteral(KWIN_NAME) + QStringLiteral("/decorations/"); /* * KDecoration2::BorderSize doesn't map to the indices used for the Aurorae SVG Button Sizes. * BorderSize defines None and NoSideBorder as index 0 and 1. These do not make sense for Button @@ -166,17 +166,20 @@ QQmlComponent *Helper::loadComponent(const QString &themeName) qCDebug(AURORAE) << "Trying to load QML Decoration " << themeName; const QString internalname = themeName.toLower(); - QString constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(internalname); - KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("KWin/Decoration"), constraint); + const auto offers = KPackage::PackageLoader::self()->findPackages(QStringLiteral("KWin/Decoration"), s_qmlPackageFolder, + [internalname] (const KPluginMetaData &data) { + return data.pluginId().compare(internalname, Qt::CaseInsensitive) == 0; + } + ); if (offers.isEmpty()) { qCCritical(AURORAE) << "Couldn't find QML Decoration " << themeName << endl; // TODO: what to do in error case? return nullptr; } - KService::Ptr service = offers.first(); - 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("/decorations/") + pluginName + QStringLiteral("/contents/") + scriptName); + const KPluginMetaData &service = offers.first(); + const QString pluginName = service.pluginId(); + const QString scriptName = service.value(QStringLiteral("X-Plasma-MainScript")); + const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, s_qmlPackageFolder + pluginName + QStringLiteral("/contents/") + scriptName); if (file.isNull()) { qCDebug(AURORAE) << "Could not find script file for " << pluginName; // TODO: what to do in error case? @@ -623,9 +626,9 @@ void ThemeFinder::init() void ThemeFinder::findAllQmlThemes() { - const KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("KWin/Decoration")); + const auto offers = KPackage::PackageLoader::self()->findPackages(QStringLiteral("KWin/Decoration"), s_qmlPackageFolder); for (const auto &offer : offers) { - m_themes.insert(offer->name(), offer->property(QStringLiteral("X-KDE-PluginInfo-Name")).toString()); + m_themes.insert(offer.name(), offer.pluginId()); } }