Created attachment 115682 [details] Screenshot of current behaviour SUMMARY When a file filter is attached to a file save dialog over the xdg-desktop-portal interface, it looks awful (`.[pP][nN][gG]` for PNG images, in particular). STEPS TO REPRODUCE 1. Get a Firefox Nightly build with xdg-desktop-portal support, 2018-10-16 or later. Make sure you run it with `GTK_USE_PORTAL=1` to force it to use the portal interface. 2. Navigate to a PNG image. 3. Right-click, "Save image as" OBSERVED RESULT See attached screenshot. EXPECTED RESULT "Automatically select filename extension (.png)" SOFTWARE VERSIONS (available in About System) KDE Plasma Version: 5.13.5 KDE Frameworks Version: 5.48 Qt Version: 5.11.1 ADDITIONAL INFORMATION
For the record, executing this on a Qt-based program under Plasma: QFileDialog::getSaveFileName(this, "TEST", "", "TEST files (*.[pP]ng *.blah);;ALL (*)"); shows that same uglyness. Not sure if that "wildcard syntax" is/should be supported, but it certainly displays badly in the "Automatically select filename extension" message in those dialogs
Easily reproducible also with KDialog, like this: kdialog --getsavefilename "$HOME" "PNG files (*.[Pp]ng)" if the user enters a file name like "test" in that dialog and presses Enter, the string returned by KDialog will be: /home/yourusername/test.[Pp]ng
Ideally it would just pass a mime type to us rather than relying on the archaic concept of extensions. I can confirm the bug, the file browser (both Qt's internal one and the KIO one) seem to cope with the syntax fine but the automatic file extension detection is somewhat borked. Easiest solution: if (pattern.contains("[") hide()
*** Bug 402256 has been marked as a duplicate of this bug. ***
Proposed workaround: https://phabricator.kde.org/D17677
*** Bug 402354 has been marked as a duplicate of this bug. ***
Git commit 66eb2fe654b95eb721ed3b2b1cb500f55920d7e8 by Jan Grulich. Committed on 23/12/2018 at 13:29. Pushed by grulich into branch 'Plasma/5.14'. Add workaround for gtk file chooser filter patterns Summary: Gtk can use filter patterns, looking like "*.[Pp][Nn][Gg]" to handle all possible lowercase/uppercase variants. This is unfortunately not supported by KDE/Qt dialogs so we should try to convert it to just "*.png" instead. There are other possible patterns, but this is probably the most common one. Reviewers: broulik, davidedmundson Reviewed By: davidedmundson Subscribers: heikobecker, ngraham, davidedmundson, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D17677 M +43 -3 src/filechooser.cpp https://commits.kde.org/xdg-desktop-portal-kde/66eb2fe654b95eb721ed3b2b1cb500f55920d7e8