Bug 406464 - Unexpected folder selection in native QFileDialog
Summary: Unexpected folder selection in native QFileDialog
Status: RESOLVED WORKSFORME
Alias: None
Product: plasma-integration
Classification: Plasma
Component: general (show other bugs)
Version: 5.14.5
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-12 11:05 UTC by Michael Weghorn
Modified: 2021-09-03 11:35 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Sample program that opens QFileDialog to select directory (414 bytes, text/x-c++src)
2019-04-12 11:05 UTC, Michael Weghorn
Details
screenshot with native Plasma file dialog (30.31 KB, image/png)
2019-04-12 11:06 UTC, Michael Weghorn
Details
screenshot of non-native QFileDialog (24.27 KB, image/png)
2019-04-12 11:06 UTC, Michael Weghorn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Weghorn 2019-04-12 11:05:48 UTC
Created attachment 119370 [details]
Sample program that opens QFileDialog to select directory

SUMMARY

When using the native Plasma file dialog to select a directory, clicking on a directory and confirming will not select the selected directory, but the "base directory" currently shown in the dialog.


STEPS TO REPRODUCE
1. create test directories: 'mkdir /tmp/testdir/subdir'
2. compile attached sample program ("main.cpp") that opens a file dialog to select a directory
3. start the program
4. navigate into directory "/tmp/testdir"
5. click on directory "subdir"
6. click the "Open" button
  -> dialog closes
7. check what directory has been selected (printed on stdout for the sample program) 

OBSERVED RESULT

The folder "/tmp/testdir/" has been selected.


EXPECTED RESULT

Expected result: The folder "/tmp/testdir/subdir" should be selected.


SOFTWARE/OS VERSIONS
Debian 

Operating System: Debian GNU/Linux testing (with plasma-integration 5.14.5-1, libkf5kiowidgets5 5.54.1-1)
KDE Plasma Version: 5.14.5
Qt Version: 5.11.3
KDE Frameworks Version: 5.54.0
Kernel Version: 4.19.0-4-amd64
OS Type: 64-bit


ADDITIONAL INFORMATION

* The non-native QFileDialog behaves as expected, which can be tested by forcing QFileDialog to use non-native mode (s. line 11, currently commented out). When clicking a directory, it updates that shown path accordingly and the test program prints the path after clicking the "Choose" button.
* The attached screenshots show the native and non-native dialogs at the point in time the corresponding buttons are clicked.
* The Qt documentation for QFileDialog ([1]) mentions: "Returns a list of strings containing the absolute paths of the selected files in the dialog. If no files are selected, or the mode is not ExistingFiles or ExistingFile, selectedFiles() contains the current path in the viewport." -- I don't thinks this describes what happens here, though.
* Commenting out 'dialog.setFileMode(QFileDialog::FileMode::Directory);' in line 12 in the sample program makes the QFileDialog behave as expected. However, that will make folder selection impossible with the non-native QFileDialog (so behaviour differs here as well).

[1] https://doc.qt.io/qt-5/qfiledialog.html#selectedFiles
Comment 1 Michael Weghorn 2019-04-12 11:06:20 UTC
Created attachment 119371 [details]
screenshot with native Plasma file dialog
Comment 2 Michael Weghorn 2019-04-12 11:06:53 UTC
Created attachment 119372 [details]
screenshot of non-native QFileDialog
Comment 3 Michael Weghorn 2021-09-03 11:35:22 UTC
This works as expected now after upgrading from Debian bullseye to bookworm (current testing) which also has newer versions of the Plasma/kf5 packages, e.g.

* plasma-integration/testing,now 5.21.5-2
* libkf5kiocore5/testing,now 5.83.0-2

-> closing as WORKSFORME

(This may or may not be related to the fix for bug 419874, I didn't take a closer look.)