Bug 452225 - Appchooser dialog cannot find Okular
Summary: Appchooser dialog cannot find Okular
Status: RESOLVED UPSTREAM
Alias: None
Product: xdg-desktop-portal-kde
Classification: Plasma
Component: general (show other bugs)
Version: 5.24.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL: https://github.com/flatpak/xdg-deskto...
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-03 14:20 UTC by Nicolas Fella
Modified: 2022-04-30 17:05 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Fella 2022-04-03 14:20:07 UTC
STEPS TO REPRODUCE
1. Use Dolphin from Flatpak 
2. Click on a PDF file

OBSERVED RESULT
A list of potential apps appears, but it doesn't include Okular


EXPECTED RESULT
Okular is part of that list

SOFTWARE/OS VERSIONS
KDE Plasma Version: master
KDE Frameworks Version: master
Qt Version: 5.15.3

ADDITIONAL INFORMATION

The list of choices contains 'okularApplication_pdf', but the list of all apps only contains 'org.kde.okular'. That results in Okular not being shown
Comment 1 Nate Graham 2022-04-04 21:03:13 UTC
Can reproduce.
Comment 2 Harald Sitter 2022-04-25 12:24:27 UTC
Can you still reproduce this? For me okular shows up just fine on master.
Comment 3 Nate Graham 2022-04-25 14:45:00 UTC
I'm still able to reproduce with everything on master and Okular installed from distro packages, built from source, and also as a flatpak. :)
Comment 4 Harald Sitter 2022-04-26 11:24:29 UTC
Ha! It only happens with a system okular not with flatpak okular
Comment 5 Harald Sitter 2022-04-26 11:56:35 UTC
This is a bit awkward...

okularApplication_pdf.desktop is the actual desktop file associating with pdf, org.kde.okular.desktop does not. 

What happens then is that the xdg-desktop-portal queries the options for pdf, it gets back okularApplication_pdf.desktop and whatever else may handle pdf

e.g.
XDP: Recommended handlers for file, application/pdf: okularApplication_pdf, org.chromium.Chromium, org.gimp.GIMP, inkscape

this then further trips up inside the portal because 

a) there isn't a single choice
b) the scheme to be opened isn't remote and so should_use_default_app() doesn't apply
c) right out the gate the user wouldn't have picked okular often enough for it to get auto-selected (i.e. the user would have had to pick okular a number of times from the dialog before it becomes implicit default)

ultimately this results in the dialog popping up (which is kind of silly TBH) and that dialog will then does not contain okular because okularApplication_pdf.desktop is NoDisplay and org.kde.okular.desktop doesn't associate with PDF. Long story short: the behavior is expected.

This ultimately shouldn't happen though, this bug is in effect a variant of https://github.com/flatpak/xdg-desktop-portal/issues/472 - the portal really shouldn't be starting an appchooser dialog for pdf at all, but start the default app. The only practical reason for the app chooser to appears is when no handlers are found or when the user set always-ask on his system.
Comment 6 Aleix Pol 2022-04-30 07:32:58 UTC
If we have all the information we need, we should be able to respond before even showing the dialog. What am I missing?
Comment 7 Harald Sitter 2022-04-30 17:05:25 UTC
There's a flag that tells the xdg portal to invoke the impl even when otherwise not needed. That flag is not passed along as best I can tell.

i.e. the application can explicitly ask for the dialog but we don't know whether that is the case (in which case we'd have to show the dialog) or not (which is when we could just return a value)