@@ -226,6 +226,8 @@ void DesktopEntry::updateState(const ParsedDesktopEntryData& newState) {
226226 this ->bGenericName = newState.genericName ;
227227 this ->bStartupClass = newState.startupClass ;
228228 this ->bNoDisplay = newState.noDisplay ;
229+ this ->bOnlyShowIn = newState.onlyShowIn ;
230+ this ->bNotShowIn = newState.notShowIn ;
229231 this ->bComment = newState.comment ;
230232 this ->bIcon = newState.icon ;
231233 this ->bExecString = newState.execString ;
@@ -611,51 +613,20 @@ void DesktopEntryManager::onScanCompleted(const QList<ParsedDesktopEntryData>& s
611613 auto newLowercaseEntries = QHash<QString, DesktopEntry*>();
612614 auto desktopNames = qEnvironmentVariable (" XDG_CURRENT_DESKTOP" ).split (' :' , Qt::SkipEmptyParts);
613615
614- auto maskEntry = [&](const QString& id, const QString& lowerId, const char * reason) {
615- if (auto * victim = newEntries.take (id)) victim->deleteLater ();
616- newLowercaseEntries.remove (lowerId);
617-
618- if (auto it = oldEntries.find (id); it != oldEntries.end ()) {
619- it.value ()->deleteLater ();
620- oldEntries.erase (it);
621- }
622-
623- qCDebug (logDesktopEntry) << reason << id;
624- };
625-
626616 for (const auto & data: scanResults) {
627617 auto lowerId = data.id .toLower ();
628618
629619 if (data.hidden ) {
630- maskEntry (data.id , lowerId, " Masking hidden desktop entry" );
631- continue ;
632- }
633-
634- if (data.onlyShowIn .has_value () && data.notShowIn .has_value ()) {
635- qCWarning (logDesktopEntry) << " Desktop entry" << data.id
636- << " defines both OnlyShowIn and NotShowIn, skipping" ;
637- maskEntry (data.id , lowerId, " Masking invalid desktop entry" );
638- continue ;
639- }
620+ if (auto * victim = newEntries.take (data.id )) victim->deleteLater ();
621+ newLowercaseEntries.remove (lowerId);
640622
641- if (data.onlyShowIn .has_value ()) {
642- auto found = std::ranges::any_of (desktopNames, [&](const QString& name) {
643- return data.onlyShowIn ->contains (name);
644- });
645- if (!found) {
646- maskEntry (data.id , lowerId, " Masking desktop entry (OnlyShowIn)" );
647- continue ;
623+ if (auto it = oldEntries.find (data.id ); it != oldEntries.end ()) {
624+ it.value ()->deleteLater ();
625+ oldEntries.erase (it);
648626 }
649- }
650627
651- if (data.notShowIn .has_value ()) {
652- auto dominated = std::ranges::any_of (desktopNames, [&](const QString& name) {
653- return data.notShowIn ->contains (name);
654- });
655- if (dominated) {
656- maskEntry (data.id , lowerId, " Masking desktop entry (NotShowIn)" );
657- continue ;
658- }
628+ qCDebug (logDesktopEntry) << " Masking hidden desktop entry" << data.id ;
629+ continue ;
659630 }
660631
661632 DesktopEntry* dentry = nullptr ;
@@ -705,8 +676,27 @@ void DesktopEntryManager::onScanCompleted(const QList<ParsedDesktopEntryData>& s
705676 this ->lowercaseDesktopEntries = newLowercaseEntries;
706677
707678 auto newApplications = QVector<DesktopEntry*>();
708- for (auto * entry: this ->desktopEntries .values ())
709- if (!entry->bNoDisplay ) newApplications.append (entry);
679+ for (auto * entry: this ->desktopEntries .values ()) {
680+ if (entry->bNoDisplay ) continue ;
681+
682+ auto & onlyShowIn = entry->bOnlyShowIn .value ();
683+ auto & notShowIn = entry->bNotShowIn .value ();
684+ if (onlyShowIn.has_value () && notShowIn.has_value ()) {
685+ qCWarning (logDesktopEntry) << " Desktop entry" << entry->mId
686+ << " defines both OnlyShowIn and NotShowIn (skipping display)" ;
687+ continue ;
688+ }
689+ if (onlyShowIn.has_value () && !std::ranges::any_of (desktopNames, [&](const QString& name) {
690+ return onlyShowIn->contains (name);
691+ }))
692+ continue ;
693+ if (notShowIn.has_value () && std::ranges::any_of (desktopNames, [&](const QString& name) {
694+ return notShowIn->contains (name);
695+ }))
696+ continue ;
697+
698+ newApplications.append (entry);
699+ }
710700
711701 this ->mApplications .diffUpdate (newApplications);
712702
0 commit comments