[graphics/okular] /: Add option to disable smooth scrolling

Nate Graham null at kde.org
Thu Sep 24 14:44:28 BST 2020


Git commit 122528d3fe96f6f4962136accd06f2be1ee1b323 by Nate Graham.
Committed on 24/09/2020 at 13:43.
Pushed by ngraham into branch 'master'.

Add option to disable smooth scrolling

Even though the animated smooth scrolling transitions are now affected
by the global animation speed setting in Plasma, this is not totally
satisfactory for the full pool of people who hate smooth scrolling, as
it does not address the cases of people using Okular outside of Plasma
or people who generally want animations but just not in Okular's
scrolling implementation.

Accordingly, there is now a GUI option to disable smooth scrolling in
Okular's settings window.

BUG: 420755
FIXED-IN: 20.12

M  +7    -0    conf/dlggeneralbase.ui
M  +3    -0    conf/okular.kcfg
M  +6    -0    doc/index.docbook
M  +13   -1    ui/pageview.cpp

https://invent.kde.org/graphics/okular/commit/122528d3fe96f6f4962136accd06f2be1ee1b323

diff --git a/conf/dlggeneralbase.ui b/conf/dlggeneralbase.ui
index 482c25a0f..e7ea4a4e3 100644
--- a/conf/dlggeneralbase.ui
+++ b/conf/dlggeneralbase.ui
@@ -64,6 +64,13 @@
         <property name="bottomMargin">
          <number>0</number>
         </property>
+        <item>
+         <widget class="QCheckBox" name="kcfg_SmoothScrolling">
+          <property name="text">
+           <string>Use smooth scrolling</string>
+          </property>
+         </widget>
+        </item>
         <item>
          <widget class="QCheckBox" name="kcfg_ShowScrollBars">
           <property name="text">
diff --git a/conf/okular.kcfg b/conf/okular.kcfg
index b68991df3..b15c1ade2 100644
--- a/conf/okular.kcfg
+++ b/conf/okular.kcfg
@@ -286,6 +286,9 @@
   <entry key="EditToolBarPlacement" type="Int" >
    <default>0</default>
   </entry>
+  <entry key="SmoothScrolling" type="Bool" >
+   <default>true</default>
+  </entry>
   <entry key="ShowScrollBars" type="Bool" >
    <default>true</default>
   </entry>
diff --git a/doc/index.docbook b/doc/index.docbook
index 70996f35c..214ae2ccc 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -2482,6 +2482,12 @@ Context menu actions like Rename Bookmarks etc.)
 		<sect1 id="configgeneral">
 			<title>General</title>
 			<variablelist>
+                <varlistentry>
+					<term><guilabel>Use smooth scrolling</guilabel></term>
+					<listitem>
+						<para>Whether to display animated transitions when scrolling using the mouse wheel and keyboard.</para>
+					</listitem>
+				</varlistentry>
 				<varlistentry>
 					<term><guilabel>Show scrollbars</guilabel></term>
 					<listitem>
diff --git a/ui/pageview.cpp b/ui/pageview.cpp
index 300c9444d..fc848f4f9 100644
--- a/ui/pageview.cpp
+++ b/ui/pageview.cpp
@@ -451,7 +451,6 @@ PageView::PageView(QWidget *parent, Okular::Document *document)
             PageView::updateSmoothScrollAnimationSpeed();
         }
     });
-    PageView::updateSmoothScrollAnimationSpeed();
 
     // connect the padding of the viewport to pixmaps requests
     connect(horizontalScrollBar(), &QAbstractSlider::valueChanged, this, &PageView::slotRequestVisiblePixmaps);
@@ -871,6 +870,9 @@ void PageView::displayMessage(const QString &message, const QString &details, Pa
 
 void PageView::reparseConfig()
 {
+    // set smooth scrolling policies
+    PageView::updateSmoothScrollAnimationSpeed();
+
     // set the scroll bars policies
     Qt::ScrollBarPolicy scrollBarMode = Okular::Settings::showScrollBars() ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff;
     if (horizontalScrollBarPolicy() != scrollBarMode) {
@@ -4188,6 +4190,16 @@ void PageView::addSearchWithinDocumentAction(QMenu *menu, const QString &searchT
 
 void PageView::updateSmoothScrollAnimationSpeed()
 {
+    // If it's turned off in Okular's own settings, don't bother to look at the
+    // global settings
+    if (!Okular::Settings::smoothScrolling()) {
+        d->currentShortScrollDuration = 0;
+        d->currentLongScrollDuration = 0;
+        return;
+    }
+
+    // If we are using smooth scrolling, scale the speed of the animated
+    // transitions according to the global animation speed setting
     KConfigGroup kdeglobalsConfig = KConfigGroup(KSharedConfig::openConfig(), QStringLiteral("KDE"));
     const qreal globalAnimationScale = qMax(0.0, kdeglobalsConfig.readEntry("AnimationDurationFactor", 1.0));
     d->currentShortScrollDuration = d->baseShortScrollDuration * globalAnimationScale;


More information about the kde-doc-english mailing list