view/kateviewinternal.cpp
view/kateviewhelpers.cpp
view/katemessagewidget.cpp
- view/katefadeeffect.cpp
view/kateanimation.cpp
view/katetextanimation.cpp
#include "kateanimation.h"
#include "moc_kateanimation.cpp"
-#include <katefadeeffect.h>
-#include <KMessageWidget>
#include <QTimer>
+#include <KMessageWidget>
#include <kglobalsettings.h>
-KateAnimation::KateAnimation(KMessageWidget* widget, EffectType effect)
+KateAnimation::KateAnimation(KMessageWidget* widget, bool applyEffect)
: QObject(widget)
, m_widget(widget)
- , m_fadeEffect(0)
+ , m_applyEffect(applyEffect)
{
Q_ASSERT(m_widget != 0);
- // create wanted effect
- if (effect == FadeEffect) {
- m_fadeEffect = new KateFadeEffect(widget);
- }
-
// create tracking timer for hiding the widget
m_hideTimer = new QTimer(this);
m_hideTimer->setInterval(550); // 500 from KMessageWidget + 50 to make sure the hide animation is really finished
}
// show according to effects config
- if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) {
+ if (!m_applyEffect || !(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) {
m_widget->show();
emit widgetShown();
} else {
// launch show effect
// NOTE: use a singleShot timer to avoid resizing issues when showing the message widget the first time (bug #316666)
- if (m_fadeEffect) {
- QTimer::singleShot(0, m_fadeEffect, SLOT(fadeIn()));
- } else {
- QTimer::singleShot(0, m_widget, SLOT(animatedShow()));
- }
+ QTimer::singleShot(0, m_widget, SLOT(animatedShow()));
// start timer in order to track when showing is done (this effectively works
// around the fact, that KMessageWidget does not have a hidden signal)
}
// hide according to effects config
- if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) {
+ if (!m_applyEffect || !(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) {
m_widget->hide();
emit widgetHidden();
} else {
// hide depending on effect
- if (m_fadeEffect) {
- m_fadeEffect->fadeOut();
- } else {
- m_widget->animatedHide();
- }
+ m_widget->animatedHide();
// start timer in order to track when hiding is done (this effectively works
// around the fact, that KMessageWidget does not have a hidden signal)
#include <QObject>
#include <QPointer>
-
#include <QTimer>
class KMessageWidget;
-class KateFadeEffect;
+
/**
* This class provides a fade in/out effect for KMessageWidget%s.
* Example:
public:
/**
- * The type of supported animation effects
- */
- enum EffectType{
- FadeEffect = 0, ///< fade in/out
- GrowEffect ///< grow / shrink
- };
-
- public:
- /**
* Constructor.
*/
- KateAnimation(KMessageWidget* widget, EffectType effect);
+ KateAnimation(KMessageWidget* widget, bool applyEffect);
/**
* Returns true, if the hide animation is running, otherwise false.
private:
QPointer<KMessageWidget> m_widget; ///< the widget to animate
- KateFadeEffect * m_fadeEffect; ///< the fade effect
QTimer * m_hideTimer; ///< timer to track hide animation
QTimer * m_showTimer; ///< timer to track show animation
+ bool m_applyEffect;
};
#endif
+++ /dev/null
-/* This file is part of the KDE and the Kate project
- *
- * Copyright (C) 2013 Dominik Haumann <dhaumann@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "katefadeeffect.h"
-#include "moc_katefadeeffect.cpp"
-
-#include <QWidget>
-#include <QTimeLine>
-#include <QtGui/qgraphicseffect.h>
-#include <QDebug>
-
-KateFadeEffect::KateFadeEffect(QWidget* widget)
- : QObject(widget)
- , m_widget(widget)
- , m_effect(0) // effect only exists during fading animation
-{
- m_timeLine = new QTimeLine(500, this);
- m_timeLine->setUpdateInterval(40);
-
- connect(m_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(opacityChanged(qreal)));
- connect(m_timeLine, SIGNAL(finished()), this, SLOT(animationFinished()));
-}
-
-void KateFadeEffect::fadeIn()
-{
- // stop time line if still running
- if (m_timeLine->state() == QTimeLine::Running) {
- m_timeLine->stop();
- }
-
- // assign new graphics effect, old one is deleted in setGraphicsEffect()
- m_effect = new QGraphicsOpacityEffect(this);
- m_effect->setOpacity(0.0);
- m_widget->setGraphicsEffect(m_effect);
-
- // show widget and start fade in animation
- m_widget->show();
- m_timeLine->setDirection(QTimeLine::Forward);
- m_timeLine->start();
-}
-
-void KateFadeEffect::fadeOut()
-{
- // stop time line if still running
- if (m_timeLine->state() == QTimeLine::Running) {
- m_timeLine->stop();
- }
-
- // assign new graphics effect, old one is deleted in setGraphicsEffect()
- m_effect = new QGraphicsOpacityEffect(this);
- m_effect->setOpacity(1.0);
- m_widget->setGraphicsEffect(m_effect);
-
- // start fade out animation
- m_timeLine->setDirection(QTimeLine::Backward);
- m_timeLine->start();
-}
-
-void KateFadeEffect::opacityChanged(qreal value)
-{
- Q_ASSERT(m_effect);
- m_effect->setOpacity(value);
-}
-
-void KateFadeEffect::animationFinished()
-{
- // fading finished: remove graphics effect, deletes the effect as well
- m_widget->setGraphicsEffect(0);
- Q_ASSERT(!m_effect);
-
- if (m_timeLine->direction() == QTimeLine::Backward) {
- m_widget->hide();
- emit widgetHidden();
- }
-}
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
+++ /dev/null
-/* This file is part of the KDE and the Kate project
- *
- * Copyright (C) 2013 Dominik Haumann <dhaumann@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef KATE_FADE_EFFECT_H
-#define KATE_FADE_EFFECT_H
-
-#include <QObject>
-#include <QPointer>
-
-#include <QWidget>
-#include <QTimeLine>
-#include <QGraphicsOpacityEffect>
-/**
- * This class provides a fade in/out effect for arbitrary QWidget%s.
- * Example:
- * \code
- * KateFadeEffect* fadeEffect = new KateFadeEffect(someWidget);
- * fadeEffect->fadeIn();
- * //...
- * fadeEffect->fadeOut();
- * \endcode
- */
-class KateFadeEffect : public QObject
-{
- Q_OBJECT
-
- public:
- /**
- * Constructor.
- * By default, the widget is fully opaque (opacity = 1.0).
- */
- KateFadeEffect(QWidget* widget = 0);
-
- public Q_SLOTS:
- /**
- * Call to fade out and hide the widget.
- */
- void fadeOut();
- /**
- * Call to show and fade in the widget
- */
- void fadeIn();
-
- Q_SIGNALS:
- /**
- * This signal is emitted when the hiding animation is finished.
- * At this point, the associated widget is hidden.
- */
- void widgetHidden();
-
- protected Q_SLOTS:
- /**
- * Helper to update opacity value
- */
- void opacityChanged(qreal value);
- /**
- * When the animation is finished, hide the widget if fading out.
- */
- void animationFinished();
-
- private:
- QPointer<QWidget> m_widget; ///< the fading widget
- QTimeLine* m_timeLine; ///< update time line
- QPointer<QGraphicsOpacityEffect> m_effect; ///< graphics opacity effect
-};
-
-#endif
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
hide();
// create animation controller, and connect widgetHidden() to showNextMessage()
- m_animation = new KateAnimation(m_messageWidget, applyFadeEffect ? KateAnimation::FadeEffect : KateAnimation::GrowEffect);
+ m_animation = new KateAnimation(m_messageWidget, applyFadeEffect);
connect(m_animation, SIGNAL(widgetHidden()), this, SLOT(showNextMessage()));
// setup autoHide timer details