From 01a74949fa1d5b0624f8a57bd078a55e678ea213 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Wed, 20 Oct 2021 17:50:27 +0200 Subject: [PATCH] Fix context menu actions for KCMs Needs https://invent.kde.org/plasma/systemsettings/commit/c815c7a9bc658b7d4778c3fc4ebfff9756ebb199 Currently the logic is very fragile and depends on the data being an url. However the data of the match is an implementation detail and is in case of the KCM matches a KPluginMetaData instance. To avoid this issue the first url of the QueryMatch::urls() return value is checked. This data is intended for mime-type/scheme related operations. In the future we need an extra url for systemsettings & should consistently use the urls of the query match. I will work on this before continuing to port the plasma KCMs from KServiceTypeTrader. BUG: 442522 --- applets/kicker/plugin/runnermatchesmodel.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/applets/kicker/plugin/runnermatchesmodel.cpp b/applets/kicker/plugin/runnermatchesmodel.cpp index 8bcd91d7d..fccd1f936 100644 --- a/applets/kicker/plugin/runnermatchesmodel.cpp +++ b/applets/kicker/plugin/runnermatchesmodel.cpp @@ -86,7 +86,11 @@ QVariant RunnerMatchesModel::data(const QModelIndex &index, int role) const return actionList; } - const QUrl dataUrl(match.data().toUrl()); + QUrl dataUrl(match.data().toUrl()); + if (dataUrl.isEmpty() && !match.urls().isEmpty()) { + // needed for systemsettigs runner + dataUrl = match.urls().constFirst(); + } if (dataUrl.scheme() != QLatin1String("applications")) { return actionList; } @@ -162,7 +166,11 @@ bool RunnerMatchesModel::trigger(int row, const QString &actionId, const QVarian QObject *appletInterface = static_cast(parent())->appletInterface(); - const KService::Ptr service = KService::serviceByStorageId(match.data().toUrl().toString(QUrl::RemoveScheme)); + KService::Ptr service = KService::serviceByStorageId(match.data().toUrl().toString(QUrl::RemoveScheme)); + if (!service && !match.urls().isEmpty()) { + // needed for systemsettigs runner + service = KService::serviceByStorageId(match.urls().constFirst().toString(QUrl::RemoveScheme)); + } if (Kicker::handleAddLauncherAction(actionId, appletInterface, service)) { return false; // We don't want to close Kicker, BUG: 390585