]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Disable smooth-scrolling dependent on the graphics-effect level
authorPeter Penz <peter.penz19@gmail.com>
Tue, 17 Jan 2012 08:57:58 +0000 (09:57 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 17 Jan 2012 09:04:00 +0000 (10:04 +0100)
If the graphics-effect-level has been set to NoEffects (systemsettings -> Appearance
-> Style -> Fine Tuning), the smooth scrolling in Dolphin will be disabled.

Additionally the duration for the smooth-scrolling has been decreased from 200 ms
to 100 ms to reduce the lag.

A wrong calculation of the end-value has been fixed that might trigger
a wrong position of the content.

BUG: 291740
BUG: 291607
FIXED-IN: 4.8.0

src/kitemviews/kitemlistsmoothscroller.cpp
src/kitemviews/kitemlistwidget.cpp

index d966920cb41258374722b5c199ade4d1dc202bdd..80f7f28837a11b0a6e4ce3e690c920d9260193ea 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "kitemlistsmoothscroller_p.h"
 
+#include <KGlobalSettings>
 #include <QEvent>
 #include <QPropertyAnimation>
 #include <QScrollBar>
@@ -35,7 +36,8 @@ KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar,
     m_animation(0)
 {
     m_animation = new QPropertyAnimation(this);
-    m_animation->setDuration(200);
+    const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 100;
+    m_animation->setDuration(duration);
     connect(m_animation, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)),
             this, SLOT(slotAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
 
@@ -100,7 +102,6 @@ void KItemListSmoothScroller::scrollContentsBy(qreal distance)
     }
 
     const qreal endOffset = currentOffset - distance;
-
     if (m_smoothScrolling || animRunning) {
         qreal startOffset = currentOffset;
         if (animRunning) {
@@ -109,6 +110,11 @@ void KItemListSmoothScroller::scrollContentsBy(qreal distance)
             // assures that animation proceeds even in cases where new end-offset are triggered
             // within a very short timeslots.
             startOffset += (endOffset - currentOffset) * 1000 / (m_animation->duration() * 60);
+            if (currentOffset < endOffset) {
+                startOffset = qMin(startOffset, endOffset);
+            } else {
+                startOffset = qMax(startOffset, endOffset);
+            }
         }
 
         m_animation->stop();
index cd2bf4d40ce6851414aad5a9c34c77e2badf3a9b..8e6c728f7dfa9ba8a695659da2bb83a495f16311 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <KDebug>
 
+#include <KGlobalSettings>
 #include <QApplication>
 #include <QPainter>
 #include <QPropertyAnimation>
@@ -243,7 +244,8 @@ void KItemListWidget::setHovered(bool hovered)
 
     if (!m_hoverAnimation) {
         m_hoverAnimation = new QPropertyAnimation(this, "hoverOpacity", this);
-        m_hoverAnimation->setDuration(200);
+        const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 200;       
+        m_hoverAnimation->setDuration(duration);
         connect(m_hoverAnimation, SIGNAL(finished()), this, SLOT(slotHoverAnimationFinished()));
     }
     m_hoverAnimation->stop();