I have a qt app, when the user wants to open a file I use the QFileDialog::getOpenFileName.
The path returned is /run/user/1000/doc/39face4d/myFile.txt instead of /home/user/Documents/myFile.txt
How do I get the “User friendly” path? Am I missing something in the yaml?
I’m not sure what’s causing this but it looks like your application is using $XDG_RUNTIME_DIR instead of $HOME. Is there anything in Qt docs about the functions you’re using using $XDG_RUNTIME_DIR?
I believe the file is made available though the document portal, which is a fuse filesystem under /run/user/<uid>/doc. So what you get is really myFile.txt from the original path, and an external program makes sure that content written there ends up in /home/user/Documents/myFile.txt.
Probably @jamesh knows more about this.
This does indicate that Qt is using xdg-desktop-portal to show the file chooser here. Note that reading from the /run/usr/... path provided will return the contents from the file in ~/Documents, and writes will also be directed to the location you picked. In the vast majority of cases, this proxying is harmless, and gives the user fine grained control over what documents they make available to the confined application.
I am slowly working on some improvements to xdg-desktop-portal/xdg-document-portal that should allow it to avoid proxying files we’re sure the snap can access (e.g. non-hidden files in the user’s home directory if the snap plugs the home interface). That is still a work in progress though.
Not really: if I snap my app in the “traditional way”, using the qmake plugin and the qt 5.9 libs that comes with snap, the dialog works fine…
The problem is that for my app I need a couple of the new features that came in the last 3 years… so basically the question become: how do I create a snap for a Qt 5.14.1 application the right way??? Do you know of any example or tutorial?
Hi.
I have this same issue, and since the file I’m accessing is a script (that runs confined in the snap environment) I get a permission issue.
If I set the path manually with /home//… the script runs properly.
The snap has home access.
Is there an option to tell the portal to allow execute permissions to the loaded files?
Thanks