From 4c066d991a779a6268f7fd2b2ed4f8764741cc02 Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 18 Sep 2025 09:33:55 -0400 Subject: [PATCH 1/2] core/desktopentry: mask entries with priority less than hidden entry --- src/core/desktopentry.cpp | 18 ++++++++++++++++-- src/core/desktopentry.hpp | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/core/desktopentry.cpp b/src/core/desktopentry.cpp index cb9710e2..b453988c 100644 --- a/src/core/desktopentry.cpp +++ b/src/core/desktopentry.cpp @@ -108,7 +108,6 @@ ParsedDesktopEntryData DesktopEntry::parseText(const QString& id, const QString& auto finishCategory = [&data, &groupName, &entries]() { if (groupName == "Desktop Entry") { if (entries.value("Type").second != "Application") return; - if (entries.value("Hidden").second == "true") return; for (const auto& [key, pair]: entries.asKeyValueRange()) { auto& [_, value] = pair; @@ -118,6 +117,7 @@ ParsedDesktopEntryData DesktopEntry::parseText(const QString& id, const QString& else if (key == "GenericName") data.genericName = value; else if (key == "StartupWMClass") data.startupClass = value; else if (key == "NoDisplay") data.noDisplay = value == "true"; + else if (key == "Hidden") data.hidden = value == "true"; else if (key == "Comment") data.comment = value; else if (key == "Icon") data.icon = value; else if (key == "Exec") { @@ -495,6 +495,21 @@ void DesktopEntryManager::onScanCompleted(const QList& s auto newLowercaseEntries = QHash(); for (const auto& data: scanResults) { + auto lowerId = data.id.toLower(); + + if (data.hidden) { + if (auto* victim = newEntries.take(data.id)) victim->deleteLater(); + newLowercaseEntries.remove(lowerId); + + if (auto it = oldEntries.find(data.id); it != oldEntries.end()) { + it.value()->deleteLater(); + oldEntries.erase(it); + } + + qCDebug(logDesktopEntry) << "Masking hidden desktop entry" << data.id; + continue; + } + DesktopEntry* dentry = nullptr; if (auto it = oldEntries.find(data.id); it != oldEntries.end()) { @@ -516,7 +531,6 @@ void DesktopEntryManager::onScanCompleted(const QList& s qCDebug(logDesktopEntry) << "Found desktop entry" << data.id; - auto lowerId = data.id.toLower(); auto conflictingId = newEntries.contains(data.id); if (conflictingId) { diff --git a/src/core/desktopentry.hpp b/src/core/desktopentry.hpp index b124aaf8..623019de 100644 --- a/src/core/desktopentry.hpp +++ b/src/core/desktopentry.hpp @@ -33,6 +33,7 @@ struct ParsedDesktopEntryData { QString genericName; QString startupClass; bool noDisplay = false; + bool hidden = false; QString comment; QString icon; QString execString; From 223279390079672bc9e9c27bd7a410e5fb128a90 Mon Sep 17 00:00:00 2001 From: bbedward Date: Tue, 30 Sep 2025 08:17:03 -0400 Subject: [PATCH 2/2] core/desktopentry: don't match locales with wrong modifier/country --- src/core/desktopentry.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/desktopentry.cpp b/src/core/desktopentry.cpp index b453988c..941a4050 100644 --- a/src/core/desktopentry.cpp +++ b/src/core/desktopentry.cpp @@ -61,12 +61,14 @@ struct Locale { [[nodiscard]] int matchScore(const Locale& other) const { if (this->language != other.language) return 0; - auto territoryMatches = !this->territory.isEmpty() && this->territory == other.territory; - auto modifierMatches = !this->modifier.isEmpty() && this->modifier == other.modifier; + + if (!other.modifier.isEmpty() && this->modifier != other.modifier) return 0; + if (!other.territory.isEmpty() && this->territory != other.territory) return 0; auto score = 1; - if (territoryMatches) score += 2; - if (modifierMatches) score += 1; + + if (!other.territory.isEmpty()) score += 2; + if (!other.modifier.isEmpty()) score += 1; return score; }