From c998bb4017eea7bfcbf11a07a94cac45cd8fb5cb Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Wed, 12 Aug 2020 00:59:06 +0200 Subject: [PATCH] Port away from KMimeTypeTrader It is about to be deprecated See https://phabricator.kde.org/T12177 --- applets/kicker/plugin/actionlist.cpp | 6 +++--- applets/kicker/plugin/appentry.cpp | 4 ++-- applets/kicker/plugin/recentusagemodel.cpp | 1 - klipper/urlgrabber.cpp | 4 ++-- libtaskmanager/tasktools.cpp | 8 ++++---- runners/bookmarks/bookmarksrunner.cpp | 4 ++-- runners/webshortcuts/webshortcutrunner.cpp | 4 ++-- shell/scripting/scriptengine_v1.cpp | 8 ++++---- 8 files changed, 19 insertions(+), 20 deletions(-) diff --git a/applets/kicker/plugin/actionlist.cpp b/applets/kicker/plugin/actionlist.cpp index aa38502b2..738f927b8 100644 --- a/applets/kicker/plugin/actionlist.cpp +++ b/applets/kicker/plugin/actionlist.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -91,7 +91,7 @@ QVariantList createActionListForFileItem(const KFileItem &fileItem) { QVariantList list; - KService::List services = KMimeTypeTrader::self()->query(fileItem.mimetype(), QStringLiteral("Application")); + KService::List services = KApplicationTrader::queryByMimeType(fileItem.mimetype()); if (!services.isEmpty()) { list << createTitleActionItem(i18n("Open with:")); @@ -370,7 +370,7 @@ QVariantList appstreamActions(const KService::Ptr &service) QVariantList ret; #ifdef HAVE_APPSTREAMQT - const KService::Ptr appStreamHandler = KMimeTypeTrader::self()->preferredService(QStringLiteral("x-scheme-handler/appstream")); + const KService::Ptr appStreamHandler = KApplicationTrader::preferredService(QStringLiteral("x-scheme-handler/appstream")); // Don't show action if we can't find any app to handle appstream:// URLs. if (!appStreamHandler) { diff --git a/applets/kicker/plugin/appentry.cpp b/applets/kicker/plugin/appentry.cpp index e77362ef1..d099783b2 100644 --- a/applets/kicker/plugin/appentry.cpp +++ b/applets/kicker/plugin/appentry.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -273,7 +273,7 @@ KService::Ptr AppEntry::defaultAppByName(const QString& name) QString browser = config.readPathEntry("BrowserApplication", QString()); if (browser.isEmpty()) { - return KMimeTypeTrader::self()->preferredService(QLatin1String("text/html")); + return KApplicationTrader::preferredService(QLatin1String("text/html")); } else if (browser.startsWith(QLatin1Char('!'))) { browser.remove(0, 1); } diff --git a/applets/kicker/plugin/recentusagemodel.cpp b/applets/kicker/plugin/recentusagemodel.cpp index d9b9f7539..b2bf135ba 100644 --- a/applets/kicker/plugin/recentusagemodel.cpp +++ b/applets/kicker/plugin/recentusagemodel.cpp @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include diff --git a/klipper/urlgrabber.cpp b/klipper/urlgrabber.cpp index 7baf5ed1d..3ad49f02c 100644 --- a/klipper/urlgrabber.cpp +++ b/klipper/urlgrabber.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include "klippersettings.h" @@ -146,7 +146,7 @@ void URLGrabber::matchingMimeActions(const QString& clipData) } if ( !mimetype.isDefault() ) { - KService::List lst = KMimeTypeTrader::self()->query( mimetype.name(), QStringLiteral("Application") ); + KService::List lst = KApplicationTrader::queryByMimeType(mimetype.name()); if ( !lst.isEmpty() ) { ClipAction* action = new ClipAction( QString(), mimetype.comment() ); foreach( const KService::Ptr &service, lst ) { diff --git a/libtaskmanager/tasktools.cpp b/libtaskmanager/tasktools.cpp index 32d93e926..78229d1fe 100644 --- a/libtaskmanager/tasktools.cpp +++ b/libtaskmanager/tasktools.cpp @@ -26,7 +26,7 @@ License along with this library. If not, see . #include #include #include -#include +#include #include #include #include @@ -648,7 +648,7 @@ QString defaultApplication(const QUrl &url) QString browserApp = config.readPathEntry("BrowserApplication", QString()); if (browserApp.isEmpty()) { - const KService::Ptr htmlApp = KMimeTypeTrader::self()->preferredService(QStringLiteral("text/html")); + const KService::Ptr htmlApp = KApplicationTrader::preferredService(QStringLiteral("text/html")); if (htmlApp) { browserApp = htmlApp->storageId(); @@ -663,12 +663,12 @@ QString defaultApplication(const QUrl &url) return confGroup.readPathEntry("TerminalApplication", QStringLiteral("konsole")); } else if (application.compare(QLatin1String("filemanager"), Qt::CaseInsensitive) == 0) { - KService::Ptr service = KMimeTypeTrader::self()->preferredService(QStringLiteral("inode/directory")); + KService::Ptr service = KApplicationTrader::preferredService(QStringLiteral("inode/directory")); if (service) { return service->storageId(); } - } else if (KService::Ptr service = KMimeTypeTrader::self()->preferredService(application)) { + } else if (KService::Ptr service = KApplicationTrader::preferredService(application)) { return service->storageId(); } else { // Try the files in share/apps/kcm_componentchooser/*.desktop. diff --git a/runners/bookmarks/bookmarksrunner.cpp b/runners/bookmarks/bookmarksrunner.cpp index d4893e02c..848db1a03 100644 --- a/runners/bookmarks/bookmarksrunner.cpp +++ b/runners/bookmarks/bookmarksrunner.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include "bookmarkmatch.h" @@ -88,7 +88,7 @@ QString BookmarksRunner::findBrowserName() QString exec = config.readPathEntry(QStringLiteral("BrowserApplication"), QString()); //qDebug() << "Found exec string: " << exec; if (exec.isEmpty()) { - KService::Ptr service = KMimeTypeTrader::self()->preferredService(QStringLiteral("text/html")); + KService::Ptr service = KApplicationTrader::preferredService(QStringLiteral("text/html")); if (service) { exec = service->exec(); } diff --git a/runners/webshortcuts/webshortcutrunner.cpp b/runners/webshortcuts/webshortcutrunner.cpp index 5cecaaeef..df13f8269 100644 --- a/runners/webshortcuts/webshortcutrunner.cpp +++ b/runners/webshortcuts/webshortcutrunner.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -82,7 +82,7 @@ void WebshortcutRunner::configurePrivateBrowsingActions() service = KService::serviceByStorageId(browserFile); } if (!service) { - service = KMimeTypeTrader::self()->preferredService(QStringLiteral("text/html")); + service = KApplicationTrader::preferredService(QStringLiteral("text/html")); } if (!service) { return; diff --git a/shell/scripting/scriptengine_v1.cpp b/shell/scripting/scriptengine_v1.cpp index d12a512c7..d0219fa26 100644 --- a/shell/scripting/scriptengine_v1.cpp +++ b/shell/scripting/scriptengine_v1.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include @@ -643,7 +643,7 @@ QJSValue ScriptEngine::V1::defaultApplication(const QString &application, bool s = config.readPathEntry("BrowserApplication", QString()); if (browserApp.isEmpty()) { const KService::Ptr htmlApp - = KMimeTypeTrader::self()->preferredService(QStringLiteral("text/html")); + = KApplicationTrader::preferredService(QStringLiteral("text/html")); if (htmlApp) { browserApp = storageId ? htmlApp->storageId() : htmlApp->exec(); } @@ -659,7 +659,7 @@ QJSValue ScriptEngine::V1::defaultApplication(const QString &application, bool s QStringLiteral("konsole"))); } else if (matches(application, QLatin1String("filemanager"))) { - KService::Ptr service = KMimeTypeTrader::self()->preferredService( + KService::Ptr service = KApplicationTrader::preferredService( QStringLiteral("inode/directory")); if (service) { return storageId ? service->storageId() : onlyExec(service->exec()); @@ -671,7 +671,7 @@ QJSValue ScriptEngine::V1::defaultApplication(const QString &application, bool s return onlyExec( confGroup.readEntry("windowManager", QStringLiteral("kwin"))); - } else if (KService::Ptr service = KMimeTypeTrader::self()->preferredService(application)) { + } else if (KService::Ptr service = KApplicationTrader::preferredService(application)) { return storageId ? service->storageId() : onlyExec(service->exec()); } else {