[graphics/okular] /: Add a configuration option to disable drag-scrolling beyond screen edges

Nate Graham null at kde.org
Wed Sep 28 01:10:59 BST 2022


Git commit ea04c61faffb729b540d6168b8b8879113905492 by Nate Graham, on behalf of Eduardo Cruz.
Committed on 28/09/2022 at 00:10.
Pushed by ngraham into branch 'master'.

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

M  +3    -0    conf/okular.kcfg
M  +8    -0    doc/index.docbook
M  +9    -0    part/dlggeneral.cpp
M  +15   -11   part/pageview.cpp
M  +1    -1    part/thumbnaillist.cpp

https://invent.kde.org/graphics/okular/commit/ea04c61faffb729b540d6168b8b8879113905492

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 @@
    <default>true</default>
    <emit signal="viewContinuousChanged" />
   </entry>
+  <entry key="DragBeyondScreenEdges" type="Bool" >
+   <default>true</default>
+  </entry>
   <entry key="PrimaryAnnotationToolBar" type="Enum" >
    <default>FullAnnotationToolBar</default>
    <choices>
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.)
 						</para>
 					</listitem>
 				</varlistentry>
+				<varlistentry>
+					<term><guilabel>When using Browse Tool, wrap cursor at screen edges</guilabel></term>
+					<listitem>
+						<para>
+						  Allows endless scrolling around the entire document with the <link linkend="menutools">Browse Tool</link>. 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.
+						</para>
+					</listitem>
+				</varlistentry>
 				<varlistentry>
 					<term><guilabel>Overview columns</guilabel></term>
 					<listitem>
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 <QCheckBox>
 #include <QComboBox>
 #include <QFormLayout>
+#include <QGuiApplication>
 #include <QHBoxLayout>
 #include <QLabel>
 #include <QSpinBox>
@@ -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());
-
-                d->mouseGrabOffset -= CursorWrapHelper::wrapCursor(e->pos(), wrapEdges);
+                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->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);
         }


More information about the kde-doc-english mailing list