Created attachment 167044 [details] Sample program to reproduce the bug SUMMARY QFileDialog allows the use of named filters, e.g. QFileDialog::setNameFilters to set filters and QFileDialog::selectedNameFilter to retrieve the currently selected filter. However, QFileDialog::selectedNameFilter currently doesn't return the full name of the actually selected filter when that one contains text in parenthesis in addition to the file extensions when using the KF6 version. The KF5 one works or non-native Qt one works as expected. STEPS TO REPRODUCE 1. create a dummy file to select: `mkdir dummy.ods` 2. compile attached sample program main.cpp with Qt 6 and run it on KDE Plasma 6 3. select the "ODF Spreadsheet" filter in the file dialog 4. select the dummy file created in step 1 5. click "Open" 6. check the output on stderr OBSERVED RESULT The returned filter lacks the " (.ods") part that was set in parenthesis before using QFileDialog::setNameFilters: > selected filter: "ODF Spreadsheet (*.ods)" EXPECTED RESULT The actually selected filter should be returned including the text in brackets: > selected filter: "ODF Spreadsheet (.ods) (*.ods)" This works as expected when building against Qt 5 instead (so that the KF 5 version is used) or explicitly disabling the use of the native KF 6 implementation by setting the QFileDialog::DontUseNativeDialog option on the dialog (s. line 17 in the sample program, recompile with that line uncommented to make it work). SOFTWARE/OS VERSIONS Operating System: KDE neon Unstable Edition KDE Plasma Version: 6.0.80 KDE Frameworks Version: 6.0.0 Qt Version: 6.6.2 Kernel Version: 6.5.0-25-generic (64-bit) Graphics Platform: X11 Processors: 4 × Intel® Core™ i7-8850H CPU @ 2.60GHz Memory: 11,4 GiB of RAM Graphics Processor: llvmpipe Manufacturer: QEMU Product Name: Standard PC (Q35 + ICH9, 2009) System Version: pc-q35-7.2 ADDITIONAL INFORMATION This bug breaks saving files in LibreOffice when using the kf6 integration and was originally reported there: https://bugs.documentfoundation.org/show_bug.cgi?id=159701 This is a follow-up for bug 481287, which solved part of the problem.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-integration/-/merge_requests/140
Git commit 448b8aef5751608e6de05a8c31741cea1035dabb by Michael Weghorn. Committed on 12/03/2024 at 15:13. Pushed by nicolasfella into branch 'master'. Don't truncate filter name containing parenthesis When extracting the part of the string that contains the filter name, use the part in front of the *last* parenthesis, not the first one, since otherwise the name gets truncated if it contains parenthesis itself, e.g. in a call like QFileDialog dialog; dialog.setNameFilters({"ODF Spreadsheet (.ods) (*.ods)"}); This is in line with the fact that `QPlatformFileDialogHelper::cleanFilterList` just considers those extensions in the last set of parenthesis and aligns the behavior with the non-native QFileDialog implementation that the Qt library itself provides, as well as the KF 5 implementation. M +1 -1 qt6/src/platformtheme/kdeplatformfiledialoghelper.cpp https://invent.kde.org/plasma/plasma-integration/-/commit/448b8aef5751608e6de05a8c31741cea1035dabb
Git commit efa61e7de254dd1184b73499adea5aba177e3db4 by Nicolas Fella, on behalf of Michael Weghorn. Committed on 12/03/2024 at 15:24. Pushed by nicolasfella into branch 'Plasma/6.0'. Don't truncate filter name containing parenthesis When extracting the part of the string that contains the filter name, use the part in front of the *last* parenthesis, not the first one, since otherwise the name gets truncated if it contains parenthesis itself, e.g. in a call like QFileDialog dialog; dialog.setNameFilters({"ODF Spreadsheet (.ods) (*.ods)"}); This is in line with the fact that `QPlatformFileDialogHelper::cleanFilterList` just considers those extensions in the last set of parenthesis and aligns the behavior with the non-native QFileDialog implementation that the Qt library itself provides, as well as the KF 5 implementation. (cherry picked from commit 448b8aef5751608e6de05a8c31741cea1035dabb) M +1 -1 qt6/src/platformtheme/kdeplatformfiledialoghelper.cpp https://invent.kde.org/plasma/plasma-integration/-/commit/efa61e7de254dd1184b73499adea5aba177e3db4