1 | /* |
2 | SPDX-FileCopyrightText: 2013 Dominik Haumann <dhaumann@kde.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KATE_ANIMATION_H |
8 | #define KATE_ANIMATION_H |
9 | |
10 | #include <QObject> |
11 | #include <QPointer> |
12 | |
13 | class QTimer; |
14 | |
15 | class KMessageWidget; |
16 | class KateFadeEffect; |
17 | /** |
18 | * This class provides a fade in/out effect for KMessageWidget%s. |
19 | * Example: |
20 | * \code |
21 | * KateAnimation* animation = new KateAnimation(someMessageWidget); |
22 | * animation->show(); |
23 | * //... |
24 | * animation->hide(); |
25 | * \endcode |
26 | */ |
27 | class KateAnimation : public QObject |
28 | { |
29 | Q_OBJECT |
30 | |
31 | public: |
32 | /** |
33 | * The type of supported animation effects |
34 | */ |
35 | enum EffectType { |
36 | FadeEffect = 0, ///< fade in/out |
37 | GrowEffect ///< grow / shrink |
38 | }; |
39 | |
40 | public: |
41 | /** |
42 | * Constructor. |
43 | */ |
44 | KateAnimation(KMessageWidget *widget, EffectType effect); |
45 | |
46 | /** |
47 | * Returns true, if the hide animation is running, otherwise false. |
48 | */ |
49 | bool isHideAnimationRunning() const; |
50 | |
51 | /** |
52 | * Returns true, if the how animation is running, otherwise false. |
53 | */ |
54 | bool isShowAnimationRunning() const; |
55 | |
56 | public Q_SLOTS: |
57 | /** |
58 | * Call to hide the widget. |
59 | */ |
60 | void hide(); |
61 | |
62 | /** |
63 | * Call to show and fade in the widget |
64 | */ |
65 | void show(); |
66 | |
67 | Q_SIGNALS: |
68 | /** |
69 | * This signal is emitted when the hiding animation is finished. |
70 | * At this point, the associated widget is hidden. |
71 | */ |
72 | void widgetHidden(); |
73 | |
74 | /** |
75 | * This signal is emitted when the showing animation is finished. |
76 | * At this point, the associated widget is hidden. |
77 | */ |
78 | void widgetShown(); |
79 | |
80 | private: |
81 | QPointer<KMessageWidget> m_widget; ///< the widget to animate |
82 | KateFadeEffect *m_fadeEffect; ///< the fade effect |
83 | }; |
84 | |
85 | #endif |
86 | |