]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/private/kitemlistviewanimation.h
Merge branch 'release/21.12'
[dolphin.git] / src / kitemviews / private / kitemlistviewanimation.h
1 /*
2 * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef KITEMLISTVIEWANIMATION_H
8 #define KITEMLISTVIEWANIMATION_H
9
10 #include "dolphin_export.h"
11
12 #include <QHash>
13 #include <QObject>
14 #include <QVariant>
15
16 class KItemListView;
17 class QGraphicsWidget;
18 class QPropertyAnimation;
19
20 /**
21 * @brief Internal helper class for KItemListView to animate the items.
22 *
23 * Supports item animations for moving, creating, deleting and resizing
24 * an item. Several applications can be applied to one item in parallel.
25 */
26 class DOLPHIN_EXPORT KItemListViewAnimation : public QObject
27 {
28 Q_OBJECT
29
30 public:
31 enum AnimationType {
32 MovingAnimation,
33 CreateAnimation,
34 DeleteAnimation,
35 ResizeAnimation,
36 IconResizeAnimation,
37 AnimationTypeCount
38 };
39
40 explicit KItemListViewAnimation(QObject* parent = nullptr);
41 ~KItemListViewAnimation() override;
42
43 void setScrollOrientation(Qt::Orientation orientation);
44 Qt::Orientation scrollOrientation() const;
45
46 void setScrollOffset(qreal scrollOffset);
47 qreal scrollOffset() const;
48
49 /**
50 * Starts the animation of the type \a type for the widget \a widget. If an animation
51 * of the type is already running, this animation will be stopped before starting
52 * the new animation.
53 */
54 void start(QGraphicsWidget* widget, AnimationType type, const QVariant& endValue = QVariant());
55
56 /**
57 * Stops the animation of the type \a type for the widget \a widget.
58 */
59 void stop(QGraphicsWidget* widget, AnimationType type);
60
61 /**
62 * Stops all animations that have been applied to the widget \a widget.
63 */
64 void stop(QGraphicsWidget* widget);
65
66 /**
67 * @return True if the animation of the type \a type has been started
68 * for the widget \a widget..
69 */
70 bool isStarted(QGraphicsWidget *widget, AnimationType type) const;
71
72 /**
73 * @return True if any animation has been started for the widget.
74 */
75 bool isStarted(QGraphicsWidget* widget) const;
76
77 Q_SIGNALS:
78 void finished(QGraphicsWidget* widget, KItemListViewAnimation::AnimationType type);
79
80 private Q_SLOTS:
81 void slotFinished();
82
83 private:
84 Qt::Orientation m_scrollOrientation;
85 qreal m_scrollOffset;
86 QHash<QGraphicsWidget*, QPropertyAnimation*> m_animation[AnimationTypeCount];
87 };
88
89 #endif
90
91