Commit cce2a797 authored by Nicolas Fella's avatar Nicolas Fella

Port from KMimeTypeTrader to KApplicationTrader

KMimeTypeTrader is about to be deprecated, use the new API instead.

There is still some usage of KMimeTypeTrader left for KPart loading.
That requires a different new API so I'm not porting that yet.

See also https://phabricator.kde.org/T12173
parent 0f147181
......@@ -28,7 +28,12 @@
#include <KI18n/KLocalizedString>
#include <KIOWidgets/KRun>
#include <KWidgetsAddons/KMessageBox>
#include <kservice_version.h>
#if KSERVICE_VERSION < QT_VERSION_CHECK(5, 68, 0)
#include <KService/KMimeTypeTrader>
#else
#include <KService/KApplicationTrader>
#endif
#include <KService/KToolInvocation>
#include <KXmlGui/KActionCollection>
#include <KIOCore/KFileItem>
......@@ -178,9 +183,15 @@ PanelContextMenu::PanelContextMenu(KrPanel *krPanel, QWidget *parent)
uniqueMimeTypes.insert(file->getMime());
const QStringList mimeTypes = uniqueMimeTypes.values();
#if KSERVICE_VERSION < QT_VERSION_CHECK(5, 68, 0)
offers = mimeTypes.count() == 1 ?
KMimeTypeTrader::self()->query(mimeTypes.first()) :
KFileItemActions::associatedApplications(mimeTypes, QString());
#else
offers = mimeTypes.count() == 1 ?
KApplicationTrader::queryByMimeType(mimeTypes.first()) :
KFileItemActions::associatedApplications(mimeTypes, QString());
#endif
if (!offers.isEmpty()) {
auto *openWithMenu = new QMenu(this);
......
......@@ -49,7 +49,12 @@
#include <KIOWidgets/KOpenWithDialog>
#include <KIOWidgets/KPropertiesDialog>
#include <KIOWidgets/KRun>
#include <kservice_version.h>
#if KSERVICE_VERSION < QT_VERSION_CHECK(5, 68, 0)
#include <KService/KMimeTypeTrader>
#else
#include <KService/KApplicationTrader>
#endif
#include <KWidgetsAddons/KCursor>
#include <KWidgetsAddons/KMessageBox>
#include <KWidgetsAddons/KToggleAction>
......@@ -158,7 +163,11 @@ void ListPanelFunc::openFileNameInternal(const QString &name, bool externallyExe
return;
}
#if KSERVICE_VERSION < QT_VERSION_CHECK(5, 68, 0)
KService::Ptr service = KMimeTypeTrader::self()->preferredService(mime);
#else
KService::Ptr service = KApplicationTrader::preferredService(mime);
#endif
if(service) {
runService(*service, QList<QUrl>() << url);
return;
......
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