• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • view
kateanimation.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE and the Kate project
2  *
3  * Copyright (C) 2013 Dominik Haumann <dhaumann@kde.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #include "kateanimation.h"
22 #include "kateanimation.moc"
23 #include <katefadeeffect.h>
24 
25 #include <KMessageWidget>
26 #include <QTimer>
27 #include <kglobalsettings.h>
28 
29 KateAnimation::KateAnimation(KMessageWidget* widget, EffectType effect)
30  : QObject(widget)
31  , m_widget(widget)
32  , m_fadeEffect(0)
33 {
34  Q_ASSERT(m_widget != 0);
35 
36  // create wanted effect
37  if (effect == FadeEffect) {
38  m_fadeEffect = new KateFadeEffect(widget);
39  }
40 
41  // create tracking timer for hiding the widget
42  m_hideTimer = new QTimer(this);
43  m_hideTimer->setInterval(550); // 500 from KMessageWidget + 50 to make sure the hide animation is really finished
44  m_hideTimer->setSingleShot(true);
45  connect(m_hideTimer, SIGNAL(timeout()), this, SIGNAL(widgetHidden()));
46 
47  // create tracking timer for showing the widget
48  m_showTimer = new QTimer(this);
49  m_showTimer->setInterval(550); // 500 from KMessageWidget + 50 to make sure the show animation is really finished
50  m_showTimer->setSingleShot(true);
51  connect(m_showTimer, SIGNAL(timeout()), this, SIGNAL(widgetShown()));
52 }
53 
54 bool KateAnimation::hideAnimationActive() const
55 {
56  return m_hideTimer->isActive();
57 }
58 
59 bool KateAnimation::showAnimationActive() const
60 {
61  return m_showTimer->isActive();
62 }
63 
64 void KateAnimation::show()
65 {
66  Q_ASSERT(m_widget != 0);
67 
68  // stop hide timer if needed
69  if (m_hideTimer->isActive()) {
70  m_hideTimer->stop();
71  }
72 
73  // show according to effects config
74  if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) {
75  m_widget->show();
76  emit widgetShown();
77  } else {
78  // launch show effect
79  // NOTE: use a singleShot timer to avoid resizing issues when showing the message widget the first time (bug #316666)
80  if (m_fadeEffect) {
81  QTimer::singleShot(0, m_fadeEffect, SLOT(fadeIn()));
82  } else {
83  QTimer::singleShot(0, m_widget, SLOT(animatedShow()));
84  }
85 
86  // start timer in order to track when showing is done (this effectively works
87  // around the fact, that KMessageWidget does not have a hidden signal)
88  m_showTimer->start();
89  }
90 }
91 
92 void KateAnimation::hide()
93 {
94  Q_ASSERT(m_widget != 0);
95 
96  // stop show timer if needed
97  if (m_showTimer->isActive()) {
98  m_showTimer->stop();
99  }
100 
101  // hide according to effects config
102  if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) {
103  m_widget->hide();
104  emit widgetHidden();
105  } else {
106  // hide depending on effect
107  if (m_fadeEffect) {
108  m_fadeEffect->fadeOut();
109  } else {
110  m_widget->animatedHide();
111  }
112 
113  // start timer in order to track when hiding is done (this effectively works
114  // around the fact, that KMessageWidget does not have a hidden signal)
115  m_hideTimer->start();
116  }
117 }
118 
119 // kate: space-indent on; indent-width 2; replace-tabs on;
QTimer::setInterval
void setInterval(int msec)
KateAnimation::hideAnimationActive
bool hideAnimationActive() const
Returns true, if the hide animation is running, otherwise false.
Definition: kateanimation.cpp:54
KateAnimation::showAnimationActive
bool showAnimationActive() const
Returns true, if the how animation is running, otherwise false.
Definition: kateanimation.cpp:59
KateAnimation::KateAnimation
KateAnimation(KMessageWidget *widget, EffectType effect)
Constructor.
Definition: kateanimation.cpp:29
KateFadeEffect
This class provides a fade in/out effect for arbitrary QWidgets.
Definition: katefadeeffect.h:40
KateAnimation::widgetShown
void widgetShown()
This signal is emitted when the showing animation is finished.
KateAnimation::FadeEffect
fade in/out
Definition: kateanimation.h:50
KateAnimation::show
void show()
Call to show and fade in the widget.
Definition: kateanimation.cpp:64
katefadeeffect.h
kateanimation.h
QTimer
QObject
KateFadeEffect::fadeOut
void fadeOut()
Call to fade out and hide the widget.
Definition: katefadeeffect.cpp:59
QTimer::stop
void stop()
KateAnimation::widgetHidden
void widgetHidden()
This signal is emitted when the hiding animation is finished.
KateAnimation::EffectType
EffectType
The type of supported animation effects.
Definition: kateanimation.h:49
QTimer::start
void start(int msec)
KateAnimation::hide
void hide()
Call to hide the widget.
Definition: kateanimation.cpp:92
QTimer::isActive
bool isActive() const
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QTimer::setSingleShot
void setSingleShot(bool singleShot)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal