Bug 481287 - Name filters don't work with native KF6 file dialog
Summary: Name filters don't work with native KF6 file dialog
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Open/save dialogs (show other bugs)
Version: git master
Platform: Neon Linux
: NOR major
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2024-02-13 11:05 UTC by Michael Weghorn
Modified: 2024-05-17 07:45 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Sample program to reproduce the bug (625 bytes, text/x-c++src)
2024-02-13 11:05 UTC, Michael Weghorn
Details
qmake .pro project file for the sample program (510 bytes, application/vnd.nokia.qt.qmakeprofile)
2024-03-11 11:03 UTC, Michael Weghorn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Weghorn 2024-02-13 11:05:33 UTC
Created attachment 165804 [details]
Sample program to reproduce the bug

SUMMARY

QFileDialog allows the use of named filters, e.g. QFileDialog::setNameFilters to set filters and QFileDialog::selectedNameFilter to retrieve the currently selected filter.

However, QFileDialog::selectedNameFilter currently always returns an empty string instead of the actually selected filter when using the native implementation on KF6.
The KF5 one works as expected.

STEPS TO REPRODUCE
1. compile attached sample program main.cpp with Qt 6 and run it on KDE Plasma 6
2. in the native file dialog that shows up, select a file that matches the file pattern (e.g. the file main.cpp itself)
3. click "Open"
4. check the output on stderr

OBSERVED RESULT

The returned filter is empty:

> selected filter:  ""

EXPECTED RESULT

The actually selected filter should be returned:

> selected filter:  "All C++ files (*.cpp *.cc *.C *.cxx *.c++)"

This works as expected when building against Qt 5 instead (so that the KF 5 version is used) or explicitly disabling the use of the native KF 6 implementation by setting the QFileDialog::DontUseNativeDialog option on the dialog (s. line 15 in the sample program, recompile with that line uncommented to make it work).

SOFTWARE/OS VERSIONS
Operating System: KDE neon Unstable Edition
KDE Plasma Version: 6.0.80
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.1
Kernel Version: 6.5.0-17-generic (64-bit)
Graphics Platform: X11
Processors: 4 × Intel® Core™ i7-8850H CPU @ 2.60GHz
Memory: 11,4 GiB of RAM
Graphics Processor: llvmpipe
Manufacturer: QEMU
Product Name: Standard PC (Q35 + ICH9, 2009)
System Version: pc-q35-7.2

ADDITIONAL INFORMATION

This bug breaks saving files in LibreOffice when using the kf6 integration and was originally reported there:
https://bugs.documentfoundation.org/show_bug.cgi?id=159701
Comment 1 Bug Janitor Service 2024-02-16 14:04:55 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-integration/-/merge_requests/137
Comment 2 Nicolas Fella 2024-02-19 08:51:29 UTC
Git commit 8944e255e4dcd41279c2bd04432d5a933fb0823f by Nicolas Fella.
Committed on 19/02/2024 at 08:48.
Pushed by nicolasfella into branch 'master'.

Fix KDEPlatformFileDialogHelper::selectedNameFilter

Directly return dialog->selectedNameFilter instead of the current nonsense

M  +5    -19   qt6/src/platformtheme/kdeplatformfiledialoghelper.cpp

https://invent.kde.org/plasma/plasma-integration/-/commit/8944e255e4dcd41279c2bd04432d5a933fb0823f
Comment 3 Nicolas Fella 2024-02-19 08:52:22 UTC
Git commit 9abb182f75c99d4e6b1460c18bbfec13be1811fa by Nicolas Fella.
Committed on 19/02/2024 at 08:52.
Pushed by nicolasfella into branch 'Plasma/6.0'.

Fix KDEPlatformFileDialogHelper::selectedNameFilter

Directly return dialog->selectedNameFilter instead of the current nonsense
(cherry picked from commit 8944e255e4dcd41279c2bd04432d5a933fb0823f)

M  +5    -19   qt6/src/platformtheme/kdeplatformfiledialoghelper.cpp

https://invent.kde.org/plasma/plasma-integration/-/commit/9abb182f75c99d4e6b1460c18bbfec13be1811fa
Comment 4 Michael Weghorn 2024-02-20 15:10:09 UTC
Thanks a lot for the fix!

I can confirm that both, the attached sample program and the LibreOffice use case work fine for me on a KDE Neon unstable updated today.
Comment 5 Andreas Sturmlechner 2024-02-27 13:52:53 UTC
As mentioned in the linked MR[1] unfortunately this is still not fixed on my system.

1. run localc
2. Ctrl + Shift + S (or File -> Save As)
3. (Enter random name) Save

File dialog reappears every time instead of saving the file.


Operating System: Gentoo 2.14
KDE Plasma Version: 6.0.0
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.6.17-gentoo (64-bit)
Graphics Platform: Wayland
Processors: 32 × AMD Ryzen 9 5950X 16-Core Processor
Memory: 62,7 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Product Name: X570 Phantom Gaming-ITX/TB3

Version: 24.2.1.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 32; OS: Linux 6.6; UI render: default; VCL: kf6 (cairo+wayland)
Locale: de-AT (de_AT.UTF-8); UI: en-US
Gentoo official package
Calc: threaded

[1] https://invent.kde.org/plasma/plasma-integration/-/merge_requests/137
Comment 6 Andreas Sturmlechner 2024-02-27 14:24:34 UTC
Works fine if started with SAL_USE_VCLPLUGIN=qt6 instead.
Comment 7 Michael Weghorn 2024-02-27 18:51:42 UTC
(In reply to Andreas Sturmlechner from comment #5)
> As mentioned in the linked MR[1] unfortunately this is still not fixed on my
> system.
> 
> 1. run localc
> 2. Ctrl + Shift + S (or File -> Save As)
> 3. (Enter random name) Save
> 
> File dialog reappears every time instead of saving the file.

This works fine for me in a KDE Neon unstable VM and a local build of LibreOffice master (but should presumably be the same with LO 24.2 instead).

Does the sample program from this bug report work for you?
Comment 8 ariasuni 2024-03-08 16:52:38 UTC
I and other people have this bug on Arch Linux:
https://bbs.archlinux.org/viewtopic.php?id=293552

It works if I use `SAL_USE_VCLPLUGIN=kf5` for example.

I can’t compile the sample program to test the result, g++ can’t find `QApplication`, so I suppose I need more setup.

---

Operating System: Arch Linux 
KDE Plasma Version: 6.0.1
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.7.8-zen1-1-zen (64-bit)
Graphics Platform: X11

LibreOffice
Version: 24.2.1.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 8; OS: Linux 6.7; UI render: default; VCL: kf6 (cairo+xcb)
Locale: fr-FR (fr_FR.UTF-8); UI: fr-FR
24.2.1-1
Calc: threaded
Comment 9 Michael Weghorn 2024-03-11 11:03:05 UTC
Created attachment 166947 [details]
qmake .pro project file for the sample program
Comment 10 Michael Weghorn 2024-03-11 11:07:14 UTC
(In reply to ariasuni from comment #8)
> I can’t compile the sample program to test the result, g++ can’t find
> `QApplication`, so I suppose I need more setup.

I've added a .pro file for qmake as attachment 166947 [details].

This should work to compile the sample program:

1) place the .pro and the C++ file (both attachments from this bug report) into the same directory
2) in terminal, from within the directory containing both files:
    * run `qmake6` (or whatever the path to the Qt 6 qmake is for your distro)
    * run `make`
3) run the sample program: `./qfiledialog`

If you place this together with the sample program in the same directory, and run `qmake6` (or whatever the path to your
Comment 11 Michael Weghorn 2024-03-11 11:09:05 UTC
(In reply to Michael Weghorn from comment #10)
> (In reply to ariasuni from comment #8)
> This should work to compile the sample program:
> 
> (...)
> 
> If you place this together with the sample program in the same directory,
> and run `qmake6` (or whatever the path to your

Please ignore that last and incomplete sentence. It doesn't add to the steps already mentioned above it, I just forgot to remove it.
Comment 12 Andreas Sturmlechner 2024-03-11 11:15:25 UTC
This works, but it is testing file open - which works fine in LO calc for me as well, not save though (currently on 24.2.2.1).
Comment 13 Michael Weghorn 2024-03-11 15:59:22 UTC
(In reply to Andreas Sturmlechner from comment #12)
> This works, but it is testing file open - which works fine in LO calc for me
> as well, not save though (currently on 24.2.2.1).

It's unclear to me why that should make a difference and saving from LO Calc works OK for me on KDE Neon unstable (see comment 7).

How can I reproduce your scenario? Is this just setting up a Gentoo VM, install LO and KDE Plasma 6 and start LO there or are more steps needed?
Comment 14 Buovjaga 2024-03-12 08:35:38 UTC
Saving with kf6 + Wayland *only works from Writer*. With the other apps the save dialog acts like in comment 5. 

Arch Linux
Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 173bf8bf8b8e485691f8f0b4b33da0a139babc34
CPU threads: 8; OS: Linux 6.7; UI render: default; VCL: kf6 (cairo+wayland)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Comment 15 Andreas Sturmlechner 2024-03-12 08:55:40 UTC
(In reply to Michael Weghorn from comment #13)
> How can I reproduce your scenario? Is this just setting up a Gentoo VM,
> install LO and KDE Plasma 6 and start LO there or are more steps needed?
That would be essentially it, but if Arch Linux users can reproduce it then presumably that will get you there faster (with less compile time since none of the packages involved are currently stable hence not available as Gentoo binary packages).
Comment 16 Antonio Rojas 2024-03-12 08:57:55 UTC
(In reply to Andreas Sturmlechner from comment #15)
> (In reply to Michael Weghorn from comment #13)
> > How can I reproduce your scenario? Is this just setting up a Gentoo VM,
> > install LO and KDE Plasma 6 and start LO there or are more steps needed?
> That would be essentially it, but if Arch Linux users can reproduce it then
> presumably that will get you there faster (with less compile time since none
> of the packages involved are currently stable hence not available as Gentoo
> binary packages).

Arch has now disabled the KF6 libreoffice integration to prevent this.
Comment 17 Michael Weghorn 2024-03-12 09:51:28 UTC
(In reply to Michael Weghorn from comment #7)
> This works fine for me in a KDE Neon unstable VM and a local build of
> LibreOffice master (but should presumably be the same with LO 24.2 instead).

Sorry, my bad.
That local LO build of mine had local changes I had used to track down the issue fixed in the context of this bug report.
I can reproduce the LO scenario after undoing those local changes, so there's apparently another issue either on LO or on KF6 side.

I've reopened https://bugs.documentfoundation.org/show_bug.cgi?id=159701 for now to keep track of this.

Closing the issue here again, as that one *is* fixed.
Comment 18 Michael Weghorn 2024-03-12 15:19:34 UTC
(In reply to Michael Weghorn from comment #17)

> I can reproduce the LO scenario after undoing those local changes, so
> there's apparently another issue either on LO or on KF6 side.
> 
> I've reopened https://bugs.documentfoundation.org/show_bug.cgi?id=159701 for
> now to keep track of this.

Looks like another KF6 issue to me, so I've created another bug report + MR with a suggested fix:
bug 483350
https://invent.kde.org/plasma/plasma-integration/-/merge_requests/140