From 843c43cc6ba82a80db86e0a5ed11e27e255cd851 Mon Sep 17 00:00:00 2001 From: David Hurka Date: Wed, 21 Oct 2020 00:40:01 +0000 Subject: [PATCH] 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 --- autotests/parttest.cpp | 4 ---- ui/pageview.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/autotests/parttest.cpp b/autotests/parttest.cpp index 6cc1e108c..6eddbd86c 100644 --- a/autotests/parttest.cpp +++ b/autotests/parttest.cpp @@ -316,10 +316,6 @@ void PartTest::testClickInternalLink() QTRY_COMPARE(part.m_document->currentPage(), 1u); // make sure cursor goes back to being an open hand again. Bug 421437 - // TODO: This test for bug 421437 has been committed when there was no fix for the bug - // available yet. That's why the QTRY_COMPARE_WITH_TIMEOUT is preceded by QEXPECT_FAIL. - // Please remove the QEXPECT_FAIL together with the fix for bug 421437. - QEXPECT_FAIL("", "Please remove this QEXPECT_FAIL once bug 421437 is fixed!", Continue); QTRY_COMPARE_WITH_TIMEOUT(part.m_pageView->cursor().shape(), Qt::OpenHandCursor, 1000); } diff --git a/ui/pageview.cpp b/ui/pageview.cpp index 4dda88a49..d7d0ee615 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -3171,8 +3171,6 @@ void PageView::wheelEvent(QWheelEvent *e) } } } - - updateCursor(); } bool PageView::viewportEvent(QEvent *e) @@ -3225,6 +3223,8 @@ void PageView::scrollContentsBy(int dx, int dy) for (const QRect &rect : rgn) viewport()->update(rect); + + updateCursor(); } // END widget events @@ -3895,12 +3895,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());