]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/private/kitemlistviewanimation.cpp
Merge remote-tracking branch 'origin/release/21.08'
[dolphin.git] / src / kitemviews / private / kitemlistviewanimation.cpp
index 5a00c8c3a6a9cb018444ac453037c0d56999370f..9dc5fbadaf72cdb1579a5b47bad4666a825b1b21 100644 (file)
@@ -1,42 +1,20 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "kitemlistviewanimation.h"
+#include "kitemviews/kitemlistview.h"
 
-#include <kitemviews/kitemlistview.h>
-
-#include <KDebug>
-#include <KGlobalSettings>
-
-#include <QGraphicsWidget>
 #include <QPropertyAnimation>
 
 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 +100,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 +111,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 +119,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 +128,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 +141,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 +151,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();
@@ -195,7 +174,7 @@ void KItemListViewAnimation::stop(QGraphicsWidget* widget, AnimationType type)
         m_animation[type].remove(widget);
         delete propertyAnim;
 
-        emit finished(widget, type);
+        Q_EMIT finished(widget, type);
     }
 }
 
@@ -234,7 +213,7 @@ void KItemListViewAnimation::slotFinished()
                 it.remove();
                 finishedAnim->deleteLater();
 
-                emit finished(widget, static_cast<AnimationType>(type));
+                Q_EMIT finished(widget, static_cast<AnimationType>(type));
                 return;
             }
         }
@@ -242,4 +221,3 @@ void KItemListViewAnimation::slotFinished()
     Q_ASSERT(false);
 }
 
-#include "kitemlistviewanimation.moc"