Port away from KGlobalSettings::graphicEffectsLevel()

REVIEW: 122309
This commit is contained in:
Emmanuel Pescosta 2015-01-29 16:02:39 +01:00
parent f8187b982a
commit 08252ffc69
4 changed files with 8 additions and 15 deletions

View file

@ -29,7 +29,6 @@
#include <QDebug> #include <QDebug>
#include <KGlobalSettings>
#include <QApplication> #include <QApplication>
#include <QPainter> #include <QPainter>
#include <QPropertyAnimation> #include <QPropertyAnimation>
@ -250,7 +249,7 @@ void KItemListWidget::setHovered(bool hovered)
if (!m_hoverAnimation) { if (!m_hoverAnimation) {
m_hoverAnimation = new QPropertyAnimation(this, "hoverOpacity", this); m_hoverAnimation = new QPropertyAnimation(this, "hoverOpacity", this);
const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 200; const int duration = style()->styleHint(QStyle::SH_Widget_Animate) ? 200 : 1;
m_hoverAnimation->setDuration(duration); m_hoverAnimation->setDuration(duration);
connect(m_hoverAnimation, &QPropertyAnimation::finished, this, &KItemListWidget::slotHoverAnimationFinished); connect(m_hoverAnimation, &QPropertyAnimation::finished, this, &KItemListWidget::slotHoverAnimationFinished);
} }

View file

@ -19,12 +19,11 @@
#include "kitemlistsmoothscroller.h" #include "kitemlistsmoothscroller.h"
#include <KGlobalSettings>
#include <QEvent> #include <QEvent>
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include <QScrollBar> #include <QScrollBar>
#include <QWheelEvent> #include <QWheelEvent>
#include <QStyle>
#include <QDebug> #include <QDebug>
KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar, KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar,
@ -36,7 +35,7 @@ KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar,
m_animation(0) m_animation(0)
{ {
m_animation = new QPropertyAnimation(this); m_animation = new QPropertyAnimation(this);
const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 100; const int duration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animate, nullptr, m_scrollBar) ? 100 : 1;
m_animation->setDuration(duration); m_animation->setDuration(duration);
connect(m_animation, &QPropertyAnimation::stateChanged, connect(m_animation, &QPropertyAnimation::stateChanged,
this, &KItemListSmoothScroller::slotAnimationStateChanged); this, &KItemListSmoothScroller::slotAnimationStateChanged);

View file

@ -22,21 +22,16 @@
#include <kitemviews/kitemlistview.h> #include <kitemviews/kitemlistview.h>
#include <QDebug> #include <QDebug>
#include <KGlobalSettings>
#include <QGraphicsWidget> #include <QGraphicsWidget>
#include <QPropertyAnimation> #include <QPropertyAnimation>
KItemListViewAnimation::KItemListViewAnimation(QObject* parent) : KItemListViewAnimation::KItemListViewAnimation(QObject* parent) :
QObject(parent), QObject(parent),
m_animationDuration(200),
m_scrollOrientation(Qt::Vertical), m_scrollOrientation(Qt::Vertical),
m_scrollOffset(0), m_scrollOffset(0),
m_animation() m_animation()
{ {
if (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) {
m_animationDuration = 1;
}
} }
KItemListViewAnimation::~KItemListViewAnimation() KItemListViewAnimation::~KItemListViewAnimation()
@ -123,6 +118,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
stop(widget, type); stop(widget, type);
QPropertyAnimation* propertyAnim = 0; QPropertyAnimation* propertyAnim = 0;
const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animate) ? 200 : 1;
switch (type) { switch (type) {
case MovingAnimation: { case MovingAnimation: {
@ -132,7 +128,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
} }
propertyAnim = new QPropertyAnimation(widget, "pos"); propertyAnim = new QPropertyAnimation(widget, "pos");
propertyAnim->setDuration(m_animationDuration); propertyAnim->setDuration(animationDuration);
propertyAnim->setEndValue(newPos); propertyAnim->setEndValue(newPos);
break; break;
} }
@ -140,7 +136,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
case CreateAnimation: { case CreateAnimation: {
propertyAnim = new QPropertyAnimation(widget, "opacity"); propertyAnim = new QPropertyAnimation(widget, "opacity");
propertyAnim->setEasingCurve(QEasingCurve::InQuart); propertyAnim->setEasingCurve(QEasingCurve::InQuart);
propertyAnim->setDuration(m_animationDuration); propertyAnim->setDuration(animationDuration);
propertyAnim->setStartValue(0.0); propertyAnim->setStartValue(0.0);
propertyAnim->setEndValue(1.0); propertyAnim->setEndValue(1.0);
break; break;
@ -149,7 +145,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
case DeleteAnimation: { case DeleteAnimation: {
propertyAnim = new QPropertyAnimation(widget, "opacity"); propertyAnim = new QPropertyAnimation(widget, "opacity");
propertyAnim->setEasingCurve(QEasingCurve::OutQuart); propertyAnim->setEasingCurve(QEasingCurve::OutQuart);
propertyAnim->setDuration(m_animationDuration); propertyAnim->setDuration(animationDuration);
propertyAnim->setStartValue(1.0); propertyAnim->setStartValue(1.0);
propertyAnim->setEndValue(0.0); propertyAnim->setEndValue(0.0);
break; break;
@ -162,7 +158,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
} }
propertyAnim = new QPropertyAnimation(widget, "size"); propertyAnim = new QPropertyAnimation(widget, "size");
propertyAnim->setDuration(m_animationDuration); propertyAnim->setDuration(animationDuration);
propertyAnim->setEndValue(newSize); propertyAnim->setEndValue(newSize);
break; break;
} }

View file

@ -94,7 +94,6 @@ private slots:
private: private:
enum { AnimationTypeCount = 4 }; enum { AnimationTypeCount = 4 };
int m_animationDuration;
Qt::Orientation m_scrollOrientation; Qt::Orientation m_scrollOrientation;
qreal m_scrollOffset; qreal m_scrollOffset;
QHash<QGraphicsWidget*, QPropertyAnimation*> m_animation[AnimationTypeCount]; QHash<QGraphicsWidget*, QPropertyAnimation*> m_animation[AnimationTypeCount];