Bug 499787

Summary: Support xdg-document-portal
Product: [Applications] systemsettings Reporter: Ilya Fedin <fedin-ilja2010>
Component: kcm_filetypesAssignee: Plasma Bugs List <plasma-bugs-null>
Status: CONFIRMED ---    
Severity: wishlist CC: faure, kde, kdedev, meven, nate
Priority: NOR    
Version First Reported In: 6.2.5   
Target Milestone: ---   
Platform: NixOS   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Ilya Fedin 2025-02-10 23:59:53 UTC
SUMMARY
xdg-document-portal saves the file asssociation preference per-app for apps using xdg-desktop-portal to open files. Currently the only way to manipulate xdg-document-portal settings are flatpak permission-related CLI commands. gtk 4.18 looks like going to always use xdg-desktop-portal, even when not in flatpak, so there's going to be an entire class of apps it's impossible to edit file associations for with the KCM.

STEPS TO REPRODUCE
1. Open the KCM
2. See for portal's per-app file associations

OBSERVED RESULT
There's none

EXPECTED RESULT
A editable list of apps with their file associations

SOFTWARE/OS VERSIONS
Operating System: NixOS 25.05
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.1
Kernel Version: 6.12.10-cachyos (64-bit)
Graphics Platform: Wayland
Comment 1 Nate Graham 2025-02-19 15:58:29 UTC
Thanks for the heads-up about this, Ilya.
Comment 2 Ilya Fedin 2025-03-08 14:31:16 UTC
Looks like I made a mistake about the version, it's actually used since 4.10 by any application using the GtkUriLauncher/GtkFileLauncher APIs (opposed to the deprecated gtk_show_uri). So it's live for around 2 years already. 4.18 won't make a difference regarding URL opening actually.
Comment 3 David Redondo 2025-03-10 08:33:20 UTC
I think having per app default apps might be a bit too much to show in the UI.

I had a look at this and I think it might no even be needed. 
- if a mime type has a default app the portal will use that
- the app forces to show the app choosing dialog => nothing to do the dialog will always be shown.
- the case that some mime type doesnt have a default app
   - in the case the user selects "remember" => go to 1
   - if the user doesn't select a default app, the portal will keep asking a defined number of times and then stop asking, this is where this would matter
   - the number of times the portal should ask is saved in the permission store, we could just increase that number to some incredibly high number or even reset the number of times it has asked in the past from the portal impl to sidestep this problem.
Comment 4 Ilya Fedin 2025-03-10 16:08:28 UTC
> if a mime type has a default app the portal will use that

No, that's true only for a few schemes. All other schemes and all file types get asked 3 times and then remembered for the app that attempted to open the URI/file.

https://github.com/flatpak/xdg-desktop-portal/blob/main/src/open-uri.c#L478
Comment 5 David Redondo 2025-03-10 16:49:59 UTC
That sucks.

SO I guess the comment there is not entirely true https://github.com/flatpak/xdg-desktop-portal/issues/472#issuecomment-1423002949
Comment 6 Ilya Fedin 2025-03-10 19:39:35 UTC
They changed the logic multiple times during the years, it's possible it was the true back then. Or maybe he meant only http(s) URLs talking about firefox.
Comment 7 Ilya Fedin 2025-03-10 19:56:49 UTC
Apparently the latter given that https://github.com/flatpak/xdg-desktop-portal/issues/472#issuecomment-614701580 links the PR changing the logic to the current state.