Bug 319502 - Kdialog returns wrong filter
Summary: Kdialog returns wrong filter
Status: CONFIRMED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Open/save dialogs (show other bugs)
Version: 5.54.0
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL: http://pastebin.com/UxNhi88F
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-08 04:43 UTC by Rustam Safin
Modified: 2019-02-15 01:26 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Attaching the file from the pastebin in case the pastebin get deleted (411 bytes, text/plain)
2013-05-10 12:22 UTC, Shlomi Fish
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rustam Safin 2013-05-08 04:43:42 UTC
KDialog return wrong filter if filters have same mask e.g. ("All files (*.*)", "Files (*.*)", "Another files (*.*)")

Reproducible: Always

Steps to Reproduce:
1. Run this python script http://pastebin.com/UxNhi88F
2. Select "Images" filter
3. Select some file

Actual Results:  
(PyQt4.QtCore.QString(u'/home/snegovik/Pictures/the_bitter_end_by_fallenzeraphine-d53j4k7.png'), PyQt4.QtCore.QString(u'All files (*.*)'))

Expected Results:  
(PyQt4.QtCore.QString(u'/home/snegovik/Pictures/the_bitter_end_by_fallenzeraphine-d53j4k7.png'), PyQt4.QtCore.QString(u'Images (*.*)'))

Qt: 4.8.3
PyQt: 4.9.3
KDE Development Platform: 4.10.2
KDialog: 1.0
Comment 1 Christoph Feck 2013-05-08 10:13:39 UTC
Can you clarify why you see this as a KDE bug? Your attached sample only uses QFileDialog.
Comment 2 Rustam Safin 2013-05-08 12:20:09 UTC
If you read http://qt-project.org/doc/qt-4.8/qfiledialog.html you will see:
"The easiest way to create a QFileDialog is to use the static functions. On Windows, Mac OS X, KDE and GNOME, these static functions will call the native file dialog when possible."

If you will run code above in Gnome DE it will run Gnome's own file dialog that return correct filter rather than in KDE.
Comment 3 Shlomi Fish 2013-05-10 12:22:18 UTC
Created attachment 79810 [details]
Attaching the file from the pastebin in case the pastebin get deleted

I can reproduce this here. I get the wrong filter.
Comment 4 Andrew Crouthamel 2018-11-10 03:14:58 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 5 Andrew Crouthamel 2018-11-20 04:11:03 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? This bug will be moved back to REPORTED Status for manual review later, which may take a while. If you are able to, please lend us a hand.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Peter Wu 2019-02-15 01:26:08 UTC
This is still a problem with kio 5.54 / Qt 5.12.0 / Arch Linux. The important details are:

- Two files have the same mask.
- The mask is changed by the user before accepting the dialog.

The KFileDialog class that is used by plasma-integration does not seem to respect the selected filter. Instead of reporting the actual selected filter, it seems to query for the first filter that has the same mask. The non-native Qt dialog does *not* have this problem.

import sys
from PyQt5.QtWidgets import QApplication, QFileDialog

app = QApplication(sys.argv)
filter = 'All Files (*.*);;Image (*.*);;Thing (*.txt)'
options = QFileDialog.Option(0)
#options = QFileDialog.DontUseNativeDialog
name, newfilter = QFileDialog.getSaveFileName(None, "Title", "", filter, "", options)
print(name, newfilter)


Steps to reproduce:
0. Run the above Python script.
1. Enter any file name
2. Set filter to "Image"
3. Press OK.

Expected results:
Print the file name and "Image"

Actual results:
Print the filename and the first filter ("All Files").