Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1069882e authored by Henrik Fehlauer's avatar Henrik Fehlauer

Fix zoom slider toolbuttons not disabling properly

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 84910f85.

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.

Reviewers: #kde_applications, ngraham, vtasoulas, gateau

Reviewed By: ngraham, gateau

Differential Revision: https://phabricator.kde.org/D8241
parent e014d581
......@@ -578,6 +578,7 @@ qreal DocumentView::zoom() const
void DocumentView::resizeEvent(QGraphicsSceneResizeEvent *event)
{
d->resizeAdapterWidget();
d->updateZoomSnapValues();
QGraphicsWidget::resizeEvent(event);
}
......@@ -667,7 +668,6 @@ qreal DocumentView::minimumZoom() const
void DocumentView::setCompareMode(bool compare)
{
d->mCompareMode = compare;
d->resizeAdapterWidget();
if (compare) {
d->mHud->show();
d->mHud->setZValue(1);
......@@ -729,7 +729,6 @@ void DocumentView::emitFocused()
void DocumentView::setGeometry(const QRectF& rect)
{
QGraphicsWidget::setGeometry(rect);
d->resizeAdapterWidget();
if (d->mBirdEyeView) {
d->mBirdEyeView->slotZoomOrSizeChanged();
}
......
......@@ -45,8 +45,11 @@ struct ZoomSliderPrivate
void updateButtons()
{
mZoomOutButton->setEnabled(mSlider->value() > mSlider->minimum());
mZoomInButton->setEnabled(mSlider->value() < mSlider->maximum());
// Use QSlider::sliderPosition(), not QSlider::value() because when we are
// called from slotZoomSliderActionTriggered(), QSlider::value() has not
// been updated yet.
mZoomOutButton->setEnabled(mSlider->sliderPosition() > mSlider->minimum());
mZoomInButton->setEnabled(mSlider->sliderPosition() < mSlider->maximum());
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment