flatpak-docs icon indicating copy to clipboard operation
flatpak-docs copied to clipboard

docs/portals-qt.rst: QDesktopServices::openUrl(const QUrl &url) does not work for file:// url

Open ChrisHal opened this issue 3 years ago • 4 comments

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.

ChrisHal avatar Aug 24 '22 14:08 ChrisHal

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.

TingPing avatar Oct 22 '22 03:10 TingPing

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.

ChrisHal avatar Oct 25 '22 11:10 ChrisHal

Changes are welcomed but I don't use Qt so its just drive-by updates to it.

TingPing avatar Oct 25 '22 15:10 TingPing

I think I will investigate this issue a little further and then try to improve the documentation.

ChrisHal avatar Oct 25 '22 16:10 ChrisHal

Since Qt fixed this, I will close this.

ChrisHal avatar Apr 23 '24 11:04 ChrisHal