KTextEditor

kateanimation.cpp
1 /*
2  SPDX-FileCopyrightText: 2013 Dominik Haumann <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "kateanimation.h"
8 
9 #include "katefadeeffect.h"
10 #include "kateglobal.h"
11 
12 #include <KMessageWidget>
13 
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) {
55  QTimer::singleShot(0, m_fadeEffect, SLOT(fadeIn()));
56  } else {
57  QTimer::singleShot(0, m_widget, SLOT(animatedShow()));
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  || KTextEditor::EditorPrivate::unitTestMode() // 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 }
void fadeOut()
Call to fade out and hide the widget.
bool isShowAnimationRunning() const
Check whether the show animation started by calling fadeIn() is still running.
Q_EMITQ_EMIT
KateAnimation(KMessageWidget *widget, EffectType effect)
Constructor.
void hideAnimationFinished()
This signal is emitted when the fadeOut animation is finished, started by calling fadeOut().
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void showAnimationFinished()
void show()
Call to show and fade in the widget.
bool isHideAnimationRunning() const
Check whether the hide animation started by calling fadeOut() is still running.
bool isHideAnimationRunning() const
Returns true, if the hide animation is running, otherwise false.
void hide()
Call to hide the widget.
static bool unitTestMode()
Returns true, if the unit test mode was enabled through a call of enableUnitTestMode(),...
Definition: kateglobal.cpp:64
void widgetShown()
This signal is emitted when the showing animation is finished.
void widgetHidden()
This signal is emitted when the hiding animation is finished.
SH_Widget_Animate
EffectType
The type of supported animation effects.
Definition: kateanimation.h:35
This class provides a fade in/out effect for arbitrary QWidgets.
void showAnimationFinished()
This signal is emitted when the fadeIn animation is finished, started by calling fadeIn().
T * data() const const
@ FadeEffect
fade in/out
Definition: kateanimation.h:36
bool isShowAnimationRunning() const
Returns true, if the how animation is running, otherwise false.
void hideAnimationFinished()
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed Aug 17 2022 03:54:00 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.