From e07778d97bafffe503c00ad7de4a26cb1ae1e159 Mon Sep 17 00:00:00 2001 From: Martin Klapetek Date: Tue, 8 Sep 2015 12:30:30 -0400 Subject: [PATCH] Simplify getting associated apps list in AssociatedApplicationManager REVIEW: 125105 --- .../private/associatedapplicationmanager.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/plasma/private/associatedapplicationmanager.cpp b/src/plasma/private/associatedapplicationmanager.cpp index 60ba596fd..182f657d5 100644 --- a/src/plasma/private/associatedapplicationmanager.cpp +++ b/src/plasma/private/associatedapplicationmanager.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #if !PLASMA_NO_KIO #include @@ -72,15 +72,8 @@ public: for (i = urlLists.begin(); i != urlLists.end(); ++i) { QAction *a = i.key()->actions()->action("run associated application"); if (a) { - // This gets the current mimetype _and_ a list of its aliases, because aliases() - // do not return the current mimetype in it, so it needs to be prepended, - // especially for the cases where there are no aliases to be returned, - // this would then just return an empty list, returning the generic action even - // when there is a valid mimetype and an associated app - QStringList mimeTypes{mimeDb.mimeTypeForUrl(i.value().first()).name()}; - mimeTypes << mimeDb.mimeTypeForUrl(i.value().first()).aliases(); - - apps = KFileItemActions::associatedApplications(mimeTypes, QString()); + const QString mimeType = mimeDb.mimeTypeForUrl(i.value().first()).name(); + const KService::List apps = KMimeTypeTrader::self()->query(mimeType); if (!apps.isEmpty()) { a->setIcon(QIcon::fromTheme(apps.first()->icon())); a->setText(i18n("Open with %1", apps.first()->genericName().isEmpty() ? apps.first()->genericName() : apps.first()->name())); @@ -149,7 +142,8 @@ void AssociatedApplicationManager::setUrls(Plasma::Applet *applet, const QListactions()->action("run associated application"); if (a) { QMimeDatabase mimeDb; - KService::List apps = KFileItemActions::associatedApplications(mimeDb.mimeTypeForUrl(urls.first()).aliases(), QString()); + const QString mimeType = mimeDb.mimeTypeForUrl(urls.first()).name(); + const KService::List apps = KMimeTypeTrader::self()->query(mimeType); if (!apps.isEmpty()) { a->setIcon(QIcon::fromTheme(apps.first()->icon())); a->setText(i18n("Open with %1", apps.first()->genericName().isEmpty() ? apps.first()->genericName() : apps.first()->name()));