Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85657

QXdgDesktopPortalFileDialog does not support preselecting and getting selected filter

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.15.0
    • None
    • Debian testing (amd64), Qt self-compiled from 5.15 branch as of commit b3b21b1a30e5375a327cc09313ada8d42bdf2164.
    • Linux/Wayland, Linux/X11

    Description

      When using the desktop portal, e.g. with environment variable QT_QPA_PLATFORMTHEME="xdgdesktopportal" set, preselecting a specific filter or retrieving the one that was selected in QFileDialog does not work, i.e. the following methods don't work as expected:

       

      QFileDialog::selectMimeTypeFilter
      QFileDialog::selectedMimeTypeFilter
      QFileDialog::selectNameFilter
      QFileDialog::selectedNameFilter

        

      A sample program (main.cxx) to test this is attached.

       

      Steps to reproduce:

      (precondition: have current development versions of xdg-desktop-portal and xdg-desktop-portal-gtk or xdg-desktop-portal-kde installed)

      1. compile attached sample program
      2. run it, using the portal file chooser:

          QT_QPA_PLATFORMTHEME="xdgdesktopportal" ./main

      3. check what filter is preselected in the first file dialog that opens
      4. select PDF for the filter, then select a file and click OK
      5. check output of the program
      6. check what MIME filter is preselected in the second file dialog
      7. select PDF for the filter, then select a file and click OK
      8. check output of the program

      Actual result:

      in step 3): PDF filter is preselected
      in step 5): output is: selectedNameFilter(): ""
      in step 6: PDF filter is preselected
      in step 8: output is: selectedMimeTypeFilter(): ""

       

      Expected result:

      The behavior should be the same as when using the "normal" (i.e. non-portal) file chooser, i.e. without env variable QT_QPA_PLATFORMTHEME="xdgdesktopportal" set:

      in step 3): text filter is preselected (since set with QFileDialog::selectNameFilter)
      in step 5): output is: selectedNameFilter(): "PDF (*.pdf)"
      in step 6: text filter is preselected (since set with QFileDialog::selectMimeTypeFilter("text/plain"))
      in step 8: output is: selectedMimeTypeFilter(): "application/pdf"

       

      Further notes:

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              michaelweghorn Michael Weghorn
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes