Commit 6377ed4f authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

make sure host okular shows up

when using (e.g.) dolphin as a flatpak it runs stuff through the app
chooser dialog but that dialog is incapable of handling okular
correctly. okular is a bit of an odd ball because it installs a separate
desktop file for every file format it supports (thereby technically
allowing default handling). unfortunately since currently portals always
prompt which app to use (until a clear winner choice has been made) this
system falls flat on the face because now we somehow need to get okular
into our preference list but the actual preference we get passed in from
the upstream portal is 'okularApplication_pdf' not 'org.kde.okular'.
Very unfortunate set of circumstances that. To mitigate this problem we
use the new aliasfor property to compile a list of "fake" names and then
present the aliased entity instead of the fake one.

this is not a problem when okular is installed as a flatpak because
there the mimetype list of the flatpak's desktop file is comprehensive
parent def117e0
Pipeline #196220 passed with stage
in 2 minutes and 2 seconds
* SPDX-FileCopyrightText: 2017-2019 Red Hat Inc
* SPDX-FileCopyrightText: 2020 Harald Sitter <>
* SPDX-FileCopyrightText: 2020-2022 Harald Sitter <>
* SPDX-License-Identifier: LGPL-2.0-or-later
......@@ -219,8 +219,19 @@ AppModel::~AppModel()
void AppModel::setPreferredApps(const QStringList &list)
void AppModel::setPreferredApps(const QStringList &possiblyAliasedList)
// In the event that we get incoming NoDisplay entries that are AliasFor another desktop file,
// switch the NoDisplay name for the aliased name.
QStringList list;
for (const auto &entry : possiblyAliasedList) {
if (const auto value = m_noDisplayAliasesFor.value(entry); !value.isEmpty()) {
list << value;
} else {
list << entry;
for (ApplicationItem &item : m_list) {
bool changed = false;
......@@ -287,12 +298,20 @@ QHash<int, QByteArray> AppModel::roleNames() const
void AppModel::loadApplications()
const KService::List appServices = KApplicationTrader::query([](const KService::Ptr &service) -> bool {
return service->isValid() && !service->noDisplay() /* includes platform and desktop considerations */;
return service->isValid();
for (const KService::Ptr &service : appServices) {
if (service->noDisplay()) {
if (const auto alias = service->aliasFor(); !alias.isEmpty()) {
m_noDisplayAliasesFor.insert(service->desktopEntryName(), service->aliasFor());
continue; // no display after all
const QString fullName = service->property(QStringLiteral("X-GNOME-FullName"), QVariant::String).toString();
const QString name = fullName.isEmpty() ? service->name() : fullName;
ApplicationItem appItem(name, service->icon(), service->desktopEntryName());
if (!m_list.contains(appItem)) {
......@@ -123,6 +123,7 @@ private:
void loadApplications();
QList<ApplicationItem> m_list;
QHash<QString, QString> m_noDisplayAliasesFor;
class AppChooserDialog : public QuickDialog
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment