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

QFileDialog::getSaveFileName on mac os double file extension (i.e. *.tar.gz ) filter alert

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.15.0 Beta2
    • 5.4.0, 5.12, 5.15
    • None
    •  OS X, native file dialog
    • macOS
    • 5d9d3ff3269f92366b022e17485fa4dd98f5ba95 (qt/qtbase/5.15)

      Adding file filter to QFileDialog::getSaveFileName for user to be able to select i.e. "*.tar.gz" and than selecting format from pop up messes up/just appends .tar.gz to previously selected file name instead replacing extension or just add twice extension.

      I.e. in Standard dialogs example add filters for *.tar and *.tar.gz:

      void Dialog::setSaveFileName()
      {
          const QFileDialog::Options options = QFlag(fileDialogOptionsWidget->value());
          QString selectedFilter;
          QString fileName = QFileDialog::getSaveFileName(this,
                                      tr("QFileDialog::getSaveFileName()"),
                                      saveFileNameLabel->text(),
                                      tr("All Files (*);;Text Files (*.txt);;Tar (*.tar);;Tar gzipped (*.tar.gz)"),
                                      &selectedFilter,
                                      options);
          if (!fileName.isEmpty())
              saveFileNameLabel->setText(fileName);
      }
      

      after showing save dialog, typing name test and switching popup to Tar gzipped (*.tar.gz) name becomes test.tar.gz.tar.gz, than switching to something other i.e. to Tar (*.tar) (there is also bug there it doesn't always change extension on first popup change) name becomes test.tar.gz.tar.gz.tar, and going furher switching popup to *.tar.gzip will change to name to test.tar.gz.tar.gz.tar.gz.tar.gz etc.

      Even just selecting *.tar.gzip popup, fixing name to be test.tar.gz and clicking Save alert pops up (see attached pictures), and returned name if I select use both is test.tar.gz.tar.gz or selecting use .tar.gz returned name is test.tar.tar.gz

      Only workaround I could think of is setting option QFileDialog::HideNameFilterDetails and filter to be "Tar gzipped (*)" and manually adding extension after dialog is closed

        1. file name and type fixed manually and clicked save alert.png
          60 kB
          Ivan Golubovic
        2. format popup changed to tar.gz.png
          46 kB
          Ivan Golubovic
        3. save name entered.png
          43 kB
          Ivan Golubovic
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            vestbo Tor Arne Vestbø
            ivang Ivan Golubovic
            Votes:
            7 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes