Bug 501743

Summary: Open and save dialogs always set preview to false at startup
Product: [Frameworks and Libraries] frameworks-kio Reporter: Akseli Lahtinen <akselmo>
Component: Open/save dialogsAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kdedev, kdelibs-bugs-null, nate
Priority: NOR    
Version First Reported In: git master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Akseli Lahtinen 2025-03-19 13:58:07 UTC
SUMMARY
When opening open-save dialog, the `KFilePreviewGenerator *pg = d->m_ops->previewGenerator();` initialization disables preview images due to invalid iconSize: 
```
    if (!m_viewAdapter->iconSize().isValid()) {
        m_previewShown = false;
    }
```

STEPS TO REPRODUCE
1. Save any file in Kate etc.
2. Enable the preview button
3. Save or cancel
4. Open the dialog again

OBSERVED RESULT
Preview is turned off.

EXPECTED RESULT
Preview would save it's state.

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 41
KDE Plasma Version: 6.3.80
KDE Frameworks Version: 6.13.0
Qt Version: 6.8.2
Kernel Version: 6.13.6-200.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 3600 6-Core Processor
Memory: 16 GiB of RAM (15.5 GiB usable)
Graphics Processor: AMD Radeon RX 6600

ADDITIONAL INFORMATION
Unsure why this fails to get the iconSize.
Comment 1 Nate Graham 2025-03-19 14:25:35 UTC
On your system, what's the value of `m_viewAdapter->iconSize()` when this happens?
Comment 2 Akseli Lahtinen 2025-03-19 22:00:13 UTC
It's QIcon(-1,-1)
Comment 3 Akseli Lahtinen 2025-03-19 22:00:45 UTC
typo, its QSize(-1,-1)
Comment 4 TraceyC 2025-03-20 16:33:13 UTC
I'm not able to reproduce this with Kate built from and run from master

1. Create a new file in Kate. Open the Save As dialog
2. Enable the preview button
3. Save or cancel
4. Open the dialog again

The preview button is still shown, and I still see file previews
Note that the view is Details View on my system, but I tested Icon and Compact as well, and couldn't reproduce with those either
Comment 5 Nate Graham 2025-03-21 16:58:35 UTC
How did it get an invalid QSize? What does `grep -r IconSize ~/.config/kdeglobals` say?
Comment 6 Akseli Lahtinen 2025-03-21 19:57:23 UTC
(In reply to Nate Graham from comment #5)
> How did it get an invalid QSize? What does `grep -r IconSize
> ~/.config/kdeglobals` say?

Replies empty. Seems i dont have IconSize text there.
Comment 7 Nate Graham 2025-03-21 20:13:13 UTC
Which would imply the icon sizes are at their default values, which would imply the fallback value for this use case is broken.

Does it stop happening if you change the icon size of the current view and close and re-open the dialog?
Comment 8 Akseli Lahtinen 2025-03-24 10:01:19 UTC
Nope, the config is still empty too.
Comment 9 Akseli Lahtinen 2025-03-24 10:02:24 UTC
Not whole config, just the IconSize grep
Comment 10 Nate Graham 2025-03-25 22:34:18 UTC
So changing the icon size doesn't write anything to the config file. That seems like a bug too.
Comment 11 Bug Janitor Service 2025-03-27 15:12:09 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1851
Comment 12 Akseli Lahtinen 2025-03-28 15:56:04 UTC
Git commit e482885ba1ed4d89862821764207c72e4e1833a5 by Akseli Lahtinen.
Committed on 28/03/2025 at 15:56.
Pushed by akselmo into branch 'master'.

KFileWidget and KDirOperator: Fix saving and loading preview settings

KDirOperator would load the iconSize after creating previewGenerator, which asks the iconSize from KDirOperator. This would make the iconSize always be invalid in previewGenerator.

KFileWidget would additionally toggle the action again, regardless of what the user setting is. It's better
just to explicitly follow what the user setting is and toggle the button accordingly. The previewGenerator value would always override what the user value is otherwise.

M  +49   -0    autotests/kfilewidgettest.cpp
M  +1    -1    src/filewidgets/kdiroperator.cpp
M  +0    -5    src/filewidgets/kfilewidget.cpp

https://invent.kde.org/frameworks/kio/-/commit/e482885ba1ed4d89862821764207c72e4e1833a5