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
remotes/origin/work/aacid/shorcutslost_2008
David Hurka 5 years ago committed by Nate Graham
parent dc74ffa68c
commit 843c43cc6b
  1. 4
      autotests/parttest.cpp
  2. 7
      ui/pageview.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);
}

@ -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());

Loading…
Cancel
Save