Commit 809ba746 authored by Elvis Angelaccio's avatar Elvis Angelaccio

Filter json-only KFileItemAction plugins by mimetype

Commit d48b7334 introduced support for kfileitemaction plugins with json
metadata, but forgot to filter them by the commonMimeType (like
KMimeTypeTrader::query() does with old-style plugins).

So we need to load a plugin only when commonMimeType is equal to (or child of) one
of the mimetypes supported by the plugin.
parent 438ede27
......@@ -48,6 +48,7 @@
#include <QKeyEvent>
#include <QMenuBar>
#include <QMenu>
#include <QMimeDatabase>
#include <panels/places/placesitem.h>
#include <panels/places/placesitemmodel.h>
......@@ -519,8 +520,19 @@ void DolphinContextMenu::addFileItemPluginActions()
}
}
const auto jsonPlugins = KPluginLoader::findPlugins(QStringLiteral("kf5/kfileitemaction"), [](const KPluginMetaData& metaData) {
return metaData.serviceTypes().contains(QStringLiteral("KFileItemAction/Plugin"));
const auto jsonPlugins = KPluginLoader::findPlugins(QStringLiteral("kf5/kfileitemaction"), [=](const KPluginMetaData& metaData) {
if (!metaData.serviceTypes().contains(QStringLiteral("KFileItemAction/Plugin"))) {
return false;
}
auto mimeType = QMimeDatabase().mimeTypeForName(commonMimeType);
foreach (const auto& supportedMimeType, metaData.mimeTypes()) {
if (mimeType.inherits(supportedMimeType)) {
return true;
}
}
return false;
});
foreach (const auto& jsonMetadata, jsonPlugins) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment