Commit dcf0163a authored by Stefano Crocco's avatar Stefano Crocco
Browse files

Port away from KMimeTypeTrader

This means that KService::Ptr for parts should be replaced by
KPluginMetaData.

There are some problems, however:
- KonqMainWindow::updateViewModeActions uses KService::actions. As far
  as I can tell,there isn't a replacement for it
- the documentation for KPluginMetaData::serviceTypes states that "This
  is mostly for historical / compatibility purposes" and suggests to put
  all plugins of the same type in the appropriate directory. However,
  this is out of our control, as the plugins come from other
  applications. What's the best way to approach this problem?
parent c13bd7db
......@@ -34,15 +34,15 @@ private Q_SLOTS:
QSignalSpy spyCompleted(view, SIGNAL(viewCompleted(KonqView*)));
QVERIFY(spyCompleted.wait(10000));
QCOMPARE(view->serviceType(), QString("text/plain"));
const QString firstService = view->service()->entryPath();
const QString firstService = view->service().pluginId();
qDebug() << firstService;
QVERIFY(view->supportsMimeType("text/html")); // it does, since that's a mimetype subclass
// Now open HTML, as if we typed a URL in the location bar.
KonqOpenURLRequest req2; req2.typedUrl = QStringLiteral("http://www.kde.org");
mainWindow.openUrl(nullptr, QUrl(QStringLiteral("data:text/html, <p>Hello World</p>")), QStringLiteral("text/html"), req2);
qDebug() << view->service()->entryPath();
QVERIFY(view->service()->entryPath() != firstService);
qDebug() << view->service().pluginId();
QVERIFY(view->service().pluginId() != firstService);
}
};
......
......@@ -9,13 +9,13 @@
#include <QStandardPaths>
// KDE
#include <kcolorbutton.h>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kurlrequester.h>
#include <kmimetypetrader.h>
#include <kparts/part.h>
#include <kparts/openurlarguments.h>
#include <KColorButton>
#include <KConfig>
#include <KConfigGroup>
#include <KUrlRequester>
#include <KParts/Part>
#include <KParts/OpenUrlArguments>
#include <KParts/PartLoader>
// Local
#include "template.h"
......@@ -309,7 +309,7 @@ CSSCustomDialog::CSSCustomDialog(QWidget *parent)
//QStringList fonts;
//KFontChooser::getFontList(fonts, 0);
//fontFamily->addItems(fonts);
part = KMimeTypeTrader::createPartInstanceFromQuery<KParts::ReadOnlyPart>(QStringLiteral("text/html"), parent, this);
part = KParts::PartLoader::createPartInstanceForMimeType<KParts::ReadOnlyPart>(QStringLiteral("text/html"));
QVBoxLayout *l = new QVBoxLayout(previewBox);
l->addWidget(part->widget());
}
......
......@@ -23,11 +23,12 @@
// KDE
#include <kbuildsycocaprogressdialog.h>
#include <kmimetypetrader.h>
#include <kservice.h>
// #include <kmimetypetrader.h>
// #include <kservice.h>
#include <KConfigGroup>
#include <KSharedConfig>
#include <KMessageWidget>
#include <KParts/PartLoader>
// Local
#include "ui_advancedTabOptions.h"
......@@ -212,15 +213,20 @@ void KKonqGeneralOptions::load()
m_webEngineCombo->clear();
// ## Well, the problem with using the trader to find the available parts, is that if a user
// removed a part in keditfiletype text/html, it won't be in the list anymore. Oh well.
const KService::List partOfferList = KMimeTypeTrader::self()->query(QStringLiteral("text/html"), QStringLiteral("KParts/ReadOnlyPart"), QStringLiteral("not ('KParts/ReadWritePart' in ServiceTypes)"));
// Sorted list, so the first one is the preferred one, no need for a setCurrentIndex.
Q_FOREACH (const KService::Ptr partService, partOfferList) {
// We want only the HTML-capable parts, not any text/plain part (via inheritance)
// This is a small "private inheritance" hack, pending a more general solution
if (!partService->hasMimeType(QStringLiteral("text/plain"))) {
m_webEngineCombo->addItem(QIcon::fromTheme(partService->icon()), partService->name(),
QVariant(partService->storageId()));
}
QVector<KPluginMetaData> allParts = KParts::PartLoader::partsForMimeType(QStringLiteral("text/html"));
QVector<KPluginMetaData> partOfferList;
auto filter = [](const KPluginMetaData &md){
return !md.serviceTypes().contains(QStringLiteral("KParts/ReadWritePart")) && !md.mimeTypes().contains(QStringLiteral("text/plain"));
};
std::copy_if(allParts.constBegin(), allParts.constEnd(), std::back_inserter(partOfferList), filter);
//Remove duplicate entries
//TODO port away from query: are the following 3 lines really needed? Is it correct that the vector returned by partsForMimeType contains the same part several times?
std::sort(partOfferList.begin(), partOfferList.end(), [](const KPluginMetaData &md1, const KPluginMetaData &md2){return md1.pluginId() == md2.pluginId();});
auto unique = std::unique(partOfferList.begin(), partOfferList.end(), [](const KPluginMetaData &md1, const KPluginMetaData &md2){return md1.pluginId() == md2.pluginId();});
partOfferList.erase(unique, partOfferList.end());
for (const KPluginMetaData &md : partOfferList) {
m_webEngineCombo->addItem(QIcon::fromTheme(md.iconName()), md.name(), md.pluginId());
}
KConfigGroup cg(m_pConfig, "FMSettings"); // ### what a wrong group name for these settings...
......
......@@ -85,6 +85,7 @@ set(konqueror_KDEINIT_SRCS
konqbrowserinterface.cpp
urlloader.cpp
konqsettings.cpp
pluginmetadatautils.cpp
)
kconfig_add_kcfg_files(konqueror_KDEINIT_SRCS konqsettingsxt.kcfgc)
......
......@@ -66,7 +66,7 @@ KonqExtensionManager::KonqExtensionManager(QWidget *parent, KonqMainWindow *main
d->activePart = activePart;
auto addPluginForId = [this](const QString &pluginId) {
QVector<KPluginMetaData> metaDataList = KPluginMetaData::findPlugins(pluginId + QStringLiteral("/kpartplugins"));
PluginMetaDataVector metaDataList = KPluginMetaData::findPlugins(pluginId + QStringLiteral("/kpartplugins"));
d->pluginSelector->addPlugins(metaDataList, i18n("Extensions"));
};
if (activePart) {
......
......@@ -6,9 +6,11 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
// Own
#include "konqfactory.h"
#include <konq_kpart_plugin.h>
#include "konqdebug.h"
#include "konqsettings.h"
#include "konqmainwindow.h"
// std
#include <assert.h>
......@@ -19,21 +21,15 @@
#include <QCoreApplication>
// KDE
#include "konqdebug.h"
#include <KLocalizedString>
#include <KParts/ReadOnlyPart>
#include <KPluginInfo>
#include <kmessagebox.h>
#include <kmimetypetrader.h>
#include <kservicetypetrader.h>
// Local
#include "konqsettings.h"
#include "konqmainwindow.h"
#include <KMessageBox>
#include <KApplicationTrader>
#include <KParts/PartLoader>
KonqViewFactory::KonqViewFactory(const QString &libName, KPluginFactory *factory)
: m_libName(libName), m_factory(factory),
m_args()
KonqViewFactory::KonqViewFactory(const KPluginMetaData &data, KPluginFactory *factory)
: m_metaData(data), m_factory(factory), m_args()
{
}
......@@ -48,10 +44,10 @@ KParts::ReadOnlyPart *KonqViewFactory::create(QWidget *parentWidget, QObject *pa
return nullptr;
}
KParts::ReadOnlyPart *part = m_factory->create<KParts::ReadOnlyPart>(parentWidget, parent, QString(), m_args);
KParts::ReadOnlyPart *part = m_factory->create<KParts::ReadOnlyPart>(parentWidget, parent, m_args);
if (!part) {
qCWarning(KONQUEROR_LOG) << "No KParts::ReadOnlyPart created from" << m_libName;
qCWarning(KONQUEROR_LOG) << "No KParts::ReadOnlyPart created from" << m_metaData.name();
} else {
KonqParts::Plugin::loadPlugins(part, part, part->componentName());
QFrame *frame = qobject_cast<QFrame *>(part->widget());
......@@ -62,31 +58,34 @@ KParts::ReadOnlyPart *KonqViewFactory::create(QWidget *parentWidget, QObject *pa
return part;
}
static KonqViewFactory tryLoadingService(KService::Ptr service)
static KonqViewFactory tryLoadingService(const KPluginMetaData &data)
{
if (auto factoryResult = KPluginFactory::loadFactory(KPluginInfo(service).toMetaData())) {
return KonqViewFactory(service->library(), factoryResult.plugin);
if (auto factoryResult = KPluginFactory::loadFactory(data)) {
return KonqViewFactory(data, factoryResult.plugin);
} else {
KMessageBox::error(nullptr,
i18n("There was an error loading the module %1.\nThe diagnostics is:\n%2",
service->name(), factoryResult.errorString));
data.name(), factoryResult.errorString));
return KonqViewFactory();
}
}
//TODO port away from query: check whether this output type arguments can be replaced by something else
KonqViewFactory KonqFactory::createView(const QString &serviceType,
const QString &serviceName,
KService::Ptr *serviceImpl,
KService::List *partServiceOffers,
KPluginMetaData *serviceImpl,
PluginMetaDataVector *partServiceOffers,
KService::List *appServiceOffers,
bool forceAutoEmbed)
{
//TODO port away from query: check whether service name can be empty
qCDebug(KONQUEROR_LOG) << "Trying to create view for" << serviceType << serviceName;
// We need to get those in any case
KService::List offers, appOffers;
PluginMetaDataVector offers;
KService::List appOffers;
// Query the trader
// Query the plugins
getOffers(serviceType, &offers, &appOffers);
if (partServiceOffers) {
......@@ -113,37 +112,35 @@ KonqViewFactory KonqFactory::createView(const QString &serviceType,
}
}
KService::Ptr service;
KPluginMetaData service;
// Look for this service
if (!serviceName.isEmpty()) {
auto it = std::find_if(offers.constBegin(), offers.constEnd(), [serviceName](KService::Ptr s){return s->desktopEntryName() == serviceName;});
qCDebug(KONQUEROR_LOG) << "Found requested service" << serviceName;
service = *it;
auto it = std::find_if(offers.constBegin(), offers.constEnd(), [serviceName](const KPluginMetaData &md){return md.pluginId() == serviceName;});
if (it != offers.constEnd()) {
service = *it;
}
}
KonqViewFactory viewFactory;
if (service) {
qCDebug(KONQUEROR_LOG) << "Trying to open lib for requested service " << service->desktopEntryName();
if (service.isValid()) {
qCDebug(KONQUEROR_LOG) << "Trying to open lib for requested service " << service.name();
viewFactory = tryLoadingService(service);
// If this fails, then return an error.
// When looking for konq_sidebartng or konq_aboutpage, we don't want to end up
// with khtml or another Browser/View part in case of an error...
} else {
for (KService::Ptr offer : offers) {
for (const KPluginMetaData &md : offers) {
// Allowed as default ?
QVariant prop = offer ->property(QStringLiteral("X-KDE-BrowserView-AllowAsDefault"));
qCDebug(KONQUEROR_LOG) << offer ->desktopEntryName() << " : X-KDE-BrowserView-AllowAsDefault is valid : " << prop.isValid();
if (!prop.isValid() || prop.toBool()) { // defaults to true
//qCDebug(KONQUEROR_LOG) << "Trying to open lib for service " << service->name();
viewFactory = tryLoadingService(offer);
if (!md.value(QStringLiteral("X-KDE-BrowserView-AllowAsDefault"), true)) {
viewFactory = tryLoadingService(md);
if (!viewFactory.isNull()) {
service = offer;
service = md;
break;
}
} else {
qCDebug(KONQUEROR_LOG) << "Not allowed as default " << service->desktopEntryName();
qCDebug(KONQUEROR_LOG) << "Not allowed as default " << service.name();
}
}
}
......@@ -162,14 +159,11 @@ KonqViewFactory KonqFactory::createView(const QString &serviceType,
}
QVariantList args;
const QVariant prop = service->property(QStringLiteral("X-KDE-BrowserView-Args"));
if (prop.isValid()) {
Q_FOREACH (const QString &str, prop.toString().split(' ')) {
args << QVariant(str);
}
for (const QString &str : service.value(QStringLiteral("X-KDE-BrowserView-Args"), QStringList())) {
args << QVariant(str);
}
if (service->serviceTypes().contains(QStringLiteral("Browser/View"))) {
if (service.serviceTypes().contains(QStringLiteral("Browser/View"))) {
args << QLatin1String("Browser/View");
}
......@@ -177,25 +171,22 @@ KonqViewFactory KonqFactory::createView(const QString &serviceType,
return viewFactory;
}
void KonqFactory::getOffers(const QString &serviceType,
KService::List *partServiceOffers,
KService::List *appServiceOffers)
void KonqFactory::getOffers(const QString &serviceType, PluginMetaDataVector *partServiceOffers, KService::List *appServiceOffers)
{
#ifdef __GNUC__
#warning Temporary hack -- must separate mimetypes and servicetypes better
#endif
if (partServiceOffers && serviceType.length() > 0 && serviceType[0].isUpper()) {
*partServiceOffers = KServiceTypeTrader::self()->query(serviceType,
QStringLiteral("DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'"));
//TODO port away from query: check whether it's still necessary to exclude kfmclient* from this vector (they aren't parts, so I think they shouldn't be included here)
qDebug() << KPluginMetaData::findPlugins(QString(), [serviceType](const KPluginMetaData &md){return md.serviceTypes().contains(serviceType);});
*partServiceOffers = KPluginMetaData::findPlugins(QString(), [serviceType](const KPluginMetaData &md){return md.serviceTypes().contains(serviceType);});
return;
}
if (appServiceOffers) {
*appServiceOffers = KMimeTypeTrader::self()->query(serviceType, QStringLiteral("Application"),
QStringLiteral("DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'"));
}
if (partServiceOffers) {
*partServiceOffers = KMimeTypeTrader::self()->query(serviceType, QStringLiteral("KParts/ReadOnlyPart"));
*partServiceOffers = KParts::PartLoader::partsForMimeType(serviceType);
}
if (appServiceOffers) {
*appServiceOffers = KApplicationTrader::queryByMimeType(serviceType, [](const KService::Ptr &s){return !s->desktopEntryName().startsWith("kfmclient");});
}
}
......@@ -10,8 +10,10 @@
#define __konq_factory_h__
#include "konqprivate_export.h"
#include "pluginmetadatautils.h"
#include <kservice.h>
#include <KService>
#include <KPluginMetaData>
class KPluginFactory;
namespace KParts
......@@ -27,7 +29,7 @@ public:
*/
KonqViewFactory() : m_factory(nullptr), m_args() {}
KonqViewFactory(const QString &libName, KPluginFactory *factory);
KonqViewFactory(const KPluginMetaData &data, KPluginFactory *factory);
// The default copy ctor and operator= can be used, this is a value class.
......@@ -41,7 +43,7 @@ public:
}
private:
QString m_libName;
KPluginMetaData m_metaData;
KPluginFactory *m_factory;
QVariantList m_args;
};
......@@ -64,14 +66,12 @@ public:
*/
KonqViewFactory createView(const QString &serviceType,
const QString &serviceName = QString(),
KService::Ptr *serviceImpl = nullptr,
KService::List *partServiceOffers = nullptr,
KPluginMetaData *serviceImpl = nullptr,
PluginMetaDataVector *partServiceOffers = nullptr,
KService::List *appServiceOffers = nullptr,
bool forceAutoEmbed = false);
static void getOffers(const QString &serviceType,
KService::List *partServiceOffers = nullptr,
KService::List *appServiceOffers = nullptr);
static void getOffers(const QString& serviceType, PluginMetaDataVector *partServiceOffers = nullptr, KService::List* appServiceOffers = nullptr);
};
#endif
......@@ -23,7 +23,7 @@
#include "konqframestatusbar.h"
#include "konqviewmanager.h"
PopupMenuGUIClient::PopupMenuGUIClient(const KService::List &embeddingServices,
PopupMenuGUIClient::PopupMenuGUIClient(const PluginMetaDataVector &embeddingServices,
KonqPopupMenu::ActionGroupMap &actionGroups,
QAction *showMenuBar, QAction *stopFullScreen)
: m_actionCollection(this),
......@@ -47,15 +47,15 @@ PopupMenuGUIClient::PopupMenuGUIClient(const KService::List &embeddingServices,
if (!embeddingServices.isEmpty()) {
QList<QAction *> previewActions;
if (embeddingServices.count() == 1) {
KService::Ptr service = embeddingServices.first();
QAction *act = addEmbeddingService(0, i18n("Preview &in %1", service->name()), service);
KPluginMetaData service = embeddingServices.first();
QAction *act = addEmbeddingService(0, i18n("Preview &in %1", service.name()), service);
previewActions.append(act);
} else if (embeddingServices.count() > 1) {
KService::List::ConstIterator it = embeddingServices.begin();
const KService::List::ConstIterator end = embeddingServices.end();
PluginMetaDataVector::ConstIterator it = embeddingServices.begin();
const PluginMetaDataVector::ConstIterator end = embeddingServices.end();
int idx = 0;
for (; it != end; ++it, ++idx) {
QAction *act = addEmbeddingService(idx, (*it)->name(), *it);
QAction *act = addEmbeddingService(idx, (*it).name(), *it);
previewActions.append(act);
}
}
......@@ -68,11 +68,11 @@ PopupMenuGUIClient::~PopupMenuGUIClient()
{
}
QAction *PopupMenuGUIClient::addEmbeddingService(int idx, const QString &name, const KService::Ptr &service)
QAction *PopupMenuGUIClient::addEmbeddingService(int idx, const QString &name, const KPluginMetaData &service)
{
QAction *act = m_actionCollection.addAction(QByteArray::number(idx));
act->setText(name);
act->setIcon(QIcon::fromTheme(service->icon()));
act->setIcon(QIcon::fromTheme(service.iconName()));
QObject::connect(act, &QAction::triggered, this, &PopupMenuGUIClient::slotOpenEmbedded);
return act;
}
......@@ -211,7 +211,7 @@ void ToggleViewGUIClient::slotToggleView(bool toggle)
} else {
const QList<KonqView *> viewList = KonqViewCollector::collect(m_mainWindow);
foreach (KonqView *view, viewList) {
if (view->service() && view->service()->desktopEntryName() == serviceName)
if (view->service().pluginId() == serviceName)
// takes care of choosing the new active view, and also calls slotViewRemoved
{
viewManager->removeView(view);
......@@ -240,7 +240,7 @@ void ToggleViewGUIClient::saveConfig(bool add, const QString &serviceName)
void ToggleViewGUIClient::slotViewAdded(KonqView *view)
{
QString name = view->service()->desktopEntryName();
QString name = view->service().pluginId();
QAction *action = m_actions.value(name);
......@@ -272,7 +272,7 @@ void ToggleViewGUIClient::slotViewAdded(KonqView *view)
void ToggleViewGUIClient::slotViewRemoved(KonqView *view)
{
QString name = view->service()->desktopEntryName();
QString name = view->service().pluginId();
QAction *action = m_actions.value(name);
......
......@@ -7,14 +7,16 @@
#ifndef __konq_guiclients_h__
#define __konq_guiclients_h__
#include <kactioncollection.h>
#include <konq_popupmenu.h>
#include "pluginmetadatautils.h"
#include "konq_popupmenu.h"
#include <KActionCollection>
#include <KXMLGUIClient>
#include <KPluginMetaData>
#include <QObject>
#include <QHash>
#include <kxmlguiclient.h>
#include <kservice.h>
class QAction;
class KonqMainWindow;
class KonqView;
......@@ -28,7 +30,7 @@ class PopupMenuGUIClient : public QObject
Q_OBJECT
public:
// The action groups are inserted into @p actionGroups
PopupMenuGUIClient(const KService::List &embeddingServices,
PopupMenuGUIClient(const PluginMetaDataVector &embeddingServices,
KonqPopupMenu::ActionGroupMap &actionGroups,
QAction *showMenuBar, QAction *stopFullScreen);
~PopupMenuGUIClient() override;
......@@ -39,16 +41,16 @@ public:
}
signals:
void openEmbedded(KService::Ptr service);
void openEmbedded(const KPluginMetaData &part);
private slots:
void slotOpenEmbedded();
private:
QAction *addEmbeddingService(int idx, const QString &name, const KService::Ptr &service);
QAction *addEmbeddingService(int idx, const QString &name, const KPluginMetaData &service);
KActionCollection m_actionCollection;
KService::List m_embeddingServices;
PluginMetaDataVector m_embeddingServices;
};
class ToggleViewGUIClient : public QObject
......
......@@ -145,6 +145,8 @@
#include <KSharedConfig>
#include <KProtocolManager>
#include <KParts/PartLoader>
#include <KApplicationTrader>
#include <QMetaObject>
#include <QMetaMethod>
......@@ -673,7 +675,7 @@ KonqView * KonqMainWindow::createTabForLoadUrlRequest(const QUrl& url, const Kon
static QString preferredService(KonqView *currentView, const QString &mimeType)
{
if (currentView && !mimeType.isEmpty() && currentView->supportsMimeType(mimeType)) {
return currentView->service()->desktopEntryName();
return currentView->service().pluginId();
}
return QString();
}
......@@ -768,7 +770,7 @@ bool KonqMainWindow::openView(QString mimeType, const QUrl &_url, KonqView *chil
}
// Do we even have a part to embed? Otherwise don't ask, since we'd ask twice.
if (!forceAutoEmbed) {
KService::List partServiceOffers;
PluginMetaDataVector partServiceOffers;
KonqFactory::getOffers(mimeType, &partServiceOffers);
if (partServiceOffers.isEmpty()) {
qCDebug(KONQUEROR_LOG) << "No part available for" << mimeType;
......@@ -1500,13 +1502,14 @@ void KonqMainWindow::slotViewModeTriggered(QAction *action)
return;
}
//TODO port away from query: check that plugin id actually respect these rules
// Gather data from the action, since the action will be deleted by changePart
QString modeName = action->objectName();
Q_ASSERT(modeName.endsWith("-viewmode"));
modeName.chop(9);
const QString internalViewMode = action->data().toString();
if (m_currentView->service()->desktopEntryName() != modeName) {
if (m_currentView->service().pluginId() != modeName) {
m_currentView->stop();
m_currentView->lockHistory();
......@@ -4369,20 +4372,16 @@ void KonqMainWindow::slotPopupMenu(const QPoint &global, const KFileItemList &it
!isIntoTrash && !devicesFile &&
(itemFlags & KParts::BrowserExtension::ShowTextSelectionItems) == 0;
KService::List embeddingServices;
PluginMetaDataVector embeddingServices;
if (showEmbeddingServices) {
const QString currentServiceName = currentView->service()->desktopEntryName();
const QString currentServiceName = currentView->service().pluginId();
// List of services for the "Preview In" submenu.
embeddingServices = KMimeTypeTrader::self()->query(
m_popupMimeType,
QStringLiteral("KParts/ReadOnlyPart"),
// Obey "HideFromMenus". It defaults to false so we want "absent or true"
// (wow, testing for 'true' if absent doesn't work, so order matters)
"(not exist [X-KDE-BrowserView-HideFromMenus] or not [X-KDE-BrowserView-HideFromMenus]) "
"and DesktopEntryName != '" +currentServiceName + "' "
// I had an old local dirtree.desktop without lib, no need for invalid entries
"and exist [Library]");
PluginMetaDataVector allEmbeddingServices = KParts::PartLoader::partsForMimeType(m_popupMimeType);
auto filter = [currentServiceName](const KPluginMetaData &md) {
return md.value(QLatin1String("X-KDE-BrowserView-HideFromMenus"),false) && md.pluginId() != currentServiceName;
};
std::copy_if(allEmbeddingServices.begin(), allEmbeddingServices.end(), std::back_inserter(embeddingServices), filter);
}
// TODO: get rid of KParts::BrowserExtension::PopupFlags
......@@ -4395,9 +4394,10 @@ void KonqMainWindow::slotPopupMenu(const QPoint &global, const KFileItemList &it
!menuBar()->isVisible() ? m_paShowMenuBar : nullptr,
fullScreenMode() ? m_ptaFullScreen : nullptr
);
qRegisterMetaType<KService::Ptr>("KService::Ptr");
connect(konqyMenuClient, SIGNAL(openEmbedded(KService::Ptr)),
this, SLOT(slotOpenEmbedded(KService::Ptr)), Qt::QueuedConnection);
// qRegisterMetaType<KService::Ptr>("KService::Ptr");
// connect(konqyMenuClient, SIGNAL(openEmbedded(KService::Ptr)),
// this, SLOT(slotOpenEmbedded(KService::Ptr)), Qt::QueuedConnection);
connect(konqyMenuClient, &PopupMenuGUIClient::openEmbedded, this, &KonqMainWindow::slotOpenEmbedded, Qt::QueuedConnection);
// Those actions go into the PopupMenuGUIClient, since that's the one defining them.
QList<QAction *> tabHandlingActions;
......@@ -4535,7 +4535,7 @@ void KonqMainWindow::slotItemsRemoved(const KFileItemList &items)
}
}
void KonqMainWindow::slotOpenEmbedded(KService::Ptr service)
void KonqMainWindow::slotOpenEmbedded(const KPluginMetaData &part)
{
if (!m_currentView) {
return;
......@@ -4545,7 +4545,7 @@ void KonqMainWindow::slotOpenEmbedded(KService::Ptr service)
m_currentView->setLocationBarURL(m_popupUrl);
m_currentView->setTypedURL(QString());
if (m_currentView->changePart(m_popupMimeType,
service->desktopEntryName(), true)) {
part.pluginId(), true)) {
m_currentView->openUrl(m_popupUrl, m_popupUrl.toDisplayString(QUrl::PreferLocalFile));
}
}
......@@ -4692,11 +4692,14 @@ void KonqMainWindow::updateViewModeActions()
delete m_viewModeMenu;
m_viewModeMenu = nullptr;
const KService::List services = m_currentView->partServiceOffers();
const PluginMetaDataVector services = m_currentView->partServiceOffers();
if (services.count() <= 1) {
return;
}
//TODO port away from query: find out how to replace all of this, since I don't think that KPluginMetaData provides
//something like KService::actions
#if 0
m_viewModeMenu = new KActionMenu(i18nc("@action:inmenu View", "&View Mode"), this);
//actionCollection()->addAction( "viewModeMenu", m_viewModeMenu );
......@@ -4754,6 +4757,7 @@ void KonqMainWindow::updateViewModeActions()
&& m_viewModeMenu) {
plugViewModeActions();
}
#endif
}
void KonqMainWindow::slotInternalViewModeChanged()
......@@ -4761,7 +4765,7 @@ void KonqMainWindow::slotInternalViewModeChanged()
KParts::ReadOnlyPart *part = static_cast<KParts::ReadOnlyPart *>(sender());
KonqView *view = m_mapViews.value(part);
if (view) {
const QString actionName = view->service()->desktopEntryName();
const QString actionName = view->service().pluginId();