Commit c399a110 authored by David Hurka's avatar David Hurka 🐬 Committed by Nate Graham
Browse files

Fix Page Up/Down scrolling when scrollbars are turned off

PageView::slotScrollUp/Down() queried the size of the scrollbar instead of the viewport,
which has no obvious reason and doesn’t work when scrollbars are not there.

Probably the scrollbar size was thought to be more robust
in times when PageView had overshoot enabled.

Also fixes code documentation for these methods,
and removes another spaghetti feature where Continuous mode was queried
in an `if` branch before the one where it is relevant.

BUG: 421822
parent 1047fd1d
Pipeline #71490 passed with stage
in 27 minutes and 5 seconds
......@@ -4901,16 +4901,16 @@ void PageView::slotAutoScrollDown()
void PageView::slotScrollUp(int nSteps)
{
// if in single page mode and at the top of the screen, go to \ page
if (getContinuousMode() || verticalScrollBar()->value() > verticalScrollBar()->minimum()) {
if (verticalScrollBar()->value() > verticalScrollBar()->minimum()) {
if (nSteps) {
d->scroller->scrollTo(d->scroller->finalPosition() + QPoint(0, -100 * nSteps), d->currentShortScrollDuration);
} else {
if (d->scroller->finalPosition().y() > verticalScrollBar()->minimum())
d->scroller->scrollTo(d->scroller->finalPosition() + QPoint(0, -(1 - Okular::Settings::scrollOverlap() / 100.0) * verticalScrollBar()->rect().height()), d->currentLongScrollDuration);
d->scroller->scrollTo(d->scroller->finalPosition() + QPoint(0, -(1 - Okular::Settings::scrollOverlap() / 100.0) * viewport()->height()), d->currentLongScrollDuration);
}
} else if (d->document->currentPage() > 0) {
// more optimized than document->setPrevPage and then move view to bottom
} else if (!getContinuousMode() && d->document->currentPage() > 0) {
// Since we are in single page mode and at the top of the page, go to previous page.
// setViewport() is more optimized than document->setPrevPage and then move view to bottom.
Okular::DocumentViewport newViewport = d->document->viewport();
newViewport.pageNumber -= viewColumns();
if (newViewport.pageNumber < 0)
......@@ -4923,16 +4923,16 @@ void PageView::slotScrollUp(int nSteps)
void PageView::slotScrollDown(int nSteps)
{
// if in single page mode and at the bottom of the screen, go to next page
if (getContinuousMode() || verticalScrollBar()->value() < verticalScrollBar()->maximum()) {
if (verticalScrollBar()->value() < verticalScrollBar()->maximum()) {
if (nSteps) {
d->scroller->scrollTo(d->scroller->finalPosition() + QPoint(0, 100 * nSteps), d->currentShortScrollDuration);
} else {
if (d->scroller->finalPosition().y() < verticalScrollBar()->maximum())
d->scroller->scrollTo(d->scroller->finalPosition() + QPoint(0, (1 - Okular::Settings::scrollOverlap() / 100.0) * verticalScrollBar()->rect().height()), d->currentLongScrollDuration);
d->scroller->scrollTo(d->scroller->finalPosition() + QPoint(0, (1 - Okular::Settings::scrollOverlap() / 100.0) * viewport()->height()), d->currentLongScrollDuration);
}
} else if ((int)d->document->currentPage() < d->items.count() - 1) {
// more optimized than document->setNextPage and then move view to top
} else if (!getContinuousMode() && (int)d->document->currentPage() < d->items.count() - 1) {
// Since we are in single page mode and at the bottom of the page, go to next page.
// setViewport() is more optimized than document->setNextPage and then move view to top
Okular::DocumentViewport newViewport = d->document->viewport();
newViewport.pageNumber += viewColumns();
if (newViewport.pageNumber >= (int)d->items.count())
......
Supports Markdown
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