X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/6c3d9acbc22ea9463ba40ef84c9e8c8419dfacf3..681d8bb6c:/src/kitemviews/private/kitemlistviewanimation.cpp diff --git a/src/kitemviews/private/kitemlistviewanimation.cpp b/src/kitemviews/private/kitemlistviewanimation.cpp index e347c5bb1..ccc387529 100644 --- a/src/kitemviews/private/kitemlistviewanimation.cpp +++ b/src/kitemviews/private/kitemlistviewanimation.cpp @@ -18,25 +18,16 @@ ***************************************************************************/ #include "kitemlistviewanimation.h" +#include "kitemviews/kitemlistview.h" -#include - -#include -#include - -#include #include KItemListViewAnimation::KItemListViewAnimation(QObject* parent) : QObject(parent), - m_animationDuration(200), m_scrollOrientation(Qt::Vertical), m_scrollOffset(0), m_animation() { - if (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) { - m_animationDuration = 1; - } } KItemListViewAnimation::~KItemListViewAnimation() @@ -122,7 +113,8 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type, { stop(widget, type); - QPropertyAnimation* propertyAnim = 0; + QPropertyAnimation* propertyAnim = nullptr; + const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animate) ? 200 : 1; switch (type) { case MovingAnimation: { @@ -132,7 +124,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type, } propertyAnim = new QPropertyAnimation(widget, "pos"); - propertyAnim->setDuration(m_animationDuration); + propertyAnim->setDuration(animationDuration); propertyAnim->setEndValue(newPos); break; } @@ -140,7 +132,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type, case CreateAnimation: { propertyAnim = new QPropertyAnimation(widget, "opacity"); propertyAnim->setEasingCurve(QEasingCurve::InQuart); - propertyAnim->setDuration(m_animationDuration); + propertyAnim->setDuration(animationDuration); propertyAnim->setStartValue(0.0); propertyAnim->setEndValue(1.0); break; @@ -149,7 +141,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type, case DeleteAnimation: { propertyAnim = new QPropertyAnimation(widget, "opacity"); propertyAnim->setEasingCurve(QEasingCurve::OutQuart); - propertyAnim->setDuration(m_animationDuration); + propertyAnim->setDuration(animationDuration); propertyAnim->setStartValue(1.0); propertyAnim->setEndValue(0.0); break; @@ -162,7 +154,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type, } propertyAnim = new QPropertyAnimation(widget, "size"); - propertyAnim->setDuration(m_animationDuration); + propertyAnim->setDuration(animationDuration); propertyAnim->setEndValue(newSize); break; } @@ -172,7 +164,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type, } Q_ASSERT(propertyAnim); - connect(propertyAnim, SIGNAL(finished()), this, SLOT(slotFinished())); + connect(propertyAnim, &QPropertyAnimation::finished, this, &KItemListViewAnimation::slotFinished); m_animation[type].insert(widget, propertyAnim); propertyAnim->start(); @@ -225,13 +217,13 @@ void KItemListViewAnimation::slotFinished() { QPropertyAnimation* finishedAnim = qobject_cast(sender()); for (int type = 0; type < AnimationTypeCount; ++type) { - QHashIterator it(m_animation[type]); + QMutableHashIterator it(m_animation[type]); while (it.hasNext()) { it.next(); QPropertyAnimation* propertyAnim = it.value(); if (propertyAnim == finishedAnim) { QGraphicsWidget* widget = it.key(); - m_animation[type].remove(widget); + it.remove(); finishedAnim->deleteLater(); emit finished(widget, static_cast(type)); @@ -242,4 +234,3 @@ void KItemListViewAnimation::slotFinished() Q_ASSERT(false); } -#include "kitemlistviewanimation.moc"