flatpak-docs
flatpak-docs copied to clipboard
docs/portals-qt.rst: QDesktopServices::openUrl(const QUrl &url) does not work for file:// url
Currently, the docs imply that QDesktopServices::openUrl(const QUrl &url) can be used to open any url. In my experience this is not true for file://... urls, at least with Qt6. (This might be a bug in Qt, but that's a different story).
I think this restriction should be documented. Perhaps there is a way to open file:// urls, in this case it should be documented how this can be done.
You can open files and directories but it is a different API.
https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.portal.OpenURI
I'm not a Qt person, one could say that API could automatically handle file:// and translate them to org.freedesktop.portal.OpenURI.OpenFile or org.freedesktop.portal.OpenURI.OpenDirectory.
The GIO APIs do this; For example:
flatpak run --filesystem=home --command=gio org.freedesktop.Platform//22.08 open 'file:///home/tingping/Pictures/a-picture.png' works.
I agree, QDesktopServices::openUrl(const QUrl &url) should work and handle this in a way like the one your suggested. The fact that it doesn't do that properly is for the Qt folks to take care of, I guess. (I think there even are open bug reports on Qt's bug tracker regarding this problem and similar ones concerning other sandboxed environments like snap.)
My point is solely concerning the documentation found here: https://docs.flatpak.org/en/latest/portals-qt.html
In my opinion, it would be very good to include more correct information about what works and what doesn't work. And possible workarounds.
Changes are welcomed but I don't use Qt so its just drive-by updates to it.
I think I will investigate this issue a little further and then try to improve the documentation.
Since Qt fixed this, I will close this.