sitter added a comment.

    if (!service) {
        const QString desktopId = desktopEntry + QLatin1String(".desktop");
        const auto services = 
KServiceTypeTrader::self()->query(QStringLiteral("Application"),
                                                                
QStringLiteral("exist Exec and exist [X-Flatpak-RenamedFrom]"));
        for (auto it = services.constBegin(); it != services.constEnd() && 
!service; ++it) {
            const QVariant renamedFrom = 
(*it)->property(QStringLiteral("X-Flatpak-RenamedFrom"), QVariant::String);
            const auto names = renamedFrom.toString().split(QChar(';'));
            for (const QString &name : names) {
                if (name == desktopId) {
                    service = *it;
                    break;
                }
            }
        }
    }
  
  Please try with this.
  
  KService doesn't know how to properly deserialize X-* stringlists because we 
have some desktop files which still use comma lists and others which use 
semicolon lists. Because of this a trader query for semicolon separated lists 
won't work unless `KService::property()` gets special hardcoded handling to 
read the list as an XDG type rather than a KConfig type. From a speed POV the 
above code and a complete query are just about the same as a query too would 
simply go into property() to read the property and then check against 
constraints in the query.
  
  The obvious alternative of course is to extend KService. IMHO putting X-* 
keys into KService is fairly awkward though. Another option would be to 
introduce `::xdgProperty()` and then extend the query language to specify a 
type expectation (e.g. `('%1' in XDG[X-Flatpak-RenamedFrom]`).

REPOSITORY
  R120 Plasma Workspace

REVISION DETAIL
  https://phabricator.kde.org/D21779

To: broulik, #plasma, sitter, davidedmundson
Cc: zzag, plasma-devel, LeGast00n, ericadams, jraleigh, GB_2, ragreen, Pitel, 
ZrenBot, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, 
apol, mart

Reply via email to