From ea04c61faffb729b540d6168b8b8879113905492 Mon Sep 17 00:00:00 2001 From: Eduardo Cruz Date: Wed, 28 Sep 2022 00:10:56 +0000 Subject: [PATCH] Add a configuration option to disable drag-scrolling beyond screen edges The mouse cursor wrap feature while drag-scrolling can be undesirable in some cases; for example it can be annoying to have the cursor jump accidentally to the distant edge of a big screen. Now users can disable this feature if they prefer. BUG: 421040 FIXED-IN: 22.12 --- conf/okular.kcfg | 3 +++ doc/index.docbook | 8 ++++++++ part/dlggeneral.cpp | 9 +++++++++ part/pageview.cpp | 24 ++++++++++++++---------- part/thumbnaillist.cpp | 2 +- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/conf/okular.kcfg b/conf/okular.kcfg index 223c9f836..926eed66f 100644 --- a/conf/okular.kcfg +++ b/conf/okular.kcfg @@ -325,6 +325,9 @@ true + + true + FullAnnotationToolBar diff --git a/doc/index.docbook b/doc/index.docbook index 54fcf86de..c74eb61fb 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -2644,6 +2644,14 @@ Context menu actions like Rename Bookmarks etc.) + + When using Browse Tool, wrap cursor at screen edges + + + Allows endless scrolling around the entire document with the Browse Tool. If enabled, the mouse cursor will wrap to the opposite end of the screen when it touches the borders while dragging the document. This feature is only supported on X11. + + + Overview columns diff --git a/part/dlggeneral.cpp b/part/dlggeneral.cpp index c558a9ebb..b23c95966 100644 --- a/part/dlggeneral.cpp +++ b/part/dlggeneral.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -165,6 +166,14 @@ DlgGeneral::DlgGeneral(QWidget *parent, Okular::EmbedMode embedMode) openInContinuousModeByDefault->setText(i18nc("@option:check Config dialog, general page", "Open in continuous mode by default")); openInContinuousModeByDefault->setObjectName(QStringLiteral("kcfg_ViewContinuous")); layout->addRow(programFeaturesLabel(), openInContinuousModeByDefault); + + // Under Wayland the cursor wrap feature is unavailable + if (QGuiApplication::platformName() != QLatin1String("wayland")) { + QCheckBox *dragBeyondScreenEdges = new QCheckBox(this); + dragBeyondScreenEdges->setText(i18nc("@option:check Config dialog, general page", "When using Browse Tool, wrap cursor at screen edges")); + dragBeyondScreenEdges->setObjectName(QStringLiteral("kcfg_DragBeyondScreenEdges")); + layout->addRow(programFeaturesLabel(), dragBeyondScreenEdges); + } // END Program features section // If no Program features section, don’t add a second spacer: diff --git a/part/pageview.cpp b/part/pageview.cpp index 3820f106d..f61882e2e 100644 --- a/part/pageview.cpp +++ b/part/pageview.cpp @@ -2230,11 +2230,13 @@ void PageView::mouseMoveEvent(QMouseEvent *e) const float upperZoomLimit = d->document->supportsTiles() ? 99.99 : 3.99; // Wrap mouse cursor - Qt::Edges wrapEdges; - wrapEdges.setFlag(Qt::TopEdge, d->zoomFactor < upperZoomLimit); - wrapEdges.setFlag(Qt::BottomEdge, d->zoomFactor > 0.101); + if (Okular::Settings::dragBeyondScreenEdges()) { + Qt::Edges wrapEdges; + wrapEdges.setFlag(Qt::TopEdge, d->zoomFactor < upperZoomLimit); + wrapEdges.setFlag(Qt::BottomEdge, d->zoomFactor > 0.101); - deltaY += CursorWrapHelper::wrapCursor(e->globalPos(), wrapEdges).y(); + deltaY += CursorWrapHelper::wrapCursor(e->globalPos(), wrapEdges).y(); + } // update zoom level, perform zoom and redraw if (deltaY) { @@ -2279,13 +2281,15 @@ void PageView::mouseMoveEvent(QMouseEvent *e) setCursor(Qt::ClosedHandCursor); // Wrap mouse cursor - Qt::Edges wrapEdges; - wrapEdges.setFlag(Qt::TopEdge, verticalScrollBar()->value() < verticalScrollBar()->maximum()); - wrapEdges.setFlag(Qt::BottomEdge, verticalScrollBar()->value() > verticalScrollBar()->minimum()); - wrapEdges.setFlag(Qt::LeftEdge, horizontalScrollBar()->value() < horizontalScrollBar()->maximum()); - wrapEdges.setFlag(Qt::RightEdge, horizontalScrollBar()->value() > horizontalScrollBar()->minimum()); + if (Okular::Settings::dragBeyondScreenEdges()) { + Qt::Edges wrapEdges; + wrapEdges.setFlag(Qt::TopEdge, verticalScrollBar()->value() < verticalScrollBar()->maximum()); + wrapEdges.setFlag(Qt::BottomEdge, verticalScrollBar()->value() > verticalScrollBar()->minimum()); + wrapEdges.setFlag(Qt::LeftEdge, horizontalScrollBar()->value() < horizontalScrollBar()->maximum()); + wrapEdges.setFlag(Qt::RightEdge, horizontalScrollBar()->value() > horizontalScrollBar()->minimum()); - d->mouseGrabOffset -= CursorWrapHelper::wrapCursor(e->pos(), wrapEdges); + d->mouseGrabOffset -= CursorWrapHelper::wrapCursor(e->pos(), wrapEdges); + } d->scroller->handleInput(QScroller::InputMove, e->pos() + d->mouseGrabOffset, e->timestamp()); } diff --git a/part/thumbnaillist.cpp b/part/thumbnaillist.cpp index 83a8f2950..3ba98d546 100644 --- a/part/thumbnaillist.cpp +++ b/part/thumbnaillist.cpp @@ -911,7 +911,7 @@ void ThumbnailListPrivate::mouseMoveEvent(QMouseEvent *e) } // Wrap mouse cursor - if (!CursorWrapHelper::wrapCursor(mousePos, Qt::TopEdge | Qt::BottomEdge).isNull()) { + if (Okular::Settings::dragBeyondScreenEdges() && !CursorWrapHelper::wrapCursor(mousePos, Qt::TopEdge | Qt::BottomEdge).isNull()) { m_mouseGrabPos.setX(0); m_mouseGrabPos.setY(0); }