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

QXdgDesktopPortalFileDialog does not support preselecting and getting selected filter

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.15.1
    • 5.15.0
    • None
    • Debian testing with Qt from Debian (5.14.2+dfsg-4) or self-compiled from Qt's 5.15 branch as of commit b3b21b1a30e5375a327cc09313ada8d42bdf2164
    • Linux/Wayland, Linux/X11
    • 3e09c28101d1af1dd90a4b515d7edbe5a3737f97 (qt/qtbase/dev) 7bf2ca05b8b119f6a5d2081c72cc9b3362a1275e (qt/qtbase/5.15)

    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 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:

      1. compile attach 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-desktop) 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

        1. main.cpp
          1.0 kB
          Michael Weghorn

        Issue Links

          Activity

            People

              michaelweghorn Michael Weghorn
              michaelweghorn Michael Weghorn
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: