Bug 387481 - Save file dialog doesn't return selected filter properly
Summary: Save file dialog doesn't return selected filter properly
Status: CONFIRMED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Open/save dialogs (other bugs)
Version First Reported In: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-30 21:18 UTC by Alexander
Modified: 2024-06-27 20:04 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2017-11-30 21:18:21 UTC
I'm using plain Qt5 applications and since I'm running Plasma, KDE dialogs  automatically replace Qt's built-in dialogs.

The problem is with the Save dialog (QFileDialog::getSaveFileName()).
If the "filter" parameter contains 2 filters with the same extensions, the "selectedFilter" parameter is always set to the first one, no matter which one the user selected.

Example code:
--------------------------
QString selectedFilter;
QString fileName = QFileDialog::getSaveFileName(this,
      "QFileDialog::getSaveFileName()",
      "hello.txt",
      "All Files (*);;UTF-16 Files (*.txt);;UTF-8 Files (*.txt)",
      &selectedFilter);
qWarning() << "selectedFilter: " << selectedFilter;
--------------------------

If the user selects "UTF-8 Files (*.txt)", "UTF-16 Files (*.txt)" is printed instead.

Qt's built-in dialog don't have this problem.

Thanks
Comment 1 Benito van der Zander 2018-05-10 16:44:34 UTC
I have a similar problem. The KDE file dialog always choose the first extension filter, but apparently also  when the extensions are different.


When you save a webpage in Firefox, you can choose to save it as "webpage  complete"  or "webpage html only", and it always choose the first entry in the list "webpage complete". Firefox had an option to use their own xul dialog rather than the kde dialog, but it seems they have removed that option.

Then in TeXstudio you can save a file as .tex file or with another file extension (e.g. plaintext (*.txt) or all files (*)), but the QFileDialog  always switches back to .tex files when saving another file. Only the QFileDialog::DontUseNativeDialog fixes this.