Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot choose a folder in Flatpak build #2479

Closed
alexgleason opened this issue Dec 24, 2018 · 12 comments
Closed

Cannot choose a folder in Flatpak build #2479

alexgleason opened this issue Dec 24, 2018 · 12 comments

Comments

@alexgleason
Copy link

Linux distribution and version

Tested on elementary OS Loki 0.4 and Ubuntu 18.10

Flatpak version

Flatpak 1.0.6

Description of the problem

I've used Flatpak to build Solarus Game Engine, a Qt-based desktop program that helps people make games.

It must load these games as folders. This is what "File > Add quest..." is supposed to look like:

screenshot from 2018-12-23 18 24 30

I can click a folder and select "choose" and it chooses that whole folder.

However, the Flatpak build does not use the Qt file browser dialog. It uses the native system one. Here's the resulting Flatpak on elementary OS 0.4 Loki:

screenshot from 2018-12-23 16 53 08

I cannot select a folder. The only option is "Open" which causes the file browser to navigate into the folder.

To be sure this wasn't an issue with elementary OS, I also tested on Ubuntu 18.10 with nearly the same result:

hyctq3d

Any ideas?

Steps to reproduce

  1. Clone Solarus and enter it:
git clone https://gitlab.com/solarus-games/solarus.git
cd solarus
  1. Install KDE runtime and SDK 5.11:
flatpak install flathub org.kde.Platform//5.11 org.kde.Sdk//5.11
  1. Build the Flatpak:
flatpak-builder build-dir org.solarus_games.Solarus.json
  1. Run the launcher program:
flatpak-builder --run build-dir org.solarus_games.Solarus.json solarus-launcher
  1. The Solarus Launcher GUI will start. Choose "File > Add quest..." and attempt to select a folder, but you can't.

Thank you, and happy holidays!

@TingPing
Copy link
Member

This is a Qt bug, it shouldn't be using the portal to open folders.

@alexgleason
Copy link
Author

I just saw this: https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-org.freedesktop.portal.FileChooser

It doesn't look like selecting folders is actually supported by the xdg-desktop-portal spec at all? There's no mention of them.

@alexgleason
Copy link
Author

Wait, so are you saying qt could use its own file chooser dialog from within the flatpak? I thought that wasn't possible due to the nature of the sandbox.

@matthiasclasen
Copy link
Collaborator

If you want to select a folder inside the sandbox, using a local file chooser works. There is no way to select a host-side folder at runtime.

@alexgleason
Copy link
Author

I opened a bug report against Qt: https://bugreports.qt.io/browse/QTBUG-72755

IMO this is still a bug in Flatpak, or at least a limitation that should be documented. Thanks all for your help.

@refi64
Copy link
Collaborator

refi64 commented Dec 25, 2018

Could this be a bug in the runtime itself?

@alexgleason
Copy link
Author

For what it's worth, I tried creating a Snap and it did the same thing. Screenshot of my Snap build:

screenshot from 2018-12-24 20 38 23

snapcraft.yml:

name: solarus
version: "1.6"
summary: A free and open-source Action-RPG game engine
description: |
  Solarus is a free and open-source Action-RPG game engine, licensed under GPL,
  and written in C++. It runs quests in Lua, and can work on a great number
  of platforms. Solarus also features a game editor called Solarus Quest Editor,
  written in C++ with Qt to help you create your game.

confinement: devmode

apps:
  solarus:
    command: desktop-launch solarus-launcher

parts:
  solarus:
    plugin: cmake
    source-type: git
    source: https://gitlab.com/solarus-games/solarus.git
    source-commit: 633bad6be5fbe2f77c3d63db497f7d7e2b1128f6
    build-packages:
      - g++
      - make
      - libsdl2-dev
      - libsdl2-image-dev
      - libsdl2-ttf-dev
      - libluajit-5.1-dev
      - libphysfs-dev
      - libopenal-dev
      - libmodplug-dev
      - libvorbis-dev
      - qtbase5-dev
      - qttools5-dev
      - qttools5-dev-tools
      - libglm-dev
    after: [desktop-qt5]

@matthiasclasen
Copy link
Collaborator

IMO this is still a bug in Flatpak, or at least a limitation that should be documented. Thanks all for your help.

It is a well-known limitation.

@grulja
Copy link
Contributor

grulja commented Dec 26, 2018

I just checked Solarus and it calls QFileDialog::getOpenFileName(), which means it requests to open a file, not a directory and even the filter says "Select archive or quest.dat". Qt actually doesn't use portal when trying to open a folder and when you want to open a folder, you have to change file mode in QFileDialog.

@grulja
Copy link
Contributor

grulja commented Dec 26, 2018

For reference:
https://codereview.qt-project.org/#/c/230089/
https://codereview.qt-project.org/#/c/231715/
https://codereview.qt-project.org/#/c/230560/

These all are patches to make Qt not to use portals when opening folders. All were merged to Qt 5.12 and we backported them all to our KDE 5.11 runtime (also to KDE 5.9lts).

@alexgleason
Copy link
Author

alexgleason commented Jan 2, 2019

Thank you all for the info and help. The bit about QFileDialog::getOpenFileName() makes sense. A different portion of the software uses QFileDialog::getExistingDirectory() which I haven't yet gotten a chance to test yet, but I'm guessing it will work as you'd expect. I'll close this now.

You all were extremely helpful, thanks a lot for answering (and even over the holiday), it made my life easier. 😄

@suutari-ai
Copy link

I had issues opening directories in flatpak apps in KDE environment in Ubuntu 20.04. I think it was related to this issue or the mentioned Qt issues.

The issue was that I wasn't able to select a directory in VS Code, Ungoogled Chromium or Slack, because they launched xdg-dekstop-portal-kde as the directory chooser, but that allowed only selecting files.

Workaround

# Replace the non-functional KDE portal with the GTK one
apt install xdg-desktop-portal-gtk
apt purge xdg-desktop-portal-kde
# The portal service can still be running, so kill it:
pkill xdg-desktop-portal-kde

This makes the flatpak apps use the GTK portal instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants