Apply upstream patch for fixing duplicated launcher entries

This commit is contained in:
Andreas Cord-Landwehr
2021-06-21 23:06:34 +02:00
parent 1be91ed99c
commit 7d32b2bf1f
2 changed files with 149 additions and 1 deletions

View File

@@ -27,7 +27,10 @@ DEPENDS = " \
gstreamer1.0 \
"
SRC_URI = "git://invent.kde.org/plasma/${BPN};nobranch=1;protocol=https"
SRC_URI = " \
git://invent.kde.org/plasma/${BPN};nobranch=1;protocol=https \
file://0001-Simplify-apps-model.patch \
"
S = "${WORKDIR}/git"
inherit cmake_plasma

View File

@@ -0,0 +1,145 @@
From 992950085df9762288955d8e4b5a76f4bc4b2f68 Mon Sep 17 00:00:00 2001
From: Nicolas Fella <nicolas.fella@gmx.de>
Date: Thu, 10 Jun 2021 23:17:52 +0200
Subject: [PATCH] Simplify apps model
The current code iterates over each service group separately and adds its apps. This leads to duplicate entries when an app is in multiple groups.
Since we are not actually interested in the group info, only in a flat list of all apps with some filters, we can simplify this.
---
.../applicationlistmodel.cpp | 97 ++++++++-----------
1 file changed, 40 insertions(+), 57 deletions(-)
diff --git a/components/mobilehomescreencomponents/applicationlistmodel.cpp b/components/mobilehomescreencomponents/applicationlistmodel.cpp
index 9e925da..00335d5 100644
--- a/components/mobilehomescreencomponents/applicationlistmodel.cpp
+++ b/components/mobilehomescreencomponents/applicationlistmodel.cpp
@@ -16,13 +16,12 @@
#include <QQuickWindow>
// KDE
+#include <KApplicationTrader>
#include <KIO/ApplicationLauncherJob>
#include <KNotificationJobUiDelegate>
#include <KService>
-#include <KServiceGroup>
#include <KSharedConfig>
#include <KSycoca>
-#include <KSycocaEntry>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/plasmawindowmanagement.h>
@@ -158,71 +157,55 @@ void ApplicationListModel::loadApplications()
auto cfg = KSharedConfig::openConfig(QStringLiteral("applications-blacklistrc"));
auto blgroup = KConfigGroup(cfg, QStringLiteral("Applications"));
- QStringList blacklist = blgroup.readEntry("blacklist", QStringList());
+ const QStringList blacklist = blgroup.readEntry("blacklist", QStringList());
beginResetModel();
m_applicationList.clear();
- KServiceGroup::Ptr group = KServiceGroup::root();
- if (!group || !group->isValid()) return;
- KServiceGroup::List subGroupList = group->entries(true);
-
QMap<int, ApplicationData> orderedList;
QList<ApplicationData> unorderedList;
QSet<QString> foundFavorites;
- // Iterate over all entries in the group
- while (!subGroupList.isEmpty()) {
- KSycocaEntry::Ptr groupEntry = subGroupList.first();
- subGroupList.pop_front();
-
- if (groupEntry->isType(KST_KServiceGroup)) {
- KServiceGroup::Ptr serviceGroup(static_cast<KServiceGroup *>(groupEntry.data()));
-
- if (!serviceGroup->noDisplay()) {
- KServiceGroup::List entryGroupList = serviceGroup->entries(true);
-
- for(KServiceGroup::List::ConstIterator it = entryGroupList.constBegin(); it != entryGroupList.constEnd(); it++) {
- KSycocaEntry::Ptr entry = (*it);
-
- if (entry->isType(KST_KServiceGroup)) {
- KServiceGroup::Ptr serviceGroup(static_cast<KServiceGroup *>(entry.data()));
- subGroupList << serviceGroup;
-
- } else if (entry->property(QStringLiteral("Exec")).isValid()) {
- KService::Ptr service(static_cast<KService *>(entry.data()));
-
- if (service->isApplication() &&
- !blacklist.contains(service->desktopEntryName()) &&
- service->showOnCurrentPlatform() &&
- !service->property(QStringLiteral("Terminal"), QVariant::Bool).toBool()) {
-
- ApplicationData data;
- data.name = service->name();
- data.icon = service->icon();
- data.storageId = service->storageId();
- data.uniqueId = service->storageId();
- data.entryPath = service->exec();
- data.startupNotify = service->property(QStringLiteral("StartupNotify")).toBool();
-
- if (m_favorites.contains(data.uniqueId)) {
- data.location = Favorites;
- foundFavorites.insert(data.uniqueId);
- } else if (m_desktopItems.contains(data.uniqueId)) {
- data.location = Desktop;
- }
+ auto filter = [blacklist](const KService::Ptr &service) -> bool {
+ if (service->noDisplay()) {
+ return false;
+ }
- auto it = m_appPositions.constFind(data.uniqueId);
- if (it != m_appPositions.constEnd()) {
- orderedList[*it] = data;
- } else {
- unorderedList << data;
- }
- }
- }
- }
- }
+ if (!service->showOnCurrentPlatform()) {
+ return false;
+ }
+
+ if (blacklist.contains(service->desktopEntryName())) {
+ return false;
+ }
+
+ return true;
+ };
+
+ const KService::List apps = KApplicationTrader::query(filter);
+
+ for (const KService::Ptr &service : apps) {
+ ApplicationData data;
+ data.name = service->name();
+ data.icon = service->icon();
+ data.storageId = service->storageId();
+ data.uniqueId = service->storageId();
+ data.entryPath = service->exec();
+ data.startupNotify = service->property(QStringLiteral("StartupNotify")).toBool();
+
+ if (m_favorites.contains(data.uniqueId)) {
+ data.location = Favorites;
+ foundFavorites.insert(data.uniqueId);
+ } else if (m_desktopItems.contains(data.uniqueId)) {
+ data.location = Desktop;
+ }
+
+ auto it = m_appPositions.constFind(data.uniqueId);
+ if (it != m_appPositions.constEnd()) {
+ orderedList[*it] = data;
+ } else {
+ unorderedList << data;
}
}
--
2.30.2