KTextEditor

kateanimation.cpp
1/*
2 SPDX-FileCopyrightText: 2013 Dominik Haumann <dhaumann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "kateanimation.h"
8
9#include "katefadeeffect.h"
10
11#include <KMessageWidget>
12
13#include <QStandardPaths>
14#include <QStyle>
15#include <QTimer>
16
18 : QObject(widget)
19 , m_widget(widget)
20 , m_fadeEffect(nullptr)
21{
22 Q_ASSERT(m_widget != nullptr);
23
24 // create wanted effect
25 if (effect == FadeEffect) {
26 m_fadeEffect = new KateFadeEffect(widget);
27
30 } else {
33 }
34}
35
37{
38 return m_fadeEffect ? m_fadeEffect->isHideAnimationRunning() : m_widget->isHideAnimationRunning();
39}
40
42{
43 return m_fadeEffect ? m_fadeEffect->isShowAnimationRunning() : m_widget->isShowAnimationRunning();
44}
45
47{
48 Q_ASSERT(m_widget != nullptr);
49
50 // show according to effects config
51 if (m_widget->style()->styleHint(QStyle::SH_Widget_Animate, nullptr, m_widget)) {
52 // launch show effect
53 // NOTE: use a singleShot timer to avoid resizing issues when showing the message widget the first time (bug #316666)
54 if (m_fadeEffect) {
56 } else {
58 }
59 } else {
60 m_widget->show();
62 }
63}
64
66{
67 Q_ASSERT(m_widget != nullptr);
68
69 // hide according to effects config
70 if (m_widget->style()->styleHint(QStyle::SH_Widget_Animate, nullptr, m_widget)
71 || QStandardPaths::isTestModeEnabled() // due to timing issues in the unit test
72 ) {
73 // hide depending on effect
74 if (m_fadeEffect) {
75 m_fadeEffect->fadeOut();
76 } else {
77 m_widget->animatedHide();
78 }
79 } else {
80 m_widget->hide();
82 }
83}
84
85#include "moc_kateanimation.cpp"
void showAnimationFinished()
void animatedShow()
void hideAnimationFinished()
KateAnimation(KMessageWidget *widget, EffectType effect)
Constructor.
void widgetShown()
This signal is emitted when the showing animation is finished.
bool isHideAnimationRunning() const
Returns true, if the hide animation is running, otherwise false.
void show()
Call to show and fade in the widget.
EffectType
The type of supported animation effects.
@ FadeEffect
fade in/out
void widgetHidden()
This signal is emitted when the hiding animation is finished.
bool isShowAnimationRunning() const
Returns true, if the how animation is running, otherwise false.
void hide()
Call to hide the widget.
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 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 hideAnimationFinished()
This signal is emitted when the fadeOut animation is finished, started by calling fadeOut().
bool isShowAnimationRunning() const
Check whether the show animation started by calling fadeIn() is still running.
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
T * data() const const
SH_Widget_Animate
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:57:26 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.