Commit ea04c61f authored by Eduardo Cruz's avatar Eduardo Cruz Committed by Nate Graham
Browse files

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
parent 804cadfb
Pipeline #237705 passed with stage
in 6 minutes and 5 seconds
......@@ -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>
......
......@@ -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>
......
......@@ -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:
......
......@@ -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());
}
......
......@@ -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);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment