SUMMARY kdialog's --getopenfilename argument used to accept a simple filter of file extensions, like *.jpg, but the functionality has changed to only support Mimetypes, and it is not documented in the usage text. Scripts which use kdialog appear to be broken. It's annoying, but it needs to be documented somewhere, and it would be super if kdialog itself documents itself. STEPS TO REPRODUCE 1. In Konsole, type kdialog to see the usage text. We're interested in getopenfilename: --getopenfilename File dialog to open an existing file (arguments [startDir] [filter]) Instead of just "[filter]", it should say: "[Mimetype filter]" 2. To test this, type: kdialog --getopenfilename ~/Downloads "*.jpg" A standard file dialog will appear, but instead of only showing .jpg files, it shows *all* files, and any file can be selected. A regression. This is documented here: https://develop.kde.org/docs/administration/kdialog/#--getopenfilename-dialog-box https://mostlylinux.wordpress.com/bashscripting/kdialog/#get-open-file-name 3. The new, Mimetype-only functionality of kdialog is now: kdialog --getopenfilename ~/Downloads "image/jpeg" Filtering works as expected. Please update the usage text to reflect this. SOFTWARE/OS VERSIONS Operating System: KDE neon 5.27 KDE Plasma Version: 5.27.3 KDE Frameworks Version: 5.104.0 Qt Version: 5.15.8 Kernel Version: 5.19.0-35-generic (64-bit) Graphics Platform: X11
> 2. To test this, type: > kdialog --getopenfilename ~/Downloads "*.jpg" The related code for wildcard match still exists, and this syntax still works: kdialog --getopenfilename ~/Downloads "Some Strings (*.jpg)" This is KDE's file dialog's bug. --- It seems plasma's file dialog doesn't support simple filter like "*.jpg" https://doc.qt.io/qt-6.4/qfiledialog.html#setNameFilter Compile code below with Qt5 will reproduce this bug ``` #include <QApplication> #include <QFileDialog> int main(int argc, char *argv[]) { QApplication a(argc, argv); // Doesn't work on KDE (only have problem on KDE) auto *dlg1 = new QFileDialog(); dlg1->setNameFilter("*.txt"); dlg1->exec(); // Works auto *dlg2 = new QFileDialog(); dlg2->setNameFilter("Force to work with KDE (*.txt)"); dlg2->exec(); return QApplication::exec(); } ```
Yes, it is KDE's file dialog bug. `kdialog --getopenfilename ~/Downloads "*.jpg"` works on xfce which has a different file dialog.
Very good sleuthing. So how would we reassign this bug so that the developers in charge of the file dialog will see it?
> So how would we reassign this bug so that the developers in charge of the file dialog will see it? I created a new one: https://bugs.kde.org/show_bug.cgi?id=470893
I think I found a related bug with --getexistingdirectory this used to work, I just updated to kdialog 23.04.3 and it no longer works as it used to
(In reply to Baltasar Sanchez from comment #5) > I think I found a related bug with --getexistingdirectory > > this used to work, I just updated to kdialog 23.04.3 and it no longer works > as it used to I can verify that it doesn't seem to work, but maybe it should have it's own bug report to be tracked as a separate issue?
This may have been fixed in: https://bugs.kde.org/show_bug.cgi?id=470893 Test this with the new KF6 release.
The functionality is fixed in KF6: kdialog 24.02.0 works with both file extensions and mime-types. However, the docstring still says: --getopenfilename File dialog to open an existing file (arguments [startDir] [filter]) ...and "filter" is not clarified. It can now be "*.jpg" or "image/jpeg". Instead of just "[filter]", it would be clearer to say: "[Mimetype or file extension filter]"
Do you mind sending a merge request on KDE's GitLab? It should be simple since it is just a string change.
(In reply to shenlebantongying from comment #9) > Do you mind sending a merge request on KDE's GitLab? It should be simple > since it is just a string change. Thank you for the invitation, but I don't know how to do a merge request.
A possibly relevant merge request was started @ https://invent.kde.org/documentation/develop-kde-org/-/merge_requests/351
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kdialog/-/merge_requests/37
Great! Thank you so much and even for updating the documentation 🙏