- QString aFileName = (myType == WFS_SAVE)
- ? QFileDialog::getSaveFileName(this, myTitle, aDefaultPath, aFilter, &mySelectedFilter)
- : QFileDialog::getOpenFileName(this, myTitle, aDefaultPath, aFilter, &mySelectedFilter);
- if (!aFileName.isEmpty()) {
- myPathField->setText(aFileName);
+
+ // use Option prohibited native dialog using to have both lower/upper extensions of files
+ // satisfied to dialog filter on Linux(Calibre) Issue #2055
+ myFileDialog = new QFileDialog(this, myTitle, aDefaultPath, aFilter);
+ myFileDialog->setNameFilter(aFilter);
+ myFileDialog->setOptions(QFileDialog::DontUseNativeDialog);
+ myFileDialog->setAcceptMode(myType == WFS_SAVE ? QFileDialog::AcceptSave
+ : QFileDialog::AcceptOpen);
+ if (myFileDialog->exec() == QDialog::Accepted)
+ {
+ mySelectedFilter = myFileDialog->selectedNameFilter();
+ QStringList aFileNames = myFileDialog->selectedFiles();
+ if (!aFileNames.empty()) {
+ QString aFileName = aFileNames.first();
+ if (!aFileName.isEmpty()) {
+ if (myType == WFS_SAVE)
+ aFileName = applyExtension(aFileName, mySelectedFilter);
+ myPathField->setText(aFileName.toUtf8());
+ myDefaultPath = QFileInfo(aFileName).absolutePath();
+ emit focusOutWidget(this);
+ }
+ }