mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-25 10:55:37 +00:00
Fix forms when inertially scrolling
`setViewport` automatically adds an item to the history if it finds that it moved for more than a page, which we don't want to do when automatically scrolling, as with inertial scrolling. This commit adds a new function `setViewportWithHistory()` which takes an argument to optionally avoid preserving history. This avoids breaking ABI. The new history-less functionality is used when inertially scrolling. BUG: 421354 FIXED-IN: 1.11.2
This commit is contained in:
parent
601e96037c
commit
bdb2df773d
|
@ -3445,19 +3445,8 @@ void Document::setPrevPage()
|
||||||
setViewport( DocumentViewport( (*d->m_viewportIterator).pageNumber - 1 ) );
|
setViewport( DocumentViewport( (*d->m_viewportIterator).pageNumber - 1 ) );
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
void Document::setViewportPage(int page, DocumentObserver *excludeObserver, bool smoothMove)
|
|
||||||
{
|
|
||||||
// clamp page in range [0 ... numPages-1]
|
|
||||||
if (page < 0)
|
|
||||||
page = 0;
|
|
||||||
else if (page > (int)d->m_pagesVector.count())
|
|
||||||
page = d->m_pagesVector.count() - 1;
|
|
||||||
|
|
||||||
// make a viewport from the page and broadcast it
|
void Document::setViewportWithHistory(const DocumentViewport &viewport, DocumentObserver *excludeObserver, bool smoothMove, bool updateHistory)
|
||||||
setViewport(DocumentViewport(page), excludeObserver, smoothMove);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Document::setViewport(const DocumentViewport &viewport, DocumentObserver *excludeObserver, bool smoothMove)
|
|
||||||
{
|
{
|
||||||
if (!viewport.isValid()) {
|
if (!viewport.isValid()) {
|
||||||
qCDebug(OkularCoreDebug) << "invalid viewport:" << viewport.toString();
|
qCDebug(OkularCoreDebug) << "invalid viewport:" << viewport.toString();
|
||||||
|
@ -3477,7 +3466,7 @@ void Document::setViewport(const DocumentViewport &viewport, DocumentObserver *e
|
||||||
const int oldPageNumber = oldViewport.pageNumber;
|
const int oldPageNumber = oldViewport.pageNumber;
|
||||||
|
|
||||||
// set internal viewport taking care of history
|
// set internal viewport taking care of history
|
||||||
if (oldViewport.pageNumber == viewport.pageNumber || !oldViewport.isValid()) {
|
if (oldViewport.pageNumber == viewport.pageNumber || !oldViewport.isValid() || !updateHistory) {
|
||||||
// if page is unchanged save the viewport at current position in queue
|
// if page is unchanged save the viewport at current position in queue
|
||||||
oldViewport = viewport;
|
oldViewport = viewport;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3506,6 +3495,24 @@ void Document::setViewport(const DocumentViewport &viewport, DocumentObserver *e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Document::setViewportPage(int page, DocumentObserver *excludeObserver, bool smoothMove)
|
||||||
|
{
|
||||||
|
// clamp page in range [0 ... numPages-1]
|
||||||
|
if (page < 0)
|
||||||
|
page = 0;
|
||||||
|
else if (page > (int)d->m_pagesVector.count())
|
||||||
|
page = d->m_pagesVector.count() - 1;
|
||||||
|
|
||||||
|
// make a viewport from the page and broadcast it
|
||||||
|
setViewport(DocumentViewport(page), excludeObserver, smoothMove);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Document::setViewport(const DocumentViewport &viewport, DocumentObserver *excludeObserver, bool smoothMove)
|
||||||
|
{
|
||||||
|
// set viewport, updating history
|
||||||
|
setViewportWithHistory(viewport, excludeObserver, smoothMove, true);
|
||||||
|
}
|
||||||
|
|
||||||
void Document::setZoom(int factor, DocumentObserver *excludeObserver)
|
void Document::setZoom(int factor, DocumentObserver *excludeObserver)
|
||||||
{
|
{
|
||||||
// notify change to all other (different from id) observers
|
// notify change to all other (different from id) observers
|
||||||
|
|
|
@ -431,6 +431,17 @@ public:
|
||||||
*/
|
*/
|
||||||
void setViewport(const DocumentViewport &viewport, DocumentObserver *excludeObserver = nullptr, bool smoothMove = false);
|
void setViewport(const DocumentViewport &viewport, DocumentObserver *excludeObserver = nullptr, bool smoothMove = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current document viewport to the given @p viewport.
|
||||||
|
* BCI TODO: merge with setViewport, adding a parameter "bool updateHistory = true"
|
||||||
|
*
|
||||||
|
* @param viewport The document viewport.
|
||||||
|
* @param excludeObserver The observer which shouldn't be effected by this change.
|
||||||
|
* @param smoothMove Whether the move shall be animated smoothly.
|
||||||
|
* @param updateHistory Whether to consider the change of viewport for the history navigation
|
||||||
|
*/
|
||||||
|
void setViewportWithHistory(const DocumentViewport &viewport, DocumentObserver *excludeObserver = nullptr, bool smoothMove = false, bool updateHistory = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current document viewport to the next viewport in the
|
* Sets the current document viewport to the next viewport in the
|
||||||
* viewport history.
|
* viewport history.
|
||||||
|
|
|
@ -4360,7 +4360,7 @@ static void slotRequestPreloadPixmap(Okular::DocumentObserver *observer, const P
|
||||||
void PageView::slotRequestVisiblePixmaps(int newValue)
|
void PageView::slotRequestVisiblePixmaps(int newValue)
|
||||||
{
|
{
|
||||||
// if requests are blocked (because raised by an unwanted event), exit
|
// if requests are blocked (because raised by an unwanted event), exit
|
||||||
if (d->blockPixmapsRequest || d->scroller->state() == QScroller::Scrolling)
|
if (d->blockPixmapsRequest)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// precalc view limits for intersecting with page coords inside the loop
|
// precalc view limits for intersecting with page coords inside the loop
|
||||||
|
@ -4503,7 +4503,8 @@ void PageView::slotRequestVisiblePixmaps(int newValue)
|
||||||
newViewport.rePos.normalizedX = focusedX;
|
newViewport.rePos.normalizedX = focusedX;
|
||||||
newViewport.rePos.normalizedY = focusedY;
|
newViewport.rePos.normalizedY = focusedY;
|
||||||
// set the viewport to other observers
|
// set the viewport to other observers
|
||||||
d->document->setViewport(newViewport, this);
|
// do not update history if the viewport is autoscrolling
|
||||||
|
d->document->setViewportWithHistory(newViewport, this, false, d->scroller->state() == QScroller::Scrolling);
|
||||||
}
|
}
|
||||||
d->document->setVisiblePageRects(visibleRects, this);
|
d->document->setVisiblePageRects(visibleRects, this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue