Skip to content

Commit

Permalink
Fixed #427 - File Open dialog filter is case-sensitive under Linux
Browse files Browse the repository at this point in the history
It is a known QT issue described below.
The recommended workaround is not to use the native dialog under Linux.

https://stackoverflow.com/questions/34858220/qt-how-to-set-a-case-insensitive-filter-on-qfiledialog
https://bugreports.qt.io/browse/QTBUG-51712
  • Loading branch information
foldynl committed Aug 3, 2024
1 parent 3ffe7e5 commit 331f22c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
15 changes: 14 additions & 1 deletion ui/ImportDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,20 @@ void ImportDialog::browse()

QString filename = QFileDialog::getOpenFileName(this, tr("Select File"),
lastPath,
ui->typeSelect->currentText().toUpper() + "(*." + ui->typeSelect->currentText().toLower() + ")");
ui->typeSelect->currentText().toUpper() + "(*." + ui->typeSelect->currentText().toLower() + ")",
nullptr,
#if defined(Q_OS_LINUX)
// Do not use the Native Dialog under Linux because the dialog is case-sensitive.
// QT variant looks different but it is case-insensitive.
// More information:
// https://stackoverflow.com/questions/34858220/qt-how-to-set-a-case-insensitive-filter-on-qfiledialog
// https://bugreports.qt.io/browse/QTBUG-51712
QFileDialog::DontUseNativeDialog
#else
QFileDialog::Options()
#endif

);
if ( !filename.isEmpty() )
{
settings.setValue("import/last_path", QFileInfo(filename).path());
Expand Down
17 changes: 14 additions & 3 deletions ui/PaperQSLDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,22 @@ void PaperQSLDialog::addFileClick()
tr("Add File"),
lastPath,
#if defined(Q_OS_WIN)
""
"",
#elif defined(Q_OS_MACOS)
""
"",
#else
""
"",
#endif
nullptr,
#if defined(Q_OS_LINUX)
// Do not use the Native Dialog under Linux because the dialog is case-sensitive.
// QT variant looks different but it is case-insensitive.
// More information:
// https://stackoverflow.com/questions/34858220/qt-how-to-set-a-case-insensitive-filter-on-qfiledialog
// https://bugreports.qt.io/browse/QTBUG-51712
QFileDialog::DontUseNativeDialog
#else
QFileDialog::Options()
#endif
);
if ( !filename.isEmpty() )
Expand Down
17 changes: 14 additions & 3 deletions ui/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1820,11 +1820,22 @@ void SettingsDialog::tqslPathBrowse()
tr("Select File"),
lastPath,
#if defined(Q_OS_WIN)
"TQSL (*.exe)"
"TQSL (*.exe)",
#elif defined(Q_OS_MACOS)
"TQSL (*.app)"
"TQSL (*.app)",
#else
"TQSL (tqsl)"
"TQSL (tqsl)",
#endif
nullptr,
#if defined(Q_OS_LINUX)
// Do not use the Native Dialog under Linux because the dialog is case-sensitive.
// QT variant looks different but it is case-insensitive.
// More information:
// https://stackoverflow.com/questions/34858220/qt-how-to-set-a-case-insensitive-filter-on-qfiledialog
// https://bugreports.qt.io/browse/QTBUG-51712
QFileDialog::DontUseNativeDialog
#else
QFileDialog::Options()
#endif
);
if ( !filename.isEmpty() )
Expand Down

0 comments on commit 331f22c

Please sign in to comment.