Bug 488597

Summary: Weird widget behavior
Product: [Applications] kgeotag Reporter: 2tefan <me>
Component: GeneralAssignee: Tobias Leupold <tl>
Status: RESOLVED UPSTREAM    
Severity: normal CC: tl
Priority: NOR    
Version: 1.5.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description 2tefan 2024-06-16 18:45:41 UTC
# SUMMARY
When poping out a widget (make it to its own floating window) and then closing it. I am unable to get the widget back.

STEPS TO REPRODUCE
1. Make a widget float, for example Map (press the little pop out button in the top right of every widget)
2. Close the floating widget with a hotkey, such as ALT+F4 (depending on your window manager/desktop environment)
3. Now you can't get this widget back. Even a restart restores the old layout and leaves the widget missing.

OBSERVED RESULT
Also, when right-clicking on the menu bar, it's shown, that a widget is missing, such as the map. But everything is disabled, so you can't make the widget visible again. The only workaround so far is to edit `$XDG_CONFIG_HOME/kgeotagrc` (normally ~/.config/kgeotagrc) and removing `windowState` under `[main]`.

EXPECTED RESULT
It would be nice, to either disable the possibility of removing widget, so ALT+F4 does not do anything on widgets or just moves them back to the main window. Or, it would be nice to enable removed widgets again via the menu bar.


SOFTWARE/OS VERSIONS
Distro: Arch Linux
Linux: 6.9.4-zen1-1-zen
Qt Version: 6.7.1

and

Distro: Ubuntu 22.04 LTS
Linux: 6.5.0-35-generic
Qt version: 5.15.3

(happens on both of them)

ADDITIONAL INFORMATION
If I add the following feature to the widgets: `QDockWidget::DockWidgetClosable`, then it's possible to recover a lost widget via the menu bar on top of the main window.
Comment 1 Tobias Leupold 2024-06-17 07:49:45 UTC
Hi, thanks for your report!

The docks shouldn't be closable in the first place ... at least, it's not possible to close them via mouse click (the features set are "QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable", so QDockWidget::DockWidgetClosable is not enabled).

If you can close such a floating dock nevertheless, this maybe depends on the window manager and I can't fix or prevent this at all (I think I can't do more than define that the docks are not closable) ... I'll have to investigate this.

As a workaround, you should be able to recover all docks and their default position via "Settings" → "Set default dock arrangement".

About the kgeotagrc: Current git master now uses KMainWindow's state instead of saving the state twice, so the state is now MainWindow/State. However, there will be a (now unused) main/windowState entry. Maybe, I'll add a quick check to remove this key later on to prevent confusion.
Comment 2 Tobias Leupold 2024-06-17 09:51:16 UTC
Git commit 2d298421ab3f4d4f8c9e39f33e4f95ac3a4b7f92 by Tobias Leupold.
Committed on 17/06/2024 at 09:50.
Pushed by tleupold into branch 'master'.

Be sure to actually show all docks when settuing the default arrangement

M  +5    -0    src/MainWindow.cpp

https://invent.kde.org/graphics/kgeotag/-/commit/2d298421ab3f4d4f8c9e39f33e4f95ac3a4b7f92
Comment 3 Tobias Leupold 2024-06-17 09:53:08 UTC
Okay, this at least ensures that a closed dock widget is shown again when applying the default dock arrangement.

However, I think this is an upstream bug: The dock widget should not be closable in the first place. I'll file an according kwin bug.
Comment 4 Tobias Leupold 2024-06-17 10:23:42 UTC
FYI: I just filed Bug #488616 about this.

I think I'll try to work around this by using a QDockWidget subclass that catches the QCloseEvent that should be ignored. I'm not sure if I can detect if the dock is closed because the program is quit or by using a shortcut to close it, but let's see.

However, recovering such a closed dock is now possible by setting the default dock arrangement, so at least, we have a workaround.
Comment 5 2tefan 2024-06-17 16:35:36 UTC
Hi, wow, thanks for the quick response!

I have no experience with QT, but I suspected, that you explicitly left out `QDockWidget::DockWidgetClosable`, so it's not possible to close those widgets, I just wanted to add it as a workaround :)

Also, thanks for the quick fix with the `Set default dock arrangement` button, that works great!

Finally, thanks for filing those bug reports upstream, I am just amazed by how quickly everything went. Thanks for all the help!! Let's see where https://bugreports.qt.io/browse/QTBUG-126418 gets us :)
Comment 6 Tobias Leupold 2024-06-17 17:38:50 UTC
You're welcome :-) The fact that the Qt guys already triaged this as "important" is maybe a good sign.

I think I'll wait what they say. If this is fixed upstream, there's no need to implement a workaround. And for accidental closing of floating docks, we now have the "default arrangement" workaround to get them back.

Well, let's see …

I think I'll let this bug open as a reminder to check what upstream does now and then …
Comment 7 Tobias Leupold 2024-09-27 20:50:01 UTC
Closing this as it's actually an upstream bug and we at least have a workaround.