From 8b008b02fc31e20f7c74ab2c25d34160756c7a92 Mon Sep 17 00:00:00 2001 From: David Hurka Date: Wed, 21 Oct 2020 00:40:01 +0000 Subject: [PATCH 1/2] Fix cursor not updated after clicking internal link updateCursor() was called by wheelEvent(), which made sense, because after the wheel event the page will have moved under the cursor. With smooth scrolling, it makes less sense in wheelEvent(), because at that point scrolling is still in the future. scrollContentsBy() appears to be called on every scroll step. (It is documented to be called at scrollbar value changes, so makes sense.) This patch removes updateCursor() from wheelEvent(), but adds it to scrollContentsBy(). I did not check anything out with d->visibleItems, as was indicated it graphics/okular!176. BUG: 421437 --- ui/pageview.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/pageview.cpp b/ui/pageview.cpp index 0fcc2167c..b5f25a03e 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -3139,8 +3139,6 @@ void PageView::wheelEvent(QWheelEvent *e) } } } - - updateCursor(); } bool PageView::viewportEvent(QEvent *e) @@ -3193,6 +3191,8 @@ void PageView::scrollContentsBy(int dx, int dy) for (const QRect &rect : rgn) viewport()->update(rect); + + updateCursor(); } // END widget events @@ -3863,12 +3863,15 @@ void PageView::updateCursor(const QPoint p) // detect the underlaying page (if present) PageViewItem *pageItem = pickItemOnPoint(p.x(), p.y()); + QScroller::State scrollerState = d->scroller->state(); if (d->annotator && d->annotator->active()) { if (pageItem || d->annotator->annotating()) setCursor(d->annotator->cursor()); else setCursor(Qt::ForbiddenCursor); + } else if (scrollerState == QScroller::Pressed || scrollerState == QScroller::Dragging) { + setCursor(Qt::ClosedHandCursor); } else if (pageItem) { double nX = pageItem->absToPageX(p.x()); double nY = pageItem->absToPageY(p.y()); From 777ac37ea21212c4d924c75be5cee502ad5820c0 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Tue, 20 Oct 2020 19:03:38 -0600 Subject: [PATCH 2/2] Fix fast scrolling with Shift+Scroll When holding down the shift key, multiply wheel and touchpad scroll distances by 10 to re-implement the fast scrolling feature that broke when we added animated/smooth scrolling. BUG: 420889 FIXED-IN: 1.11.3 --- ui/pageview.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/pageview.cpp b/ui/pageview.cpp index b5f25a03e..caedf5706 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -3126,16 +3126,19 @@ void PageView::wheelEvent(QWheelEvent *e) d->scroller->scrollTo(QPoint(horizontalScrollBar()->value(), verticalScrollBar()->value()), 0); // sync scroller with scrollbar } } else { + // When the shift key is held down, scroll ten times faster + int multiplier = e->modifiers() & Qt::ShiftModifier ? 10 : 1; + if (delta != 0 && delta % QWheelEvent::DefaultDeltasPerStep == 0) { // number of scroll wheel steps Qt gives to us at the same time - int count = abs(delta / QWheelEvent::DefaultDeltasPerStep); + int count = abs(delta / QWheelEvent::DefaultDeltasPerStep) * multiplier; if (delta < 0) { slotScrollDown(count); } else { slotScrollUp(count); } } else { - d->scroller->scrollTo(d->scroller->finalPosition() - e->angleDelta() / 4.0, 0); + d->scroller->scrollTo(d->scroller->finalPosition() - e->angleDelta() * multiplier / 4.0, 0); } } }