Fix zoom slider toolbuttons not disabling properly
ClosedPublic

Authored by rkflx on Oct 10 2017, 8:36 PM.

Details

Summary

Moving the zoom slider should disable the zoom buttons next to it when
reaching the maximum or minimum value respectively, but this was only
the case when changing sliding direction again. This lag is caused by
the SignalBlocker in ZoomWidget::setZoom used to enable a smoother
scroll, but disabling synchronisation of QSlider::sliderPosition and
QSlider::value at the same time. The fix is inspired by 84910f85152f.

In addition, when resizing the window in "Fit" zoom mode, the button to
zoom out would not get disabled, even though "Fit" is the minimum zoom
level. This is caused by calculating the minimum zoom in
updateZoomSnapValues based on the old window geometry. Therefore,
updateZoomSnapValues should be called only after
resizeAdapterWidget.

Note: Compared to a similar approach in D7972#152758, we avoid calling
resizeAdapterWidget unnecessarily and also stop resizeAdapterWidget
and setGeometry calling each other in a potentially infinite loop.
Trying to move updateZoomSnapValues inside of resizeAdapterWidget
sadly breaks the zoom slider when advancing to the next image.

Depends on D7972.

Test Plan

Tried various combinations of zoom (Fit, slider, keyboard) and view
modes (browse, view single image, compare images, thumbnails, birds eye
view) while resizing the window and switching between images.
Toolbuttons get disabled as they should and no (new) bugs were observed.
Nevertheless please test carefully, as this part of the code base is
quite complex.

Diff Detail

Repository
R260 Gwenview
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
rkflx created this revision.Oct 10 2017, 8:36 PM
ngraham accepted this revision.Oct 14 2017, 5:14 PM

This works great. Let's get it in once I land D7972 tomorrow, if @gateau doesn't object in that time.

This revision is now accepted and ready to land.Oct 14 2017, 5:14 PM
gateau accepted this revision.Oct 15 2017, 11:13 AM
This revision was automatically updated to reflect the committed changes.