Skip to content

DiscoverObject: Use KConfig.WindowStateSaver to handle window sizing

Fixes: https://bugs.kde.org/show_bug.cgi?id=492229

This MR uses the KConfig.WindowStateSaver, as recommended by Nate Graham in Bug 492229. Other KDE applications appear to be using this are planning to use this, such as NeoChat and Tokodon, or are already using it, such as Filelight. To my understanding this is a new addition, and so the minimum KFrameworks version has been bumped to 6.5.0.

In doing this we fix the linked bug, which has a problem where Discover stores the maximized window geometry on exit, resulting in a problem where if you close Discover, re-open it, and un-maximize it, it will use the maximized geometry. Using KConfig.WindowStateSaver fixes the bug by not storing the window geometry in the discoverrc file, and instead lets KConfig.WindowStateSaver handle that, and it handles it correctly.


With this change we can get rid of the code that handles window geometry, however I kept the code handling the visibility key which corresponds to window maximization. This is because currently window maximization is not handled by WindowStateSaver although I believe this is planned to be fixed. If it is wanted we can remove the visibility code as well in this MR and wait for the fix on the WindowStateSaver side, although I imagine that would warrant another bump of the minimum KFrameworks version, perhaps to something like 6.5.1? Unsure of the best way to handle that. 😀

Note: One problem introduced with this change is that window positioning appears to be forgotten if you maximize -> close -> re-open -> un-maximize, Discover will un-maximize in the top left of the display (I am unsure how this behaves on multi-screen, if it goes to the top-left of the display it was un-maximized on or to 0,0 of, say, the primary display). However this appears to affect many other KDE applications as well, such as Dolphin, Konsole, and Kate. Perhaps it is something related to KConfig.WindowStateSaver?


I am not very experienced with C++, Qt, or the KDE Frameworks, so please let me know if I did anything wrong in this MR. I will gladly make any adjustments or, if the fix is so egregiously incorrect, I can open a new MR (although I hope that is not the case!)

Thanks!

Edited by Eamonn Rea

Merge request reports