KTextEditor

katefadeeffect.h
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_FADE_EFFECT_H
8#define KATE_FADE_EFFECT_H
9
10#include <QObject>
11#include <QPointer>
12
13class QWidget;
14class QTimeLine;
16/**
17 * This class provides a fade in/out effect for arbitrary QWidget%s.
18 * Example:
19 * \code
20 * KateFadeEffect* fadeEffect = new KateFadeEffect(someWidget);
21 * fadeEffect->fadeIn();
22 * //...
23 * fadeEffect->fadeOut();
24 * \endcode
25 */
26class KateFadeEffect : public QObject
27{
29
30public:
31 /**
32 * Constructor.
33 * By default, the widget is fully opaque (opacity = 1.0).
34 */
35 explicit KateFadeEffect(QWidget *widget = nullptr);
36
37 /**
38 * Check whether the hide animation started by calling fadeOut()
39 * is still running. If animations are disabled, this function always
40 * returns @e false.
41 */
42 bool isHideAnimationRunning() const;
43
44 /**
45 * Check whether the show animation started by calling fadeIn()
46 * is still running. If animations are disabled, this function always
47 * returns @e false.
48 */
49 bool isShowAnimationRunning() const;
50
51public Q_SLOTS:
52 /**
53 * Call to fade out and hide the widget.
54 */
55 void fadeOut();
56
57 /**
58 * Call to show and fade in the widget
59 */
60 void fadeIn();
61
63 /**
64 * This signal is emitted when the fadeOut animation is finished, started by
65 * calling fadeOut(). If animations are disabled, this signal is
66 * emitted immediately.
67 */
69
70 /**
71 * This signal is emitted when the fadeIn animation is finished, started by
72 * calling fadeIn(). If animations are disabled, this signal is
73 * emitted immediately.
74 */
76
77protected Q_SLOTS:
78 /**
79 * Helper to update opacity value
80 */
81 void opacityChanged(qreal value);
82
83 /**
84 * When the animation is finished, hide the widget if fading out.
85 */
86 void animationFinished();
87
88private:
89 QPointer<QWidget> m_widget; ///< the fading widget
90 QTimeLine *m_timeLine; ///< update time line
91 QPointer<QGraphicsOpacityEffect> m_effect; ///< graphics opacity effect
92};
93
94#endif
This class provides a fade in/out effect for arbitrary QWidgets.
bool isHideAnimationRunning() const
Check whether the hide animation started by calling fadeOut() is still running.
void animationFinished()
When the animation is finished, hide the widget if fading out.
void fadeOut()
Call to fade out and hide the widget.
void showAnimationFinished()
This signal is emitted when the fadeIn animation is finished, started by calling fadeIn().
void fadeIn()
Call to show and fade in the widget.
void opacityChanged(qreal value)
Helper to update opacity value.
void hideAnimationFinished()
This signal is emitted when the fadeOut animation is finished, started by calling fadeOut().
KateFadeEffect(QWidget *widget=nullptr)
Constructor.
bool isShowAnimationRunning() const
Check whether the show animation started by calling fadeIn() is still running.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 12:01:51 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.