Commit 5f484d8e authored by Elvis Angelaccio's avatar Elvis Angelaccio

Drop another obsolete version check

We now require Frameworks >= 5.30
parent d0eae28f
......@@ -34,7 +34,6 @@
#include <KIO/EmptyTrashJob>
#include <KIO/JobUiDelegate>
#include <KIO/Paste>
#include <kio_version.h>
#include <KJobWidgets>
#include <KMimeTypeTrader>
#include <KNewFileMenu>
......@@ -487,76 +486,7 @@ void DolphinContextMenu::addServiceActions(KFileItemActions& fileItemActions)
void DolphinContextMenu::addFileItemPluginActions(KFileItemActions& fileItemActions)
{
#if KIO_VERSION >= QT_VERSION_CHECK(5, 27, 0)
fileItemActions.addPluginActionsTo(this);
#else
Q_UNUSED(fileItemActions);
KFileItemListProperties props;
if (m_selectedItems.isEmpty()) {
props.setItems(KFileItemList() << baseFileItem());
} else {
props = selectedItemsProperties();
}
QString commonMimeType = props.mimeType();
if (commonMimeType.isEmpty()) {
commonMimeType = QStringLiteral("application/octet-stream");
}
const KService::List pluginServices = KMimeTypeTrader::self()->query(commonMimeType, QStringLiteral("KFileItemAction/Plugin"), QStringLiteral("exist Library"));
const KConfig config(QStringLiteral("kservicemenurc"), KConfig::NoGlobals);
const KConfigGroup showGroup = config.group("Show");
QSet<QString> addedPlugins;
foreach (const KService::Ptr& service, pluginServices) {
if (!showGroup.readEntry(service->desktopEntryName(), true)) {
// The plugin has been disabled
continue;
}
KAbstractFileItemActionPlugin* abstractPlugin = service->createInstance<KAbstractFileItemActionPlugin>();
if (abstractPlugin) {
abstractPlugin->setParent(this);
addActions(abstractPlugin->actions(props, m_mainWindow));
addedPlugins << service->desktopEntryName();
}
}
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) {
// The plugin has been disabled
if (!showGroup.readEntry(jsonMetadata.pluginId(), true)) {
continue;
}
// The plugin also has a .desktop file and has already been added.
if (addedPlugins.contains(jsonMetadata.pluginId())) {
continue;
}
KPluginFactory *factory = KPluginLoader(jsonMetadata.fileName()).factory();
KAbstractFileItemActionPlugin* abstractPlugin = factory->create<KAbstractFileItemActionPlugin>();
if (abstractPlugin) {
abstractPlugin->setParent(this);
addActions(abstractPlugin->actions(props, m_mainWindow));
addedPlugins << jsonMetadata.pluginId();
}
}
#endif
}
void DolphinContextMenu::addVersionControlPluginActions()
......
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