Skip to content

Use desktop environment-aware file picker #2911

Closed

Description

@Evpok

At least when using Atom with Plasma DE, the file dialog is the GTK File Chooser one, which feels severely out-of-place (though one gets used to it from using other non-DE aware GTK apps). It would be nice if it could use QFileDialog as does Chromium.

Activity

  1. Evpok commented on Sep 27, 2015

    @Evpok
    Author

    Good thinking! It doesn't actually use any Qt binding, it just invokes the command line utility kdialog. Seems easy enough. It will only work with Plasma, though, and not e.g. for LXQt.

  2. Evpok commented on Oct 22, 2015

    @Evpok
    Author

    Keeping this as a reminder for myself if you don't mind.

    The interesting point is in https://github.com/atom/electron/tree/master/atom/browser/ui. We have to

    • write https://github.com/atom/electron/blob/master/atom/browser/ui/file_dialog_plasma.cc
    • figure how to make electron use it if the current DE is Plasma
    • If we want to get fancy about it, figure a way to (possibly as an option) use it or a similar file picker for LXQt/other Qt based DEs (are there any ?). apparently, the other Qt desktops use kdialog, so it would work for them, too.
  3. Siilwyn commented on Aug 30, 2016

    @Siilwyn
    Contributor

    This is still needed right? I'd be interested in picking this up, not sure how to test though since I use Gnome...

  4. Thaodan commented on Sep 22, 2016

    @Thaodan

    QFileDialog would be good every Qt based DE hooks their module in the provide their native dialog if needed (look at frameworksintegration). I dont if its possible but using QFileDialog for every plattform would be possible too since it provides integration for every plattform.

  5. Siilwyn commented on Oct 8, 2016

    @Siilwyn
    Contributor

    Never mind, doing this is above my current knowledge I will first need to learn more about C++ before being able to implement this. If anybody else is picking this up I would be interested in pair programming though.

  6. polarathene commented on Apr 7, 2017

    @polarathene

    Using a few electron apps (GitKraken and Atom mostly), along with Chromium. Any updates on getting this supported? Or at least someone knowledgeable about the codebase that'd be happy to work with one of us to add the support?

    Seems progress is being made on a related issue, GTK3 support however. I think I've heard of Flatpak packaged apps being able to use Qt file choosers, so that might work as a workaround?

  7. jhasse commented on Apr 28, 2017

    @jhasse

    I think I've heard of Flatpak packaged apps being able to use Qt file choosers, so that might work as a workaround?

    I would even say that should be the way forward.

  8. Gim6626 commented on Jul 10, 2017

    @Gim6626

    I think this feature is important too. Is there any progress on the issue?

  9. self-assigned this
    on Jul 28, 2017
  10. codebytere commented on Jul 29, 2017

    @codebytere
    Member

    Hey all: a fix for this is in the works, and in the meantime here's a module to provide a workaround until it's been completed

  11. Thaodan commented on Jul 29, 2017

    @Thaodan
  12. 22 remaining items

  13. ssokolow commented on Feb 8, 2019

    @ssokolow

    @Thaodan Unfortunately, the overhead for spawning a new process each time you want an open/save dialog gets irritating very quickly. Chrome did it and, as much as I'd like native KDE dialogs, I had to force it back to GTK+ dialogs with export NO_CHROME_KDE_FILE_DIALOG=1 because I just couldn't stand the added sluggishness.

    (Though, admittedly, that's partly because I'll middle-click a bunch of image links, then alternate between Ctrl+S and Ctrl+W, which makes any added delays very noticeable.)

    Portals would avoid that because calling into the portal host over D-Bus doesn't require spawning a new process each time.

    Also, portals would avoid the need to include "When do we use which picker?" logic in Electron when a user has more than one desktop installed and is mixing components. (Just use GtkFileChooserNative and it's the user's problem for not configuring their desktop and GTK the way they want.)

    That said, if you do want to play with them, the commands you're looking for are

    • kdialog --getopenfilename [startDir] [filter]
    • kdialog --getsavefilename [startDir] [filter]
    • kdialog --getexistingdirectory [startDir]
    • kdialog --getopenurl [startDir] [filter]
    • kdialog --getsaveurl [startDir] [filter]

    They all require that you provide at least one argument, but will accept a filter without a startDir. (eg. you can pass *.txt and they'll recognize it as a filter and assume you want to start in the current working directory.

  14. Rush commented on Feb 9, 2019

    @Rush

    One thing to consider against a separate process file dialog is the inability of window managers to properly display modality in such cases. (for example block the primary window and dim the background)

  15. TingPing commented on Feb 9, 2019

    @TingPing
    Contributor

    One thing to consider against a separate process file dialog is the inability of window managers to properly display modality in such cases. (for example block the primary window and dim the background)

    It passes the window id to the other process so on x11 it can work.

  16. ssokolow commented on Feb 9, 2019

    @ssokolow

    It passes the window id to the other process so on x11 it can work.

    It can work on Wayland too, if the portal host and compositor are written to work together, which makes sense, given that the DE is already supposed to write/customize both components to provide an integrated experience.

    As for kdialog, that's done via this...

    --attach <winid>          Makes the dialog transient for an X app specified by winid
    

    Zenity (GTK+'s equivalent) is confusing in that respect because it has --modal but appears to have no way to specify a parent window to be transient to. (Just the X11 class and name properties, which aren't even specific to a single process, let a lone a single window.)

  17. tristan957 commented on Jul 8, 2019

    @tristan957
    Contributor

    I will be taking a second crack at creating a PR for this issue since the last on never got merged.

  18. madprops commented on Aug 14, 2019

    @madprops

    Please support QT and KDE.

  19. TingPing commented on Aug 14, 2019

    @TingPing
    Contributor

    @madprops The proposed solution supports Qt dialogs. (Perhaps read the discussion before uselessly bumping it)

  20. MurzNN commented on Dec 17, 2019

    @MurzNN

    Here https://github.com/codebytere/native-kde-file-open is workaround to open native KDE file open dialogs in current Electron.

  21. tristan957 commented on Mar 8, 2020

    @tristan957
    Contributor

    The PR is feature complete I think, so all that is left to do is figuring out is another serious code review from an electron contributor so we can decide if loading the module and functions as static classs members would be more beneficial.

  22. ShalokShalom commented on May 7, 2020

    @ShalokShalom

    Is there anything left to do, besides the code review?

  23. tristan957 commented on May 7, 2020

    @tristan957
    Contributor

    The PR might need a rebase, but I tested it and it worked, but I don't work with Electron at all, nor am I a contributor so someone would honestly need to plug in my branch of electron into their project and see if anything breaks.

  24. DemiMarie commented on Dec 20, 2020

    @DemiMarie

    Can this be extended to handle Flatpak’s portal? Right now the file picker is simply not compatible with the sandbox.

  25. tristan957 commented on Dec 20, 2020

    @tristan957
    Contributor

    The pr takes care of Flatpaks as well

  26. ssokolow commented on Dec 20, 2020

    @ssokolow

    @DemiMarie That happens automatically when using GtkFileChooserNative. GTK has built-in support for indirecting through Flatpak portals... it just requires applications to request OS-native file dialogs instead of always using the customizable GTK-provided ones.

    (Same thing with Qt for that matter, except that Qt's API was designed around using OS-native dialogs by default, so most Qt applications didn't need to change anything.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions