Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/core/desktopentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -108,7 +110,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;
Expand All @@ -118,6 +119,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") {
Expand Down Expand Up @@ -495,6 +497,21 @@ void DesktopEntryManager::onScanCompleted(const QList<ParsedDesktopEntryData>& s
auto newLowercaseEntries = QHash<QString, DesktopEntry*>();

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()) {
Expand All @@ -516,7 +533,6 @@ void DesktopEntryManager::onScanCompleted(const QList<ParsedDesktopEntryData>& s

qCDebug(logDesktopEntry) << "Found desktop entry" << data.id;

auto lowerId = data.id.toLower();
auto conflictingId = newEntries.contains(data.id);

if (conflictingId) {
Expand Down
1 change: 1 addition & 0 deletions src/core/desktopentry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct ParsedDesktopEntryData {
QString genericName;
QString startupClass;
bool noDisplay = false;
bool hidden = false;
QString comment;
QString icon;
QString execString;
Expand Down