KFileDialog is now deprecated in favour of QFileDialog, which takes a Qt format filter string ("description (*.ext);;"). However, the only way to set a filter on a KUrlRequester is by using KUrlRequester:setFilter(), which still requires a KDE format filter string ("*.ext|description\n"). This appears to be the only place within Frameworks libraries (excepting kdelibs4support) where the KDE filter string is still used. As well as being an anomaly, this is a problem in the case where an application may use both QFileDialog and KUrlRequester, because it is not possible to share the same filter strings between both. This is a source of duplication and possible out-of-sync errors. Changing KUrlRequester::setFilter() to take a Qt format filter string would be an incompatible API change, unless it could be reliably autodetected. One possible option to fix this would be to deprecate KUrlRequester::setFilter() and add KUrlRequester::setNameFilter() analogous to QFileDialog::setNameFilter, taking a Qt format filter string. Reproducible: Always
KUrlRequester::setMimeTypeFilters() was added by https://phabricator.kde.org/D4431, which partly solves the problem. Leaving this bug report open pending a decision as to whether to deprecate setFilter().
There's a fix hanging in the pipeline: https://phabricator.kde.org/D9645 But it's questionable if it's still needed.
Dear Bug Submitter, This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging If you have already provided the requested information, please mark the bug as REPORTED so that the KDE team knows that the bug is ready to be confirmed. Thank you for helping us make KDE software even better for everyone!
Confirming because still an API anomaly.
https://invent.kde.org/frameworks/kio/-/merge_requests/1321 is a MR to approach this issue.
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1326
Git commit 6e945ed1dc01ffbaf30455341cff0ba945877255 by Friedrich W. H. Kossebau. Committed on 23/06/2023 at 14:04. Pushed by kossebau into branch 'kf5'. KUrlRequester::setFilter: note special filter syntax, allow unnamed filters The API dox referred to QFileDialog::setNameFilters for the syntax to use which is "Comment (file pattern)". The internal logic though expects the old KDE style syntax "file pattern|Comment". For more compatibility with Qt also allow name/comment-less filters by handling of non-existing "|" hit in the filter parsing. Related: bug 464350 M +6 -4 src/widgets/kurlrequester.cpp M +8 -2 src/widgets/kurlrequester.h https://invent.kde.org/frameworks/kio/-/commit/6e945ed1dc01ffbaf30455341cff0ba945877255
Git commit a7e865aa41acdb83dd625c68dd8f0d16e7f6dc0d by Friedrich W. H. Kossebau. Committed on 23/06/2023 at 14:26. Pushed by kossebau into branch 'master'. KUrlRequester::setFilter: note special filter syntax, allow unnamed filters The API dox referred to QFileDialog::setNameFilters for the syntax to use which is "Comment (file pattern)". The internal logic though expects the old KDE style syntax "file pattern|Comment". For more compatibility with Qt also allow name/comment-less filters by handling of non-existing "|" hit in the filter parsing. Related: bug 464350 (cherry picked from commit 6e945ed1dc01ffbaf30455341cff0ba945877255) M +6 -4 src/widgets/kurlrequester.cpp M +8 -2 src/widgets/kurlrequester.h https://invent.kde.org/frameworks/kio/-/commit/a7e865aa41acdb83dd625c68dd8f0d16e7f6dc0d
Git commit ee89c7a9e673f5734cd4f5fb50ebadc6915050eb by Friedrich W. H. Kossebau. Committed on 23/06/2023 at 14:29. Pushed by kossebau into branch 'kf5'. Add KUrlRequester::nameFilters, deprecate KUrlRequester::filter For consistency with QFileDialog API and better naming given there are 2 kinds of filters supported, by name and by MIME type. M +109 -0 autotests/kurlrequestertest.cpp M +1 -1 src/widgets/CMakeLists.txt M +62 -7 src/widgets/kurlrequester.cpp M +35 -1 src/widgets/kurlrequester.h https://invent.kde.org/frameworks/kio/-/commit/ee89c7a9e673f5734cd4f5fb50ebadc6915050eb
Git commit 8a1cc098cec9937bb11206f555a9bb978fbaf981 by Friedrich W. H. Kossebau. Committed on 23/06/2023 at 14:32. Pushed by kossebau into branch 'master'. Add KUrlRequester::nameFilters, deprecate KUrlRequester::filter For consistency with QFileDialog API and better naming given there are 2 kinds of filters supported, by name and by MIME type. M +109 -0 autotests/kurlrequestertest.cpp M +1 -1 src/widgets/CMakeLists.txt M +62 -7 src/widgets/kurlrequester.cpp M +39 -1 src/widgets/kurlrequester.h https://invent.kde.org/frameworks/kio/-/commit/8a1cc098cec9937bb11206f555a9bb978fbaf981