KFileWidget: Prevent places panel width from growing 1px iteratively

Authored by rkflx on Apr 29 2018, 6:10 AM.



cc00bbb22010 tried to prevent the places panel from reopening with a
width reduced by 1px compared to the previous invocation of the file

While the patch worked on the surface when it was applied, the actual
reasoning was wrong: The difference was not because of "extra resize()
events", but because of a mismatch between what was read from the config
(placesViewWidth) and what was written to the config (sizes[0]).

The actual reason placesViewWidth and sizes[0] are different is
because of a previous error: It is assumed that the splitter sizes sum
up to availableWidth, while in reality this width also contains the
width of the splitter handle. Upon setSizes, Qt equally takes away
width from both sides of the splitter to make everything fit.

While for the Oxygen and Fusion styles (3px and 4px splitter handle
width, respectively) an adjustment of 1px did the trick, for Breeze with
its splitter handle width of only 1px this did not work anymore due to
rounding errors, it resulted in the config entry incrementing by 1px for
every invocation of the dialog.

To fix the problem for every style, we simply take the width of the
splitter handle into account and revert the previous fix. While we are
at it, we refactor to make everything more DRY.

Ref T8552

FIXED-IN: 5.46

Test Plan

Setup monitoring with watch grep Speedbar ~/.config/kdeglobals.
Repeatedly open kdialog --getopenfilename, click on Cancel and
check that the config entry does not change. Test for multiple widget
styles (e.g. Breeze, Oxygen, Windows and Fusion), as well as for hiding
the places panel and manually moving the splitter to both ends.

Diff Detail

R241 KIO
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
rkflx created this revision.Apr 29 2018, 6:10 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptApr 29 2018, 6:10 AM
rkflx added a comment.Apr 29 2018, 6:16 AM

Sorry for the wait, writing the commit message for this one and the alignment patch meant going through a lot of notes. Who'd knew that after the off-by-one error in Spectacle which only happened in a VM there could be even more difficult problems :D

Wow, excellent analysis.


ngraham accepted this revision.Apr 29 2018, 10:33 PM
ngraham added a subscriber: ngraham.

Indeed, very nice!

This revision is now accepted and ready to land.Apr 29 2018, 10:33 PM
This revision was automatically updated to reflect the committed changes.