krita file picker should use xdg file chooser portal?

krita seems to only (or sometimes) use a built in file picker, which leads to inconsistent experiences between the system file manager vs within krita in some packages, and also a difference between behavior in the appimage/flatpack vs distro packages

appimage and flatpack:


distro package (fedora):

a few thoughts:
a) krita is probably using some method of calling the system file chooser, but when it’s called on something like a flatpack or appimage where it’s not “directly” on the user’s system it ends up using some basic version available to it instead
b) I’m unsure how this impacts users on gnome, I might try to spin up a VM to check if it seems needed
c) it’s possible this isn’t usual behavior and I’ve actually stumbled onto a bug, but I don’t think that’s the case

CONCLUSION:
regardless of the cause, and assuming C is untrue, the official appimage and community flatpack have worse file choosers than native packages, and this should be fixed.

based on my current understanding, it seems like xdg-destop file chooser portal just needs to be implemented and that should fix it??

I’m totally willing to try to fix it myself, but I’m fairly inexperienced with real-world coding so if this is a difficult or somewhat complex task I’m probably not up to par, I also clearly need a better understanding of what’s really happening before I can try, hence making this discussion

disclaimer: sorry if this is a duplicate or if I’m speaking ignorantly here, I rooted around and couldn’t find any posts about this specifically. I also tried to surface research the topic best I could but I’m sure my understanding of desktop portals, flatpacks/appimages, and krita has plenty of blind spots

The first screenshot is the GTK/GNOME default portal file dialog.

Try installing the xdg-desktop-portal-kde if not already installed, and set to use KDE’s portal (I am not familiar with how to achieve this, should be easy to find).

This isn’t even specific to Krita’s flatpack, any flatpack would have the same symptom.

I should mention that xdg-desktop-portal-gtk is a very generic portal for non GNOME desktops. Since 2023, the xdg-desktop-portal-gnome overhauled the file picker to finally fix the thumbnail issue. OP has the option to use either the GNOME or KDE file picker. Recently, the portals has a configuration file. Lets say you decided on the KDE portal.

You would make a config file under (correct me if I’m wrong) $HOME/.config/xdg-desktop-portal/portals.conf and in it, put something such as:

[preferred]
default=gtk
org.freedesktop.impl.portal.FileChooser=kde

Allow me to make a visual comparison of GNOME 43 vs 44:

So if OP doesn’t want to pull in KDE libs, the GNOME libs are an option.

(FWIW, I’m on Fedora 42 KDE Plasma)
it is installed, I tried following northlean’s reply and relevant documentation and tried this with no success:

# ~/.config/xdg-pestop-portal/portals.conf
[preferred]
default=kde
org.freedesktop.impl.portal.FileChooser=kde

I also tried gnome or gtk options in various combinations but nothing changed for krita or the other flatpacks I mention below (I also tried restarting because the docs are unclear when the config is called), which makes me think I’m doing it wrong or the necessary gtk/gnome stuff is not installed, but then how is the gtk file chooser getting called in the first place lol

I also tried adding org.freedesktop.impl.portal.FileChooser=kde to /usr/local/share/xdg-desktop-portal/kde-portals.conf but no dice

resources:
xdg-destop-portals docs
arch wiki page
gentoo wiki page
“Enable native file dialogs” setting is enabled by default…
Krita Flatpak uses Gnome’s file picker…

this would make sense, but my steam and prism launcher flatpacks don’t do this, and use the correct filepicker. so either this is incorrect or I’m just misunderstanding you


I wonder if they might be using a different flatpak “runtime” (collection of base libraries) than the Krita flatpak and the former are configured for portals while the latter tries something else.

The “native” (from system packages) version of Krita will very likely get its dialogs from the KDE integration plugin rather than the portal which is how you get the “correct one” for it.

Actually the dialog you get for AppImage and Flatpak Krita looks a lot like the standard Qt file picker. Which would be the fallback when they can’t load the host KDE integration plugin nor access the portal.

1 Like

could this be a permissions issue with the flatpak not having access to the system files it needs in order to use the system file picker?

run flatseal and give it file access to the system directories since they are not usually turned on be default.

1 Like

it looks like, weirdly enough, like both steam and krita uses freedesktop while prism uses the kde runtime?

unfortunately it looks like it does already. I also tried giving it all filesystem permissions for the sake of completeness, but no success


(screenshot is the defaults)

For Steam that is OK, it is not a Qt application.

For Krita that means they are including Qt inside their own Flatpak.

Maybe the built it without portal support.

1 Like

ok, after a recent update the file picker in the distro package is also the wrong one, seems to be the same one the flatpak/appimage uses. I left feedback on the update, but it’s unclear if it’s the fault of an update in the code by the devs or an update in the packaging by the maintainer

at some point I want to dig more into krita/appimages/flatpaks in general and figure out exactly what’s going on but I haven’t gotten around to it yet

thinking about it more, considering the appimage and flatpak were more up to date than the fedora package I believe, it’s possible this was just a code update that hadn’t gotten to the distro package yet. I should probably dig through the commit history

I tried changing DontUseNativeFileDialog in ~/.config/kritarc to both true or false (and restarting krita both times) but the file dialog stayed the same. then I tried deleting ~/.local/share/krita and ~/.config/kritarc {+kritadisplayarc} and it changed the dialog back to how it was before the update???

appimage (which pulls from the same locations by default if I understand right) still uses the same dialog as usual but we’re back to where we were before at least. really weird though, I have no idea why an update would make that not work while resetting my app state fixes it.

I also took a look at the commit history, there does seem to be a relatively recent commit related to this, and matches up with the fedora package updates to be changed in the recent update. so it looks like krita switched from QFileDialog to using KoFileDialog for it’s file dialog API. however now that I reset the state the native package still uses the same file dialog as before, so it doesn’t look like this commit caused the issue

something I noticed is the commiter exclusively says “K(o)FileDialog” in their notes and in the code but I was only able to find a KFileDialog (without the O) online. I don’t know if that’s important or not but just trying to dump any potentially helpful info for anyone interested

speaking of, sorry to flood the thread I just figured it’d be useful to have this information documented somewhere easily accessible instead of just in my head, lmk if I should cut it down or anything

also, I might be ready to file a proper bug report for this, but I’m not sure if I have enough info yet

anyway, I’ll keep digging

edit: now that it’s fixed, I realized I should change DontUseNativeFileDialog again from false (apparently the default) to true. this changed the file dialog to match the appimage and flatpak one! very interesting

KoFileDialog is Krita’s own wrapper for QFileDialog:

It has no relation to KFileDialog. The reason for the Ko part of the name is historical I believe, from the times when Krita was part of KOffice.

Nowadays KDE applications use QFileDialog in C++ (QtQuick.Dialogs.FileDialog in QML), both of these should work to get the native file picker + work with portals.

If their wrapper has introduced some regression you should report to Krita on https://bugs.kde.org.

2 Likes

oh, thank you so much for the info! I’m so glad I mentioned that then. with all that in order I believe I’m ready to file a bug report, here is the link

1 Like