Bug 399889 - FileChooser shows raw shell globs in "Automatically select extension" text box if given a regex for the supported file extension list
Summary: FileChooser shows raw shell globs in "Automatically select extension" text bo...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Open/save dialogs (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: David Faure
URL:
Keywords: usability
: 402256 402354 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-10-16 17:09 UTC by Nathan Moos
Modified: 2018-12-24 15:37 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.14.5


Attachments
Screenshot of current behaviour (374.93 KB, image/png)
2018-10-16 17:09 UTC, Nathan Moos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Moos 2018-10-16 17:09:39 UTC
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
Comment 1 JanKusanagi 2018-10-16 17:15:18 UTC
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
Comment 2 JanKusanagi 2018-10-16 17:22:30 UTC
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
Comment 3 Kai Uwe Broulik 2018-10-17 11:07:01 UTC
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()
Comment 4 Kai Uwe Broulik 2018-12-18 15:13:45 UTC
*** Bug 402256 has been marked as a duplicate of this bug. ***
Comment 5 Jan Grulich 2018-12-19 10:00:05 UTC
Proposed workaround: https://phabricator.kde.org/D17677
Comment 6 Jan Grulich 2018-12-20 07:13:08 UTC
*** Bug 402354 has been marked as a duplicate of this bug. ***
Comment 7 Jan Grulich 2018-12-23 13:29:45 UTC
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