1
/* This file is part of the KDE and the Kate project
3
* Copyright (C) 2013 Dominik Haumann <dhaumann@kde.org>
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.
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.
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.
21
#include "kateanimation.h"
22
#include "kateanimation.moc"
23
#include <katefadeeffect.h>
25
#include <KMessageWidget>
27
#include <kglobalsettings.h>
29
KateAnimation::KateAnimation(KMessageWidget* widget, EffectType effect)
34
Q_ASSERT(m_widget != 0);
36
// create wanted effect
37
if (effect == FadeEffect) {
38
m_fadeEffect = new KateFadeEffect(widget);
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()));
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()));
54
bool KateAnimation::hideAnimationActive() const
56
return m_hideTimer->isActive();
59
bool KateAnimation::showAnimationActive() const
61
return m_showTimer->isActive();
64
void KateAnimation::show()
66
Q_ASSERT(m_widget != 0);
68
// stop hide timer if needed
69
if (m_hideTimer->isActive()) {
73
// show according to effects config
74
if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) {
79
// NOTE: use a singleShot timer to avoid resizing issues when showing the message widget the first time (bug #316666)
81
QTimer::singleShot(0, m_fadeEffect, SLOT(fadeIn()));
83
QTimer::singleShot(0, m_widget, SLOT(animatedShow()));
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)
92
void KateAnimation::hide()
94
Q_ASSERT(m_widget != 0);
96
// stop show timer if needed
97
if (m_showTimer->isActive()) {
101
// hide according to effects config
102
if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) {
106
// hide depending on effect
108
m_fadeEffect->fadeOut();
110
m_widget->animatedHide();
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();
119
// kate: space-indent on; indent-width 2; replace-tabs on;