- const KService::List pluginServices = KServiceTypeTrader::self()->query("KFileItemAction/Plugin");
- foreach (const KSharedPtr<KService>& service, pluginServices) {
- const QString serviceName = service->desktopEntryName();
- if (!isInServicesList(serviceName)) {
- QListWidgetItem* item = new QListWidgetItem(KIcon(service->icon()),
- service->name(),
- m_servicesList);
- item->setData(Qt::UserRole, serviceName);
- const bool show = showGroup.readEntry(serviceName, true);
- item->setCheckState(show ? Qt::Checked : Qt::Unchecked);
+ const KService::List pluginServices = KServiceTypeTrader::self()->query(QStringLiteral("KFileItemAction/Plugin"));
+ foreach (const KService::Ptr& service, pluginServices) {
+ const QString desktopEntryName = service->desktopEntryName();
+ if (!isInServicesList(desktopEntryName)) {
+ const bool checked = showGroup.readEntry(desktopEntryName, true);
+ addRow(service->icon(), service->name(), desktopEntryName, checked);
+ }
+ }
+
+ // Load JSON-based plugins that implement the KFileItemActionPlugin interface
+ const auto jsonPlugins = KPluginLoader::findPlugins(QStringLiteral("kf5/kfileitemaction"), [](const KPluginMetaData& metaData) {
+ return metaData.serviceTypes().contains(QStringLiteral("KFileItemAction/Plugin"));
+ });
+
+ foreach (const auto& jsonMetadata, jsonPlugins) {
+ const QString desktopEntryName = jsonMetadata.pluginId();
+ if (!isInServicesList(desktopEntryName)) {
+ const bool checked = showGroup.readEntry(desktopEntryName, true);
+ addRow(jsonMetadata.iconName(), jsonMetadata.name(), desktopEntryName, checked);