From f54c727f9232cf23440f63eabbb218c31d3739e3 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 4 Oct 2015 20:17:40 +0300 Subject: [PATCH] plasm: drop animations support this will (most importantly) break some applets from kde-workspace and could use a review + some cleanups (like headers inclusions, variables declarations, etc.) but it's pretty much complete --- includes/CMakeLists.txt | 2 - includes/Plasma/Animation | 1 - includes/Plasma/Animator | 1 - plasma/CMakeLists.txt | 27 -- plasma/animations/animation.cpp | 92 ---- plasma/animations/animation.h | 153 ------- plasma/animations/animationscriptengine.cpp | 219 --------- plasma/animations/animationscriptengine_p.h | 49 -- plasma/animations/bindings/easingcurve.cpp | 172 ------- plasma/animations/easinganimation.cpp | 39 -- plasma/animations/easinganimation_p.h | 46 -- plasma/animations/fade.cpp | 86 ---- plasma/animations/fade_p.h | 99 ----- plasma/animations/geometry.cpp | 99 ----- plasma/animations/geometry_p.h | 97 ---- plasma/animations/grow.cpp | 99 ----- plasma/animations/grow_p.h | 89 ---- plasma/animations/javascriptanimation.cpp | 124 ------ plasma/animations/javascriptanimation_p.h | 68 --- plasma/animations/pendulumcurve.cpp | 54 --- plasma/animations/pendulumcurve_p.h | 44 -- plasma/animations/pixmaptransition.cpp | 180 -------- plasma/animations/pixmaptransition_p.h | 111 ----- plasma/animations/pulser.cpp | 144 ------ plasma/animations/pulser_p.h | 110 ----- plasma/animations/rotation.cpp | 168 ------- plasma/animations/rotation_p.h | 123 ------ plasma/animations/rotationstacked.cpp | 188 -------- plasma/animations/rotationstacked_p.h | 126 ------ plasma/animations/slide.cpp | 129 ------ plasma/animations/slide_p.h | 99 ----- plasma/animations/stackedlayout.cpp | 108 ----- plasma/animations/stackedlayout.h | 54 --- plasma/animations/water.cpp | 69 --- plasma/animations/water_p.h | 68 --- plasma/animations/widgetsnapshot.cpp | 128 ------ plasma/animations/widgetsnapshot_p.h | 59 --- plasma/animations/zoom.cpp | 76 ---- plasma/animations/zoom_p.h | 60 --- plasma/animator.cpp | 216 --------- plasma/animator.h | 219 --------- plasma/applet.cpp | 26 +- plasma/applet.h | 4 - plasma/containment.cpp | 25 +- plasma/containment.h | 2 - plasma/corona.cpp | 12 - plasma/corona.h | 18 - .../data/servicetypes/plasma-animator.desktop | 83 ---- plasma/dataengine.cpp | 3 +- plasma/dialog.cpp | 1 - plasma/private/abstractanimationprivate_p.h | 69 --- plasma/private/animationprivate_p.h | 51 --- plasma/private/animator_p.h | 146 ------ plasma/private/applet_p.h | 1 - plasma/private/applethandle_p.h | 1 - plasma/private/focusindicator.cpp | 69 +-- plasma/private/focusindicator_p.h | 5 - plasma/private/nativetabbar.cpp | 58 +-- plasma/private/nativetabbar_p.h | 2 - plasma/scripting/appletscript.cpp | 42 -- plasma/scripting/appletscript.h | 8 - plasma/theme.cpp | 41 -- plasma/theme.h | 9 - plasma/widgets/flashinglabel.cpp | 48 +- plasma/widgets/iconwidget.cpp | 68 +-- plasma/widgets/iconwidget.h | 2 - plasma/widgets/iconwidget_p.h | 1 - plasma/widgets/itembackground.cpp | 18 +- plasma/widgets/meter.cpp | 13 - plasma/widgets/pushbutton.cpp | 44 +- plasma/widgets/pushbutton.h | 1 - plasma/widgets/scrollwidget.cpp | 418 ------------------ plasma/widgets/scrollwidget.h | 3 - plasma/widgets/tabbar.cpp | 47 +- plasma/widgets/tabbar.h | 4 +- plasma/widgets/toolbutton.cpp | 1 - plasma/widgets/videowidget.cpp | 14 - plasma/widgets/webview.cpp | 1 - 78 files changed, 21 insertions(+), 5433 deletions(-) delete mode 100644 includes/Plasma/Animation delete mode 100644 includes/Plasma/Animator delete mode 100644 plasma/animations/animation.cpp delete mode 100644 plasma/animations/animation.h delete mode 100644 plasma/animations/animationscriptengine.cpp delete mode 100644 plasma/animations/animationscriptengine_p.h delete mode 100644 plasma/animations/bindings/easingcurve.cpp delete mode 100644 plasma/animations/easinganimation.cpp delete mode 100644 plasma/animations/easinganimation_p.h delete mode 100644 plasma/animations/fade.cpp delete mode 100644 plasma/animations/fade_p.h delete mode 100644 plasma/animations/geometry.cpp delete mode 100644 plasma/animations/geometry_p.h delete mode 100644 plasma/animations/grow.cpp delete mode 100644 plasma/animations/grow_p.h delete mode 100644 plasma/animations/javascriptanimation.cpp delete mode 100644 plasma/animations/javascriptanimation_p.h delete mode 100644 plasma/animations/pendulumcurve.cpp delete mode 100644 plasma/animations/pendulumcurve_p.h delete mode 100644 plasma/animations/pixmaptransition.cpp delete mode 100644 plasma/animations/pixmaptransition_p.h delete mode 100644 plasma/animations/pulser.cpp delete mode 100644 plasma/animations/pulser_p.h delete mode 100644 plasma/animations/rotation.cpp delete mode 100644 plasma/animations/rotation_p.h delete mode 100644 plasma/animations/rotationstacked.cpp delete mode 100644 plasma/animations/rotationstacked_p.h delete mode 100644 plasma/animations/slide.cpp delete mode 100644 plasma/animations/slide_p.h delete mode 100644 plasma/animations/stackedlayout.cpp delete mode 100644 plasma/animations/stackedlayout.h delete mode 100644 plasma/animations/water.cpp delete mode 100644 plasma/animations/water_p.h delete mode 100644 plasma/animations/widgetsnapshot.cpp delete mode 100644 plasma/animations/widgetsnapshot_p.h delete mode 100644 plasma/animations/zoom.cpp delete mode 100644 plasma/animations/zoom_p.h delete mode 100644 plasma/animator.cpp delete mode 100644 plasma/animator.h delete mode 100644 plasma/data/servicetypes/plasma-animator.desktop delete mode 100644 plasma/private/abstractanimationprivate_p.h delete mode 100644 plasma/private/animationprivate_p.h delete mode 100644 plasma/private/animator_p.h diff --git a/includes/CMakeLists.txt b/includes/CMakeLists.txt index 75e4958f..655ce6ab 100644 --- a/includes/CMakeLists.txt +++ b/includes/CMakeLists.txt @@ -733,8 +733,6 @@ install(FILES Plasma/AbstractDialogManager Plasma/AbstractRunner Plasma/AbstractToolBox - Plasma/Animation - Plasma/Animator Plasma/Applet Plasma/AppletScript Plasma/BusyWidget diff --git a/includes/Plasma/Animation b/includes/Plasma/Animation deleted file mode 100644 index d42a0dee..00000000 --- a/includes/Plasma/Animation +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/animation.h" diff --git a/includes/Plasma/Animator b/includes/Plasma/Animator deleted file mode 100644 index 3be3eaab..00000000 --- a/includes/Plasma/Animator +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/animator.h" diff --git a/plasma/CMakeLists.txt b/plasma/CMakeLists.txt index 13627ab8..42ca2bae 100644 --- a/plasma/CMakeLists.txt +++ b/plasma/CMakeLists.txt @@ -51,25 +51,6 @@ set(plasma_LIB_SRCS package.cpp abstractrunner.cpp abstracttoolbox.cpp - animator.cpp - animations/animation.cpp - animations/animationscriptengine.cpp - animations/bindings/easingcurve.cpp - animations/easinganimation.cpp - animations/fade.cpp - animations/grow.cpp - animations/javascriptanimation.cpp - animations/pendulumcurve.cpp - animations/pixmaptransition.cpp - animations/pulser.cpp - animations/rotation.cpp - animations/rotationstacked.cpp - animations/slide.cpp - animations/stackedlayout.cpp - animations/geometry.cpp - animations/water.cpp - animations/widgetsnapshot.cpp - animations/zoom.cpp applet.cpp configloader.cpp containment.cpp @@ -218,8 +199,6 @@ set(plasma_LIB_INCLUDES abstractdialogmanager.h abstractrunner.h abstracttoolbox.h - animations/animation.h - animator.h applet.h configloader.h containment.h @@ -304,12 +283,6 @@ if(PHONON_FOUND) endif(PHONON_FOUND) install(FILES - animations/animation.h - DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/animations COMPONENT Devel) - - -install(FILES - data/servicetypes/plasma-animator.desktop data/servicetypes/plasma-applet.desktop data/servicetypes/plasma-applet-popupapplet.desktop data/servicetypes/plasma-containment.desktop diff --git a/plasma/animations/animation.cpp b/plasma/animations/animation.cpp deleted file mode 100644 index ba51e931..00000000 --- a/plasma/animations/animation.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2009 Mehmet Ali Akmanalp - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "animation.h" -#include "private/animationprivate_p.h" - -#include -#include -#include -#include -#include -#include -#include - -namespace Plasma -{ - - -AnimationPrivate::AnimationPrivate() - : easingCurve(QEasingCurve::Linear), - duration(250) -{ -} - -Animation::Animation(QObject* parent) - : QAbstractAnimation(parent), - d(new AnimationPrivate) -{ -} - -Animation::~Animation() -{ - delete d; -} - -int Animation::duration() const -{ - return d->duration; -} - -void Animation::setDuration(int duration) -{ - d->duration = qMax(0, duration); -} - -void Animation::setTargetWidget(QGraphicsWidget* widget) -{ - d->animObject = widget; - if (parent() == 0) { - setParent(widget); - } -} - -QGraphicsWidget* Animation::targetWidget() const -{ - return d->animObject.data(); -} - -void Animation::setEasingCurve(const QEasingCurve &curve) -{ - d->easingCurve = curve; -} - -QEasingCurve Animation::easingCurve() const -{ - return d->easingCurve; -} - -void Animation::updateCurrentTime(int currentTime) -{ - Q_UNUSED(currentTime) -} - -} //namespace Plasma - -#include "moc_animation.cpp" diff --git a/plasma/animations/animation.h b/plasma/animations/animation.h deleted file mode 100644 index 00e8ad0a..00000000 --- a/plasma/animations/animation.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2009 Mehmet Ali Akmanalp - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file This file contains the abstract base class for all singular - * animations. - */ - -#ifndef PLASMA_ANIMATION_H -#define PLASMA_ANIMATION_H - -#include -#include -#include -#include -#include - -#include -#include - -namespace Plasma -{ - -class AnimationPrivate; - -/** - * @brief Abstract representation of a single animation. - * @since 4.4 - */ -class PLASMA_EXPORT Animation : public QAbstractAnimation -{ - - Q_OBJECT - Q_ENUMS(Reference) - Q_ENUMS(MovementDirection) - Q_PROPERTY(int duration READ duration WRITE setDuration) - Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve) - Q_PROPERTY(QGraphicsWidget *targetWidget READ targetWidget WRITE setTargetWidget) - -public: - /** - * Get the animation duration. It can be set using the property duration. - * @return duration in ms. - */ - int duration() const; - - /** - * Animation movement reference (used by \ref RotationAnimation). - */ - enum ReferenceFlag { - Center = 0, - Up = 0x1, - Down = 0x2, - Left = 0x4, - Right = 0x8 - }; - - Q_DECLARE_FLAGS(Reference, ReferenceFlag) - - /** - * Animation movement direction. - */ - enum MovementDirectionFlag { - MoveAny = 0, - MoveUp = 0x1, - MoveRight = 0x2, - MoveDown = 0x4, - MoveLeft = 0x8 - }; - - Q_DECLARE_FLAGS(MovementDirection, MovementDirectionFlag) - - /** - * Default constructor. - * - * @param parent Object parent (might be set when using - * \ref Animator::create factory). - * - */ - explicit Animation(QObject* parent = 0); - - /** - * Destructor. - */ - ~Animation() = 0; - - /** - * Set the widget on which the animation is to be performed. - * @param widget The QGraphicsWidget to be animated. - */ - void setTargetWidget(QGraphicsWidget* widget); - - /** - * @return The widget that the animation will be performed upon - */ - QGraphicsWidget *targetWidget() const; - - /** - * Set the animation easing curve type - */ - void setEasingCurve(const QEasingCurve &curve); - - /** - * Get the animation easing curve type - */ - QEasingCurve easingCurve() const; - -protected: - /** - * Change the animation duration. Default is 250ms. - * @param duration The new duration of the animation. - */ - virtual void setDuration(int duration = 250); - - /** - * QAbstractAnimation will call this method while the animation - * is running. Each specialized animation class should implement - * the correct behavior for it. - * @param currentTime Slapsed time using the \ref duration as reference - * (it will be from duration up to zero if the animation is running - * backwards). - */ - virtual void updateCurrentTime(int currentTime); - -private: - - /** - * Internal pimple (actually is used as a data structure, see - * \ref AnimationPrivate). - */ - AnimationPrivate *const d; - -}; - -} //namespace Plasma - -#endif diff --git a/plasma/animations/animationscriptengine.cpp b/plasma/animations/animationscriptengine.cpp deleted file mode 100644 index 70fec0ce..00000000 --- a/plasma/animations/animationscriptengine.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright 2010 Aaron Seigo - * Copyright 2010 Adenilson Cavalcanti - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/* TODO: - * - * - cleanup debug messages - */ - -#include "animationscriptengine_p.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "animator.h" -#include "javascriptanimation_p.h" - -namespace Plasma -{ - -QScriptValue constructEasingCurveClass(QScriptEngine *engine); - -namespace AnimationScriptEngine -{ - -QScriptEngine* inst = 0; -QHash s_animFuncs; -QSet s_animFailures; -QString s_prefix; - -QScriptValue animation(const QString &anim) -{ - return s_animFuncs.value(anim); -} - -bool isAnimationRegistered(const QString &anim) -{ - return s_animFuncs.contains(anim); -} - -void addToLoadFailures(const QString &anim) -{ - s_animFailures.insert(anim); -} - -bool animationFailedToLoad(const QString &anim) -{ - return s_animFailures.contains(anim); -} - -void clearAnimations() -{ - s_animFuncs.clear(); - s_animFailures.clear(); - delete inst; - inst = 0; -} - -QScriptValue registerAnimation(QScriptContext *context, QScriptEngine *engine) -{ - if (context->argumentCount() > 1) { - const QString name = s_prefix + context->argument(0).toString(); - - if (!s_animFuncs.contains(name)) { - const QScriptValue func = context->argument(1); - if (func.isFunction()) { - s_animFuncs.insert(name, func); - } - } - } - - return engine->undefinedValue(); -} - -QObject *extractParent(QScriptContext *context, QScriptEngine *engine) -{ - Q_UNUSED(engine) - return context->thisObject().property("__plasma_javascriptanimation").toQObject(); -} - -QScriptValue animationGroup(QScriptContext *context, QScriptEngine *engine) -{ - QObject *parent = extractParent(context, engine); - if (!parent) { - return engine->undefinedValue(); - } - - QSequentialAnimationGroup *group = new QSequentialAnimationGroup(parent); - return engine->newQObject(group); -} - -QScriptValue parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine) -{ - QObject *parent = extractParent(context, engine); - if (!parent) { - return engine->undefinedValue(); - } - - QParallelAnimationGroup *group = new QParallelAnimationGroup(parent); - return engine->newQObject(group); -} - -void registerEnums(QScriptValue &scriptValue, const QMetaObject &meta) -{ - //manually create enum values. ugh - QScriptEngine *engine = scriptValue.engine(); - for (int i = 0; i < meta.enumeratorCount(); ++i) { - QMetaEnum e = meta.enumerator(i); - //kDebug() << e.name(); - for (int i=0; i < e.keyCount(); ++i) { - //kDebug() << e.key(i) << e.value(i); - scriptValue.setProperty(e.key(i), QScriptValue(engine, e.value(i))); - } - } -} - -QScriptValue animation(QScriptContext *context, QScriptEngine *engine) -{ - if (context->argumentCount() != 1) { - return context->throwError(i18n("animation() takes one argument")); - } - - QObject *parent = extractParent(context, engine); - QAbstractAnimation *anim = 0; - if (context->argument(0).isString()) { - const QString animName = context->argument(0).toString(); - anim = Plasma::Animator::create(animName, parent); - } else { - int animId = context->argument(0).toInt32(); - if (animId == JavascriptAnimation::PauseAnimation) { - anim = new QPauseAnimation(parent); - } else if (animId == JavascriptAnimation::PropertyAnimation) { - anim = new QPropertyAnimation(parent); - } else { - anim = Plasma::Animator::create(static_cast(animId), parent); - } - } - - if (anim) { - QScriptValue value = engine->newQObject(anim); - registerEnums(value, *anim->metaObject()); - return value; - } - - return context->throwError(i18n("%1 is not a known animation type", context->argument(0).isString())); -} - -QScriptEngine *globalEngine() -{ - if (!inst) { - inst = new QScriptEngine; - QScriptValue global = inst->globalObject(); - global.setProperty("registerAnimation", inst->newFunction(AnimationScriptEngine::registerAnimation)); - global.setProperty("AnimationGroup", inst->newFunction(AnimationScriptEngine::animationGroup)); - global.setProperty("ParallelAnimationGroup", inst->newFunction(AnimationScriptEngine::parallelAnimationGroup)); - global.setProperty("QEasingCurve", constructEasingCurveClass(inst)); - kDebug() << "........... first js animation, creating the engine!"; - } - - return inst; -} - -bool loadScript(const QString &path, const QString &prefix) -{ - QFile file(path); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - kError() << "failed to open script file" << path; - return false; - } - - QTextStream buffer(&file); - QString tmp(buffer.readAll()); - - QScriptEngine *engine = AnimationScriptEngine::globalEngine(); - engine->pushContext(); - s_prefix = prefix; - QScriptValue def(engine->evaluate(tmp, path)); - s_prefix.clear(); - engine->popContext(); - if (engine->hasUncaughtException()) { - const QScriptValue error = engine->uncaughtException(); - QString file = error.property("fileName").toString(); - const QString failureMsg = QString("Error in %1 on line %2.\n%3") - .arg(file) - .arg(error.property("lineNumber").toString()) - .arg(error.toString()); - kError() << failureMsg; - return false; - } - - return true; -} - -} // namespace AnimationEngine -} // namespace Plasma - diff --git a/plasma/animations/animationscriptengine_p.h b/plasma/animations/animationscriptengine_p.h deleted file mode 100644 index 59694a7a..00000000 --- a/plasma/animations/animationscriptengine_p.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2010 Aaron Seigo - * Copyright 2010 Adenilson Cavalcanti - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __ENGINE__ -#define __ENGINE__ - -#include -#include -#include -#include -#include - -/* Plasma-shell will have an engine */ -namespace Plasma -{ - -namespace AnimationScriptEngine -{ - -void clearAnimations(); -bool isAnimationRegistered(const QString &anim); -QScriptEngine* globalEngine(); -QScriptValue animation(const QString &anim); -bool loadScript(const QString &path, const QString &prefix = QString()); -void addToLoadFailures(const QString &anim); -bool animationFailedToLoad(const QString &anim); - -} - -} // namespace Plasma - -#endif diff --git a/plasma/animations/bindings/easingcurve.cpp b/plasma/animations/bindings/easingcurve.cpp deleted file mode 100644 index 830db2bb..00000000 --- a/plasma/animations/bindings/easingcurve.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2010 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE(QEasingCurve) -Q_DECLARE_METATYPE(QEasingCurve*) -#define ADD_ENUM_VALUE(__c__, __ns__, __v__) \ - __c__.setProperty(#__v__, QScriptValue(__c__.engine(), __ns__::__v__)) - -#define DECLARE_SELF(Class, __fn__) \ - Class* self = qscriptvalue_cast(ctx->thisObject()); \ - if (!self) { \ - return ctx->throwError(QScriptContext::TypeError, \ - QString::fromLatin1("%0.prototype.%1: this object is not a %0") \ - .arg(#Class).arg(#__fn__)); \ - } - -namespace Plasma -{ - -static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng) -{ - if (ctx->argumentCount() > 0) { - QScriptValue arg = ctx->argument(0); - if (arg.isNumber()) { - qint32 type = arg.toInt32(); - if (type > -1 && type < QEasingCurve::Custom) { - return qScriptValueFromValue(eng, QEasingCurve(static_cast(type))); - } - } - } - - return qScriptValueFromValue(eng, QEasingCurve()); -} - -static QScriptValue toString(QScriptContext *ctx, QScriptEngine *eng) -{ - DECLARE_SELF(QEasingCurve, toString); - return QScriptValue(eng, QString::fromLatin1("QEasingCurve(type=%0)").arg(self->type())); -} - -static QScriptValue type(QScriptContext *ctx, QScriptEngine *eng) -{ - DECLARE_SELF(QEasingCurve, type); - - if (ctx->argumentCount()) { - QScriptValue arg = ctx->argument(0); - - qint32 type = -1; - if (arg.isNumber()) { - type = arg.toInt32(); - } else if (arg.isString()) { - QMetaObject meta = QEasingCurve::staticMetaObject; - QMetaEnum easingCurveEnum = meta.enumerator(meta.indexOfEnumerator("Type")); - - type = easingCurveEnum.keyToValue(arg.toString().toLatin1().data()); - } - if (type > -1 && type < QEasingCurve::Custom) { - self->setType(static_cast(type)); - } - } - - return QScriptValue(eng, self->type()); -} - -static QScriptValue valueForProgress(QScriptContext *ctx, QScriptEngine *eng) -{ - DECLARE_SELF(QEasingCurve, valueForProgress); - if (ctx->argumentCount() < 1 || !ctx->argument(0).isNumber()) { - return eng->undefinedValue(); - } - - return self->valueForProgress(ctx->argument(0).toNumber()); -} - -QScriptValue constructEasingCurveClass(QScriptEngine *eng) -{ - QScriptValue proto = qScriptValueFromValue(eng, QEasingCurve()); - QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter; - QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter; - - proto.setProperty("type", eng->newFunction(type), getter | setter); - proto.setProperty("toString", eng->newFunction(toString), getter); - proto.setProperty("valueForProgress", eng->newFunction(valueForProgress), getter); - - QScriptValue ctorFun = eng->newFunction(ctor, proto); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, Linear); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuad); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuad); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuad); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuad); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCubic); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCubic); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutCubic); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInCubic); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuart); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuart); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuart); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuart); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuint); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuint); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuint); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuint); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InSine); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutSine); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutSine); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInSine); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InExpo); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutExpo); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutExpo); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInExpo); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCirc); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCirc); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutCirc); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInCirc); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InElastic); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutElastic); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutElastic); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInElastic); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InBack); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutBack); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutBack); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInBack); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InBounce); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutBounce); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutBounce); - - ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCurve); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCurve); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, SineCurve); - ADD_ENUM_VALUE(ctorFun, QEasingCurve, CosineCurve); - - eng->setDefaultPrototype(qMetaTypeId(), proto); - eng->setDefaultPrototype(qMetaTypeId(), proto); - - return ctorFun; -} - -} - diff --git a/plasma/animations/easinganimation.cpp b/plasma/animations/easinganimation.cpp deleted file mode 100644 index 125222ff..00000000 --- a/plasma/animations/easinganimation.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2010 Aaron Seigo - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "easinganimation_p.h" -#include - -namespace Plasma -{ - -EasingAnimation::EasingAnimation(QObject *parent) - : Animation(parent) -{ -} - -void EasingAnimation::updateCurrentTime(int currentTime) -{ - updateEffectiveTime(easingCurve().valueForProgress(currentTime / qreal(qMax(1, duration()))) * duration()); -} - -} // namespace Plasma - -#include "moc_easinganimation_p.cpp" - diff --git a/plasma/animations/easinganimation_p.h b/plasma/animations/easinganimation_p.h deleted file mode 100644 index 99ac3b2f..00000000 --- a/plasma/animations/easinganimation_p.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2010 Aaron Seigo - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef PLASMA_EASINGANIMATION_H -#define PLASMA_EASINGANIMATION_H - -#include "animation.h" - -namespace Plasma -{ - - -class EasingAnimation : public Animation -{ - Q_OBJECT - -public: - explicit EasingAnimation(QObject *parent = 0); - -protected: - virtual void updateEffectiveTime(int currentTime) = 0; - -private: - void updateCurrentTime(int currentTime); -}; - -} // namespace Plasma - -#endif // PLASMA_EASINGANIMATION_H - diff --git a/plasma/animations/fade.cpp b/plasma/animations/fade.cpp deleted file mode 100644 index 44ef63d4..00000000 --- a/plasma/animations/fade.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2009 Mehmet Ali Akmanalp - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "fade_p.h" - -#include - -#include - -namespace Plasma -{ - -FadeAnimation::FadeAnimation(QObject *parent) - : EasingAnimation(parent), - m_startOpacity(0), - m_targetOpacity(1) -{ -} - -FadeAnimation::~FadeAnimation() -{ -} - -void FadeAnimation::setStartOpacity(qreal factor) -{ - m_startOpacity = qBound(qreal(0.0), factor, qreal(1.0)); -} - -qreal FadeAnimation::startOpacity() const -{ - return m_startOpacity; -} - -void FadeAnimation::setTargetOpacity(qreal factor) -{ - m_targetOpacity = qBound(qreal(0.0), factor, qreal(1.0)); -} - -qreal FadeAnimation::targetOpacity() const -{ - return m_targetOpacity; -} - -void FadeAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -{ - QGraphicsWidget *w = targetWidget(); - if (!w) { - return; - } - - if (oldState == Stopped && newState == Running) { - w->setOpacity(direction() == Forward ? m_startOpacity : m_targetOpacity); - } else if (newState == Stopped) { - w->setOpacity(direction() == Forward ? m_targetOpacity : m_startOpacity); - } -} - -void FadeAnimation::updateEffectiveTime(int currentTime) -{ - QGraphicsWidget *w = targetWidget(); - if (w) { - qreal delta = currentTime / qreal(duration()); - delta *= m_startOpacity - m_targetOpacity; - w->setOpacity(m_startOpacity - delta); - } -} - -} //namespace Plasma - -#include "moc_fade_p.cpp" diff --git a/plasma/animations/fade_p.h b/plasma/animations/fade_p.h deleted file mode 100644 index 27af7d29..00000000 --- a/plasma/animations/fade_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2009 Mehmet Ali Akmanalp - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file This file contains the definition for the Fade effect. - */ - -#ifndef PLASMA_ANIMATIONS_FADE_P_H -#define PLASMA_ANIMATIONS_FADE_P_H - -#include -#include - -namespace Plasma -{ - -/** - * @class Fade plasma/animations/fade.h - * @short Fade effect - * - * Effect that slowly transforms the opacity of the object from a starting - * value to a target value. The range is 0 (full translucent) to 1 (full - * opaque). - */ -class FadeAnimation : public EasingAnimation -{ - Q_OBJECT - Q_PROPERTY(qreal startOpacity READ startOpacity WRITE setStartOpacity) - Q_PROPERTY(qreal targetOpacity READ targetOpacity WRITE setTargetOpacity) - -public: - /** Default constructor */ - explicit FadeAnimation(QObject *parent = 0); - - /** Destructor */ - virtual ~FadeAnimation(); - - /** - * Access start opacity of the target widget. - * - * You can set both a start and an end opacity for an widget when - * using this animation class. See \ref setStartOpacity. - * @return The opacity (range is 0 to 1). - */ - qreal startOpacity() const; - /** - * Set the start opacity of the target widget. - * - * See also \ref targetOpacity. - * @param qreal The opacity (range is 0 to 1). - */ - void setStartOpacity(qreal); - - /** - * Access final opacity of the target widget. - * - * You can set both a start and an end opacity for an widget when - * using this animation class. See \ref setTargetOpacity. - * @return The opacity (range is 0 to 1). - */ - qreal targetOpacity() const; - /** - * Set the final opacity of the target widget. - * - * See also \ref startOpacity. - * @param qreal The opacity (range is 0 to 1). - */ - void setTargetOpacity(qreal); - -protected: - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); - void updateEffectiveTime(int currentTime); - -private: - /** Initial opacity */ - qreal m_startOpacity; - /** Final opacity */ - qreal m_targetOpacity; -}; - -} - -#endif // PLASMA_ANIMATIONS_FADE_P_H diff --git a/plasma/animations/geometry.cpp b/plasma/animations/geometry.cpp deleted file mode 100644 index a417904d..00000000 --- a/plasma/animations/geometry.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2009 Igor Trindade Oliveira - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "geometry_p.h" - -#include - -#include - -namespace Plasma -{ - -GeometryAnimation::GeometryAnimation(QObject *parent) - : EasingAnimation(parent), - m_startGeometry(-1, -1, -1, -1) -{ -} - -GeometryAnimation::~GeometryAnimation() -{ -} - -void GeometryAnimation::setStartGeometry(const QRectF &geometry) -{ - m_startGeometry = geometry; -} - -QRectF GeometryAnimation::startGeometry() const -{ - return m_startGeometry; -} - -void GeometryAnimation::setTargetGeometry(const QRectF &geometry) -{ - m_targetGeometry = geometry; -} - -QRectF GeometryAnimation::targetGeometry() const -{ - return m_targetGeometry; -} - -void GeometryAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -{ - QGraphicsWidget *w = targetWidget(); - if (!w) { - return; - } - - if (m_startGeometry == QRectF(-1, -1, -1, -1)) { - m_startGeometry = w->geometry(); - } - - if (oldState == Stopped && newState == Running) { - w->setGeometry(direction() == Forward ? m_startGeometry : m_targetGeometry); - } else if (newState == Stopped) { - w->setGeometry(direction() == Forward ? m_targetGeometry : m_startGeometry); - } -} - -void GeometryAnimation::updateEffectiveTime(int currentTime) -{ - QGraphicsWidget *w = targetWidget(); - if (w) { - const qreal delta = currentTime / qreal(duration()); - - QRectF newGeo; - - newGeo.moveTopLeft(QPointF(m_startGeometry.left()*(1-delta) + m_targetGeometry.left()*(delta), - m_startGeometry.top()*(1-delta) + m_targetGeometry.top()*(delta))); - if (m_startGeometry.size() != m_targetGeometry.size()) { - newGeo.setSize(QSizeF(m_startGeometry.width()*(1-delta) + m_targetGeometry.width()*(delta), - m_startGeometry.height()*(1-delta) + m_targetGeometry.height()*(delta))); - } else { - newGeo.setSize(m_targetGeometry.size()); - } - w->setGeometry(newGeo); - } -} - -} //namespace Plasma - -#include "moc_geometry_p.cpp" diff --git a/plasma/animations/geometry_p.h b/plasma/animations/geometry_p.h deleted file mode 100644 index 52a405b8..00000000 --- a/plasma/animations/geometry_p.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2009 Igor Trindade Oliveira - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file This file contains the definition for the Geometry effect. - */ - -#ifndef PLASMA_ANIMATIONS_GEOMETRY_P_H -#define PLASMA_ANIMATIONS_GEOMETRY_P_H - -#include -#include - -namespace Plasma -{ - -/** - * @class GeometryAnimation plasma/animations/geo_p.h - * @short Geometry Animation - * Use this class when you want to change the geometry of an QGraphicsWidget - * in an animated way (you should at least set the target geometry). - */ -class GeometryAnimation : public EasingAnimation -{ - Q_OBJECT - Q_PROPERTY(QRectF startGeometry READ startGeometry WRITE setStartGeometry) - Q_PROPERTY(QRectF targetGeometry READ targetGeometry WRITE setTargetGeometry) - -public: - /** Default constructor */ - explicit GeometryAnimation(QObject *parent = 0); - - /** Destructor */ - virtual ~GeometryAnimation(); - - /** - * Access the initial geometry of animated widget. - * - * If no geometry is set, it will use the widget current geometry - * when the animation is first run). - * @return Start geometry. - */ - QRectF startGeometry() const; - /** - * Set the initial geometry of animated widget. - * - * If no geometry is set, it will use the widget current geometry - * when the animation is first run). - * @param geometry The initial geometry. - */ - void setStartGeometry(const QRectF &geometry); - - /** - * Access the final geometry of animated widget. - * - * \todo: check if it was set and case negative, handle the error. - * @return Target geometry. - */ - QRectF targetGeometry() const; - /** - * Set the final geometry of animated widget. - * - * See also \ref setStartGeometry. - * @param geometry Returns the target geometry of animated widget. - */ - void setTargetGeometry(const QRectF &geometry); - -protected: - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); - void updateEffectiveTime(int currentTime); - -private: - /** Initial geometry */ - QRectF m_startGeometry; - /** Final geometry */ - QRectF m_targetGeometry; -}; - -} // PLASMA_ANIMATIONS_GEOMETRY_P_H - -#endif diff --git a/plasma/animations/grow.cpp b/plasma/animations/grow.cpp deleted file mode 100644 index 40a576b4..00000000 --- a/plasma/animations/grow.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2009 Mehmet Ali Akmanalp - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "grow_p.h" - -#include -#include - -namespace Plasma -{ - -GrowAnimation::GrowAnimation(QObject *parent, qreal factor) - : EasingAnimation(parent), m_animFactor(factor) -{ -} - -void GrowAnimation::setFactor(const qreal factor) -{ - m_animFactor = qMax(qreal(0.0), factor); -} - -qreal GrowAnimation::factor() const -{ - return m_animFactor; -} - -void GrowAnimation::updateEffectiveTime(int currentTime) -{ - QGraphicsWidget *w = targetWidget(); - if (w && state() == QAbstractAnimation::Running) { - const qreal delta = currentTime / qreal(duration()); - QRectF geometry; - geometry.setTopLeft(m_startGeometry.topLeft() * (1-delta) + (m_targetGeometry.topLeft() * delta)); - geometry.setSize(m_startGeometry.size() * (1-delta) + (m_targetGeometry.size() * delta)); - w->setGeometry(geometry); - } -} - -void GrowAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -{ - if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) { - QGraphicsWidget *widget = targetWidget(); - if (!widget) { - return; - } - - QSizeF minimum = widget->effectiveSizeHint(Qt::MinimumSize); - QSizeF maximum = widget->effectiveSizeHint(Qt::MaximumSize); - m_startGeometry = widget->geometry(); - qreal w = m_startGeometry.width(); - qreal h = m_startGeometry.height(); - qreal factor = m_animFactor; - - //compute new geometry values - qreal newWidth; - qreal newHeight; - if (direction() == QAbstractAnimation::Forward) { - newWidth = qBound(minimum.width(), w * factor, maximum.width()); - newHeight = qBound(minimum.height(), h * factor, maximum.height()); - } else { - newWidth = qBound(minimum.width(), w / factor, maximum.width()); - newHeight = qBound(minimum.height(), h / factor, maximum.height()); - } - - qreal newX; - qreal newY; - newX = m_startGeometry.x() - (newWidth - w)/2; - newY = m_startGeometry.y() - (newHeight - h)/2; - - if (direction() == QAbstractAnimation::Forward) { - //the end geometry gets rounded to prevent things looking ugly - m_targetGeometry = QRect(newX, newY, newWidth, newHeight); - } else { - m_targetGeometry = m_startGeometry; - m_startGeometry = QRectF(newX, newY, newWidth, newHeight); - } - } -} - -} //namespace Plasma - -#include "moc_grow_p.cpp" - diff --git a/plasma/animations/grow_p.h b/plasma/animations/grow_p.h deleted file mode 100644 index f16094e5..00000000 --- a/plasma/animations/grow_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2009 Mehmet Ali Akmanalp - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file This file contains the definition for the Grow effect. - */ - -#ifndef PLASMA_ANIMATIONS_GROW_P_H -#define PLASMA_ANIMATIONS_GROW_P_H - -#include -#include - -namespace Plasma -{ - -/** - * @class GrowAnimation plasma/animations/grow.h - * @short Grow effect - * - * Effect that grows any QGraphicsWidget by a multiple given in the - * constructor. The center of the object stays in place while the sides grow - * (it does the animation by changing the objects geometry). Also see - * \ref ZoomAnimation. - */ -class GrowAnimation : public EasingAnimation -{ - Q_OBJECT - Q_PROPERTY(qreal factor READ factor WRITE setFactor) - -public: - /** Default Constructor - * @param parent Animation object parent. - * @param factor Expand factor (default is twice the size of - * animated widget). - */ - explicit GrowAnimation(QObject *parent = 0, qreal factor = 2); - - /** Destructor */ - virtual ~GrowAnimation(){}; - - /** - * Access expansion factor of the shadow pulsable copy. - * - * If not set, the default is twice (2x) the size of animated widget. - * See \ref setFactor. - * @return Expansion factor. - */ - qreal factor() const; - /** - * Set expansion factor of target widget. - * - * If not set, the default is twice (2x) the size of animated widget. - * @param factor A expansion factor - */ - void setFactor(const qreal factor); - -protected: - void updateEffectiveTime(int currentTime); - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); - -private: - /** Animation grow factor */ - qreal m_animFactor; - /** Widget start geometry */ - QRectF m_startGeometry; - /** Widget final geometry */ - QRectF m_targetGeometry; -}; - -} - -#endif // PLASMA_ANIMATIONS_GROW_P_H diff --git a/plasma/animations/javascriptanimation.cpp b/plasma/animations/javascriptanimation.cpp deleted file mode 100644 index 71defd24..00000000 --- a/plasma/animations/javascriptanimation.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2010 Adenilson Cavalcanti - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "javascriptanimation_p.h" - -#include - -#include "animationscriptengine_p.h" -/* TODO: - * - support passing more parameters to the js animation object - * - support more properties: angle, direction, etc - * - support calling a 'resetAnimation' in js class when animation is stopped - */ -#define ADD_ENUM_VALUE(__c__, __ns__, __v__) \ - __c__.setProperty(#__v__, QScriptValue(__c__.engine(), __ns__::__v__)) - -namespace Plasma -{ - -JavascriptAnimation::JavascriptAnimation(const QString &name, QObject *parent) - : EasingAnimation(parent), -#ifdef PLASMA_JSANIM_FPS - m_fps(0), -#endif - m_name(name) -{ - -} - -JavascriptAnimation::~JavascriptAnimation() -{ -} - -void JavascriptAnimation::prepInstance() -{ - QScriptEngine *engine = AnimationScriptEngine::globalEngine(); - m_instance.setProperty("__plasma_javascriptanimation", engine->newQObject(this), - QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, FadeAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, AppearAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, DisappearAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, ActivateAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, FadeAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, GrowAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, PulseAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, RotationAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, RotationStackedAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, SlideAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, GeometryAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, ZoomAnimation); - ADD_ENUM_VALUE(m_instance, Plasma::Animator, PixmapTransitionAnimation); - ADD_ENUM_VALUE(m_instance, JavascriptAnimation, PauseAnimation); - ADD_ENUM_VALUE(m_instance, JavascriptAnimation, PropertyAnimation); -} - -void JavascriptAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -{ - //kDebug() << ".................. state: " << newState; - if (oldState == Stopped && newState == Running) { - if (!m_method.isFunction()) { - //Define the class and create an instance - m_instance = AnimationScriptEngine::animation(m_name).construct(); - kDebug() << "trying for" << m_name << m_instance.isFunction(); - - //Get the method of the object - m_method = m_instance.property(QString("updateCurrentTime")); - if (!m_method.isFunction()) { - qDebug() << "**************** ERROR! Name: " << m_name << " ************"; - m_instance = m_method = QScriptValue(); - } else { - prepInstance(); - - //TODO: this really should be done in the bindings provided - //Center the widget for transformation - qreal x = targetWidget()->geometry().height()/2; - qreal y = targetWidget()->geometry().width()/2; - targetWidget()->setTransformOriginPoint(x, y); - } - } - - if (m_method.isFunction()) { - m_instance.setProperty("duration", duration(), QScriptValue::ReadOnly); - m_instance.setProperty("target", m_instance.engine()->newQObject(targetWidget()), QScriptValue::ReadOnly); - } -#ifdef PLASMA_JSANIM_FPS - m_fps = 0; - } else if (oldState == Running && newState == Stopped) { - kDebug() << ".........." << m_name << " fps: " << m_fps * 1000/duration(); -#endif - } -} - -void JavascriptAnimation::updateEffectiveTime(int currentTime) -{ - if (m_method.isFunction()) { -#ifdef PLASMA_JSANIM_FPS - ++m_fps; -#endif - QScriptValueList args; - args << currentTime; - - m_method.call(m_instance, args); - } -} - -} //namespace Plasma - -#include "moc_javascriptanimation_p.cpp" diff --git a/plasma/animations/javascriptanimation_p.h b/plasma/animations/javascriptanimation_p.h deleted file mode 100644 index 8797e3e5..00000000 --- a/plasma/animations/javascriptanimation_p.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2010 Adenilson Cavalcanti - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef PLASMA_ANIMATIONS_JS_P_H -#define PLASMA_ANIMATIONS_JS_P_H - -#include - -#include "animator.h" -#include "easinganimation_p.h" -#include "plasma_export.h" - -class QString; -class QScriptEngine; - -//#define PLASMA_JSANIM_FPS - -namespace Plasma -{ - -class JavascriptAnimation: public EasingAnimation -{ - Q_OBJECT - -public: - enum { PauseAnimation = Animator::LastAnimation + 1, - PropertyAnimation = Animator::LastAnimation + 2 - }; - - explicit JavascriptAnimation(const QString &name, QObject *parent = 0); - - ~JavascriptAnimation(); - -protected: - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); - void updateEffectiveTime(int currentTime); - -private: - void prepInstance(); - -#ifdef PLASMA_JSANIM_FPS - int m_fps; -#endif - QString m_name; - QScriptValue m_instance; - QScriptValue m_method; -}; - -} - -#endif - diff --git a/plasma/animations/pendulumcurve.cpp b/plasma/animations/pendulumcurve.cpp deleted file mode 100644 index 8a328843..00000000 --- a/plasma/animations/pendulumcurve.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2010 Bruno Abinader - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include "pendulumcurve_p.h" - -/** - * This static method is used to create a custom easing curve type. - * @param progress animation progress value - * @return pendulum easing curve progress value - */ -static qreal pendulumFunction(qreal progress) -{ - if (progress <= 0.25) { - progress *= 4; - } else if (progress <= 0.50) { - progress -= 0.25; - progress *= 4; - progress = 1 - progress; - } else if (progress <= 0.75) { - progress -= 0.50; - progress *= -4; - } else { - progress -= 0.75; - progress *= 4; - progress = 1 - progress; - progress *= -1; - } - return progress; -} - -namespace Plasma -{ - -PendulumCurve::PendulumCurve() - : QEasingCurve() -{ - setCustomType(pendulumFunction); -} - -} // namespace Plasma diff --git a/plasma/animations/pendulumcurve_p.h b/plasma/animations/pendulumcurve_p.h deleted file mode 100644 index b46d6912..00000000 --- a/plasma/animations/pendulumcurve_p.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2010 Bruno Abinader - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#ifndef PLASMA_ANIMATIONS_PENDULUMCURVE_P_H -#define PLASMA_ANIMATIONS_PENDULUMCURVE_P_H - -#include - -namespace Plasma -{ - -/* - * @class PendulumCurve plasma/animations/pendulumcurve.h - * @shot Pendulum Easing Curve - * - * This easing curve provides values which are split in 4 parts: - * from 0 to 1, from 1 to 0, from 0 to -1, and from -1 to 0, in a linear way. - */ -class PendulumCurve : public QEasingCurve -{ -public: - /** - * default constructor - */ - PendulumCurve(); -}; - -} // namespace Plasma - -#endif // PLASMA_ANIMATIONS_PENDULUMCURVE_P_H diff --git a/plasma/animations/pixmaptransition.cpp b/plasma/animations/pixmaptransition.cpp deleted file mode 100644 index 76aa6ce6..00000000 --- a/plasma/animations/pixmaptransition.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2009 Mehmet Ali Akmanalp - * Copyright 2010 Marco Martin - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "pixmaptransition_p.h" - -#include -#include - -#include - -#include "paintutils.h" - -namespace Plasma -{ - -PixmapTransition::PixmapTransition(QObject *parent) - : EasingAnimation(parent), - m_cache(false), - m_dirty(false) -{ -} - -PixmapTransition::~PixmapTransition() -{ -} - -void PixmapTransition::setStartPixmap(const QPixmap &pixmap) -{ - if (state() == Running) { - stop(); - } - - m_startPixmap = pixmap; - - //this will center the pixmaps if needed - updateEffectiveTime(0); -} - -QPixmap PixmapTransition::startPixmap() const -{ - return m_startPixmap; -} - -void PixmapTransition::setTargetPixmap(const QPixmap &pixmap) -{ - if (state() == Running) { - stop(); - } - - m_targetPixmap = pixmap; - - updateEffectiveTime(0); -} - -void PixmapTransition::setUsesCache(bool cache) -{ - m_cache = cache; -} - -bool PixmapTransition::usesCache() const -{ - return m_cache; -} - -QPixmap PixmapTransition::targetPixmap() const -{ - return m_targetPixmap; -} - -QPixmap PixmapTransition::currentPixmap() const -{ - if (m_cache && !m_dirty) { - return m_currentPixmap; - } - - QPixmap currentPixmap; - qreal delta = currentTime() / qreal(duration()); - if (!m_startPixmap.isNull() && !m_targetPixmap.isNull()) { - //kDebug() << "transitioning"; - currentPixmap = Plasma::PaintUtils::transition(m_startPixmap, m_targetPixmap, delta); - } else if (m_startPixmap.isNull()) { - if (qFuzzyCompare(delta, qreal(1.0))) { - currentPixmap = alignedTargetPixmap(); - return currentPixmap; - } - - if (currentPixmap.isNull()) { - currentPixmap = QPixmap(m_pixmapSize); - } - - currentPixmap.fill(QColor(0, 0, 0, (int)(((qreal)255)*delta))); - QPainter p(¤tPixmap); - p.setCompositionMode(QPainter::CompositionMode_SourceIn); - //kDebug() << "painting" << m_targetPixmap.rect() << "into" << m_targetRect << "in size" << currentPixmap.size(); - p.drawPixmap(m_targetRect, m_targetPixmap); - p.end(); - } else if (m_targetPixmap.isNull()) { - currentPixmap = alignedStartPixmap(); - if (qFuzzyCompare(delta, qreal(1.0))) { - return m_currentPixmap; - } - //kDebug() << "painting" << m_startPixmap.rect() << "into" << m_targetRect << "in size" << currentPixmap.size(); - QPainter p(¤tPixmap); - p.setCompositionMode(QPainter::CompositionMode_DestinationIn); - p.fillRect(currentPixmap.rect(), QColor(0, 0, 0, (int)(254 - ((qreal)254)*delta))); - p.end(); - } - - if (m_cache) { - const_cast(this)->m_currentPixmap = currentPixmap; - } - - return currentPixmap; -} - -QPixmap PixmapTransition::alignedTargetPixmap() const -{ - QPixmap pm(m_pixmapSize); - pm.fill(Qt::transparent); - QPainter p(&pm); - p.drawPixmap(m_targetRect, m_targetPixmap); - return pm; -} - -QPixmap PixmapTransition::alignedStartPixmap() const -{ - QPixmap pm(m_pixmapSize); - pm.fill(Qt::transparent); - QPainter p(&pm); - p.drawPixmap(m_startRect, m_startPixmap); - return pm; -} - -void PixmapTransition::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -{ - if (oldState == Stopped && newState == Running) { - m_targetRect = m_targetPixmap.rect(); - m_startRect = m_startPixmap.rect(); - m_pixmapSize = m_startRect.size().expandedTo(m_targetRect.size()); - QRect actualRect = QRect(QPoint(0,0), m_pixmapSize); - m_targetRect.moveCenter(actualRect.center()); - m_startRect.moveCenter(actualRect.center()); - } else if (QGraphicsWidget *w = targetWidget()) { - w->update(); - } - - m_dirty = true; -} - -void PixmapTransition::updateEffectiveTime(int currentTime) -{ - Q_UNUSED(currentTime) - - m_dirty = true; - QGraphicsWidget *w = targetWidget(); - if (w) { - w->update(); - } -} - -} //namespace Plasma - -#include "moc_pixmaptransition_p.cpp" diff --git a/plasma/animations/pixmaptransition_p.h b/plasma/animations/pixmaptransition_p.h deleted file mode 100644 index 281b676c..00000000 --- a/plasma/animations/pixmaptransition_p.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2009 Mehmet Ali Akmanalp - * Copyright 2010 Marco Martin - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file This file contains the definition for the PixmapTransition effect. - */ - -#ifndef PLASMA_ANIMATIONS_PIXMAPTRANSITION_P_H -#define PLASMA_ANIMATIONS_PIXMAPTRANSITION_P_H - -#include -#include - -namespace Plasma -{ - -/** - * @class Fade plasma/animations/pixmaptransition.h - * @short PixmapTransition effect - * - * Effect that paints a transition between two pixmaps - */ -class PixmapTransition : public EasingAnimation -{ - Q_OBJECT - Q_PROPERTY(QPixmap startPixmap READ startPixmap WRITE setStartPixmap) - Q_PROPERTY(QPixmap targetPixmap READ targetPixmap WRITE setTargetPixmap) - Q_PROPERTY(bool usesCache READ usesCache WRITE setUsesCache) - Q_PROPERTY(QPixmap currentPixmap READ currentPixmap) - -public: - explicit PixmapTransition(QObject *parent = 0); - - virtual ~PixmapTransition(); - - /** - * @return The first pixmap of the animation - */ - QPixmap startPixmap() const; - - /** - * Set the first pixmap of the animation - */ - void setStartPixmap(const QPixmap &); - - /** - * The pixmap the animation will evolve to - */ - QPixmap targetPixmap() const; - - /** - * Set the pixmap the animation will evolve to - */ - void setTargetPixmap(const QPixmap &); - - /** - * @return the current pixmap - */ - QPixmap currentPixmap() const; - - /** - * Enable caching of the resulting pixmap, otherwise it will be regenerated on - * each call to currentPixmap; for elements which already have their own caching - * this is not a problem. - */ - void setUsesCache(bool cache); - - /** - * @return whether or not caching is on - */ - bool usesCache() const; - -protected: - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); - void updateEffectiveTime(int currentTime); - -private: - QPixmap alignedTargetPixmap() const; - QPixmap alignedStartPixmap() const; - -private: - QPixmap m_startPixmap; - QPixmap m_targetPixmap; - QPixmap m_currentPixmap; - QRect m_startRect; - QRect m_targetRect; - QSize m_pixmapSize; - bool m_cache; - bool m_dirty; -}; - -} - -#endif // PLASMA_ANIMATIONS_PIXMAPTRANSITION_P_H diff --git a/plasma/animations/pulser.cpp b/plasma/animations/pulser.cpp deleted file mode 100644 index cdac54b4..00000000 --- a/plasma/animations/pulser.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright (C) 2009 Adenilson Cavalcanti - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include "widgetsnapshot_p.h" -#include "pulser_p.h" - -#include -#include -#include -#include -#include - -#include - -namespace Plasma -{ - -PulseAnimation::PulseAnimation(QObject *parent) - : EasingAnimation(parent), - m_zvalue(0), - m_scale(0), - m_opacity(0), - m_endScale(1.5) -{ -} - -PulseAnimation::~PulseAnimation() -{ - delete m_under.data(); -} - -void PulseAnimation::setTargetScale(qreal scale) -{ - m_endScale = scale; -} - -qreal PulseAnimation::targetScale() const -{ - return m_endScale; -} - -void PulseAnimation::setCopy() -{ - QGraphicsWidget *target = targetWidget(); - - if (!target) { - m_under.clear(); - return; - } - - if (!m_under.data()) { - m_under = new WidgetSnapShot; - } - - m_under.data()->setTarget(target); - - m_zvalue = target->zValue() - 1; - m_scale = target->scale(); - - m_under.data()->setOpacity(m_opacity); - m_under.data()->setScale(m_scale); - m_under.data()->setZValue(m_zvalue); -} - -void PulseAnimation::resetPulser() -{ - if (m_under.data()) { - m_under.data()->setOpacity(m_opacity); - m_under.data()->setScale(m_scale); - m_under.data()->setZValue(m_zvalue); - m_under.data()->hide(); - } -} - -void PulseAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -{ - if (!targetWidget()) { - return; - } - - if (oldState == Stopped && newState == Running) { - if (!m_under.data() || m_under.data()->target() != targetWidget() || m_under.data()->size() != targetWidget()->size()) { - setCopy(); - } - - if (m_under.data()->isIconBigger()) { - m_under.data()->setScale(0); - m_endScale = 1.0; - - } else { - m_scale = 0; - m_endScale = 1.5; - } - - if (m_under.data()->isVisible() == false) { - m_under.data()->setVisible(true); - } - - m_under.data()->setOpacity(direction() == Forward ? 1 : 0); - m_under.data()->setScale(direction() == Forward ? m_scale : m_endScale); - } else if (newState == Stopped) { - resetPulser(); - } -} - -void PulseAnimation::updateEffectiveTime(int currentTime) -{ - if (m_under.data()) { - qreal delta = currentTime / qreal(duration()); - - if (m_under.data()->isIconBigger()) { - m_under.data()->setScale(delta); - } else { - m_under.data()->setScale(delta); - delta = (1 - m_endScale) * delta; - m_under.data()->setScale(1 - delta); - } - - delta = currentTime / qreal(duration()); - if (direction() == Forward) { - m_under.data()->setOpacity(1.0 - delta); - } else if (direction() == Backward) { - m_under.data()->setOpacity(delta); - } - } -} - -} //namespace Plasma - -#include "moc_pulser_p.cpp" diff --git a/plasma/animations/pulser_p.h b/plasma/animations/pulser_p.h deleted file mode 100644 index 6636999b..00000000 --- a/plasma/animations/pulser_p.h +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (C) 2009 Adenilson Cavalcanti - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file This file contains the definition for the Pulse effect. - */ - -#ifndef PLASMA_ANIMATIONS_PULSER_P_H -#define PLASMA_ANIMATIONS_PULSER_P_H - -#include -#include - -namespace Plasma -{ - -class WidgetSnapShot; - -/** - * @class PulseAnimation plasma/animations/pulser_p.h - * @short Pulse effect - * - * Effect that pulses a shadow copy of any QGraphicsWidget making - * it more translucent and bigger along the time until it vanishes. - */ -class PulseAnimation : public EasingAnimation -{ - Q_OBJECT - Q_PROPERTY(qreal targetScale READ targetScale WRITE setTargetScale) - -public: - /** Default Constructor */ - explicit PulseAnimation(QObject *parent = 0); - - /** Destructor */ - ~PulseAnimation(); - - /** Pulse scale factor. - * - * How much the pulsed shadow will expand (the default is 1.5x the - * size of pulsed widget). - * - * @param scale Pulse scale value (should be bigger than 1.0). - */ - void setTargetScale(qreal scale); - - /** Returns pulsed scale factor. - * - * The amount of pulsed shadow factor used (default is 1.5x the size - * of widget). - */ - qreal targetScale() const; - - /** - * Resets the shadow widget to its initial state (full translucent - * and with same geometry as the target widget). It is executed - * when the animation is over. - */ - void resetPulser(); - -protected: - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); - void updateEffectiveTime(int currentTime); - void setCopy(); - -private: - /** Zvalue (tipically -1 than the target widget) */ - qreal m_zvalue; - - /** Original widget scale */ - qreal m_scale; - - /** Opacity of shadow widget (full translucent) */ - qreal m_opacity; - - /** Target scale of shadow widget (default is 1.5x the animated - * widget scale). - */ - qreal m_endScale; - - /** The shadow copy (it really is a QGraphicsWidget with a pixmap - * copy of the original widget). - */ - QWeakPointer m_under; -}; - -} - -#endif // PLASMA_ANIMATIONS_PULSER_P_H - - - - - - diff --git a/plasma/animations/rotation.cpp b/plasma/animations/rotation.cpp deleted file mode 100644 index d633e43e..00000000 --- a/plasma/animations/rotation.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - Copyright (C) 2009 Igor Trindade Oliveira - Copyright (C) 2009 Adenilson Cavalcanti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include -#include -#include - -#include "kdebug.h" - -#include "rotation_p.h" - -namespace Plasma -{ - -RotationAnimation::RotationAnimation(QObject *parent, qint8 reference, Qt::Axis axis, qreal angle) - : EasingAnimation(parent), - m_rotation(new QGraphicsRotation(this)), - m_angle(angle), - m_axis(axis), - m_reference(reference) -{ -} - -RotationAnimation::~RotationAnimation() -{ -} - -Qt::Axis RotationAnimation::axis() const -{ - return m_axis; -} - -void RotationAnimation::setAxis(const Qt::Axis &axis) -{ - m_axis = axis; -} - -qint8 RotationAnimation::reference() const -{ - return m_reference; -} - -void RotationAnimation::setReference(const qint8 &reference) -{ - m_reference = reference; -} - -qreal RotationAnimation::angle() const -{ - return m_angle; -} - -void RotationAnimation::setAngle(const qreal &angle) -{ - m_angle = angle; -} - -void RotationAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -{ - Q_UNUSED(newState) - Q_UNUSED(oldState) - - QGraphicsWidget *m_object = targetWidget(); - - if (!m_object) { - return; - } - - QVector3D vector(0, 0, 0); - - const qreal widgetWidth = m_object->size().width(); - const qreal widgetHeight = m_object->size().height(); - - if (axis() == Qt::XAxis) { - switch (reference()) { - case Center: - vector.setX(widgetWidth/2); - vector.setY(widgetHeight/2); - break; - case Up: - vector.setX(widgetWidth/2); - vector.setY(0); - break; - case Down: - vector.setX(widgetWidth/2); - vector.setY(widgetHeight); - break; - } - - } else if(axis() == Qt::YAxis) { - switch (reference()) { - case Center: - vector.setX(widgetWidth/2); - vector.setY(widgetHeight/2); - break; - case Left: - vector.setX(0); - vector.setY(widgetHeight/2); - break; - case Right: - vector.setX(widgetWidth); - vector.setY(widgetHeight/2); - break; - } - - } else if (axis() == Qt::ZAxis) { - switch (reference()) { - case Center: - vector.setX(widgetWidth/2); - vector.setY(widgetHeight/2); - break; - - case Center|Up: - vector.setX(widgetWidth/2); - vector.setY(0); - break; - - case Center|Down: - vector.setX(widgetWidth/2); - vector.setY(widgetHeight); - break; - - case Center|Left: - vector.setX(0); - vector.setY(widgetHeight/2); - break; - - case Center|Right: - vector.setX(widgetWidth); - vector.setY(widgetHeight/2); - break; - } - } - - m_rotation->setOrigin(vector); - m_rotation->setAxis(axis()); - - QList transformation; - transformation.append(m_rotation); - m_object->setTransformations(transformation); -} - -void RotationAnimation::updateEffectiveTime(int currentTime) -{ - if (targetWidget()) { - qreal delta = currentTime * angle() / qreal(duration()); - m_rotation->setAngle(delta); - } -} - -} - -#include "moc_rotation_p.cpp" diff --git a/plasma/animations/rotation_p.h b/plasma/animations/rotation_p.h deleted file mode 100644 index 30d3d793..00000000 --- a/plasma/animations/rotation_p.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - Copyright (C) 2009 Igor Trindade Oliveira - Copyright (C) 2009 Adenilson Cavalcanti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -/** - * @file This file contains the definition for the 2D Rotation effect. - */ - -#ifndef PLASMA_ROTATION_P_H -#define PLASMA_ROTATION_P_H - -#include - -class QGraphicsRotation; - -namespace Plasma { -/** - * @class RotationAnimation plasma/animations/rotation_p.h - * @short 2D rotation animation. - * - * This animation rotates a QGraphicsWidget in a axis (reference and - * axis can be defined using properties). See also - * \ref StackedRotationAnimation. - */ -class RotationAnimation : public EasingAnimation -{ - - Q_OBJECT - Q_PROPERTY(Qt::Axis axis READ axis WRITE setAxis) - Q_PROPERTY(qint8 reference READ reference WRITE setReference) - Q_PROPERTY(qreal angle READ angle WRITE setAngle) - -public: - /** - * Default constructor - * - * @param parent Animation object parent. - * @param reference See \ref Animation::Reference. - * @param axis Which axis to rotate (XAxis, YAxis, ZAxis). - * @param angle Rotation angle (0 to 360) - * - */ - explicit RotationAnimation(QObject *parent = 0, - qint8 reference = Center, - Qt::Axis axis = Qt::ZAxis, - qreal angle = 180); - - /** Destructor */ - ~RotationAnimation(); - - /** - * get animation rotation axis (e.g. YAxis, ZAxis, XAxis) - */ - Qt::Axis axis() const; - - /** - * Rotation reference (e.g. Center, Up, Down, Left, Right) can - * be combined (i.e. Center|Up) - */ - qint8 reference() const; - - /** - * Animation rotation angle (e.g. 45, 180, etc) - */ - qreal angle() const; - - /** - * Reimplemented from Plasma::Animation - * @param curve Easing curve - */ - void setEasingCurve(const QEasingCurve &curve); - -public slots: - /** - * set animation rotation axis - * @param axis Rotation (e.g. YAxis, ZAxis, XAxis) - */ - void setAxis(const Qt::Axis &axis); - - /** - * Set rotation reference (e.g. Center, Up, Down, Left, Right) can - * be combined (i.e. Center|Up) - * @param reference The reference - */ - void setReference(const qint8 &reference); - - /** - * Set animation rotation angle (e.g. 45, 180, etc) - * @param angle The angle - */ - void setAngle(const qreal &angle); - -protected: - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); - void updateEffectiveTime(int currentTime); - -private: - /** Rotation transform object */ - QGraphicsRotation *m_rotation; - /** Rotation angle */ - qreal m_angle; - /** Axis where to perform the rotation */ - Qt::Axis m_axis; - /** Reference, the default is Up (see \ref Animation::Reference) */ - qint8 m_reference; -}; -} // Plasma - -#endif diff --git a/plasma/animations/rotationstacked.cpp b/plasma/animations/rotationstacked.cpp deleted file mode 100644 index 13da46ac..00000000 --- a/plasma/animations/rotationstacked.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - Copyright (C) 2009 Igor Trindade Oliveira - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "rotationstacked_p.h" -#include -#include -#include -#include - -#include "stackedlayout.h" -#include "plasma.h" - -namespace Plasma -{ - -const int RotationStackedAnimation::s_sideAngle = 90; - -RotationStackedAnimation::RotationStackedAnimation(QObject *parent) - : EasingAnimation(parent) -{ - m_backRotation = new QGraphicsRotation(this); - m_frontRotation = new QGraphicsRotation(this); - m_wLayout = new StackedLayout; -} - -RotationStackedAnimation::~RotationStackedAnimation() -{ - delete m_wLayout.data(); -} - -void RotationStackedAnimation::setMovementDirection(const Animation::MovementDirection &direction) -{ - m_animDirection = direction; - - QVector3D animDirection(0, 0, 0); - - if (m_animDirection.testFlag(MoveUp)) { - animDirection.setX(1); - } else if (m_animDirection.testFlag(MoveDown)) { - animDirection.setX(-1); - } - - if (m_animDirection.testFlag(MoveLeft)) { - animDirection.setY(-1); - } else if (m_animDirection.testFlag(MoveRight)) { - animDirection.setY(1); - } - - m_frontRotation->setAxis(animDirection); - m_backRotation->setAxis(animDirection); - - updateTransformations(); -} - -Animation::MovementDirection RotationStackedAnimation::movementDirection() const -{ - return m_animDirection; -} - -void RotationStackedAnimation::setReference(const Animation::Reference &reference) -{ - m_animReference = reference; - - if (!targetWidget() || !backWidget()) { - return; - } - - const QSizeF transformArea = targetWidget()->size().expandedTo(backWidget()->size()); - - QVector3D frontTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0); - QVector3D backTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0); - - if (m_animReference.testFlag(Up)) { - frontTransformOrigin.setY(0); - backTransformOrigin.setY(0); - } else if (m_animReference.testFlag(Down)) { - frontTransformOrigin.setY(transformArea.height()); - backTransformOrigin.setY(transformArea.height()); - } - - if (m_animReference.testFlag(Left)) { - frontTransformOrigin.setX(0); - backTransformOrigin.setX(0); - } else if (m_animReference.testFlag(Right)) { - frontTransformOrigin.setX(transformArea.width()); - backTransformOrigin.setX(transformArea.width()); - } - - m_frontRotation->setOrigin(frontTransformOrigin); - m_backRotation->setOrigin(backTransformOrigin); - - updateTransformations(); -} - -Animation::Reference RotationStackedAnimation::reference() const -{ - return m_animReference; -} - -QGraphicsWidget *RotationStackedAnimation::backWidget() -{ - return m_backWidget.data(); -} - -void RotationStackedAnimation::setBackWidget(QGraphicsWidget *backWidget) -{ - m_backWidget = backWidget; - - StackedLayout *layout = m_wLayout.data(); - - if(targetWidget() && backWidget && layout) { - layout->addWidget(targetWidget()); - layout->addWidget(backWidget); - } -} - -QGraphicsLayoutItem *RotationStackedAnimation::layout() -{ - return m_wLayout.data(); -} - -void RotationStackedAnimation::updateState(QAbstractAnimation::State newState, - QAbstractAnimation::State oldState) -{ - if (oldState == Stopped && newState == Running) { - setReference(reference()); - } -} - -void RotationStackedAnimation::updateEffectiveTime(int currentTime) -{ - if (!targetWidget() || !backWidget()) { - return; - } - - StackedLayout *layout = m_wLayout.data(); - if (!layout) { - return; - } - - qreal delta; - if (currentTime <= duration()/2) { - layout->setCurrentWidgetIndex(0); - delta = (currentTime*2) / qreal(duration()); - delta *= s_sideAngle; - m_frontRotation->setAngle(delta); - } else { - layout->setCurrentWidgetIndex(1); - delta = 1 - (((currentTime*2) - duration()) / qreal(duration())); - delta = -delta; - delta *= s_sideAngle; - m_backRotation->setAngle(delta); - } -} - -void RotationStackedAnimation::updateTransformations() -{ - if (!targetWidget() || !backWidget()) { - return; - } - - QList frontTransformation; - QList backTransformation; - - frontTransformation.append(m_frontRotation); - backTransformation.append(m_backRotation); - - targetWidget()->setTransformations(frontTransformation); - backWidget()->setTransformations(backTransformation); -} - -} //namespace Plasma - -#include "moc_rotationstacked_p.cpp" diff --git a/plasma/animations/rotationstacked_p.h b/plasma/animations/rotationstacked_p.h deleted file mode 100644 index 9ebefde7..00000000 --- a/plasma/animations/rotationstacked_p.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - Copyright (C) 2009 Igor Trindade Oliveira - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -/** - * @file This file contains the definition for the StackedRotationAnimation. - */ - -#ifndef PLASMA_ROTATIONSTACKED_P_H -#define PLASMA_ROTATIONSTACKED_P_H - -#include -#include - -#include - -class QGraphicsRotation; -class StackedLayout; - -namespace Plasma { - -/* TODO: - * create a parent class for rotations - */ -/** - * @class RotationStackedAnimation plasma/animations/rotationstacked_p.h - * @short 3D like rotation animation - * Use this class when you want to rotate a widget along an axis (e.g. Y) - * and display a 'hidden' widget behind it. See also \ref RotationAnimation. - */ -class RotationStackedAnimation : public EasingAnimation -{ - Q_OBJECT - Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection) - Q_PROPERTY(Reference reference READ reference WRITE setReference) - Q_PROPERTY(QGraphicsLayoutItem* layout READ layout) - Q_PROPERTY(QGraphicsWidget* backWidget READ backWidget WRITE setBackWidget) - -public: - explicit RotationStackedAnimation(QObject *parent = 0); - - ~RotationStackedAnimation(); - - /** - * Set the animation movement direction (e.g. MoveAny, MoveUp, MoveDown, - * MoveLeft, MoveRight) which can be combined (i.e. MoveUp|MoveLeft). - * @param direction animation direction - */ - void setMovementDirection(const Animation::MovementDirection &direction); - - /** - * Get the animation movement direction. - */ - Animation::MovementDirection movementDirection() const; - - /** - * Set the animation rotation reference (e.g. Center, Up, Down, Left, - * Right) which can be combined (i.e. Center|Up). - * @param reference animation reference - */ - void setReference(const Animation::Reference &reference); - - /** - * Get the animation rotation reference. - */ - Animation::Reference reference() const; - - /** - * Get the layout where the widgetToAnimate and backWidget are. - */ - QGraphicsLayoutItem *layout(); - - /** - * Get the back widget - */ - - QGraphicsWidget *backWidget(); - - /** - * Set the back widget that is used after the animation to be finished - * @param backWidget The back widget - */ - void setBackWidget(QGraphicsWidget *backWidget); - -protected: - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); - void updateEffectiveTime(int currentTime); - -private: - /** - * Updates the front and back widget rotation animation transformations, - * according to the given animation reference point and direction. - */ - void updateTransformations(); - - /** Animation reference (see \ref Animation::Reference) */ - Animation::Reference m_animReference; - /** Animation movement direction (see \ref Animation::MovementDirection) */ - Animation::MovementDirection m_animDirection; - /** Object the animation(s) should act upon. */ - QWeakPointer m_backWidget; - /** Layout where widget would be added */ - QWeakPointer m_wLayout; - /** Back Widget Rotation transform object */ - QGraphicsRotation *m_backRotation; - /** Front Widget Rotation transform object */ - QGraphicsRotation *m_frontRotation; - - static const int s_sideAngle; -}; -} // Plasma - -#endif // PLASMA_ROTATIONSTACKED_P_H diff --git a/plasma/animations/slide.cpp b/plasma/animations/slide.cpp deleted file mode 100644 index 5b452014..00000000 --- a/plasma/animations/slide.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2009 Mehmet Ali Akmanalp - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "slide_p.h" - -#include -#include - -namespace Plasma -{ - -void SlideAnimation::setDistance(qreal distance) -{ - m_animDistance = QPointF(distance, 0.0); -} - -qreal SlideAnimation::distance() const -{ - return m_animDistance.x(); -} - -void SlideAnimation::setDistancePointF(const QPointF &distance) -{ - m_animDistance = distance; -} - -QPointF SlideAnimation::distancePointF() const -{ - return m_animDistance; -} - -SlideAnimation::~SlideAnimation() -{ -} - -SlideAnimation::SlideAnimation(QObject *parent, - MovementDirection direction, - qreal distance) : EasingAnimation(parent) -{ - setMovementDirection(direction); - setDistance(distance); - setEasingCurve(QEasingCurve::OutCirc); -} - -void SlideAnimation::setMovementDirection(const Animation::MovementDirection &direction) -{ - m_animDirection = direction; -} - -Animation::MovementDirection SlideAnimation::movementDirection() const -{ - return m_animDirection; -} - -void SlideAnimation::updateEffectiveTime(int currentTime) -{ - QGraphicsWidget *w = targetWidget(); - if (w && state() == QAbstractAnimation::Running) { - const qreal delta = currentTime / qreal(duration()); - w->setPos(m_startPos * (1-delta) + (m_targetPos * delta)); - } -} - -void SlideAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -{ - if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) { - if (!targetWidget()) { - return; - } - m_startPos = targetWidget()->pos(); - - qreal newX = m_startPos.x(); - qreal newY = m_startPos.y(); - - QPointF actualDistance = (direction() == \ - QAbstractAnimation::Forward ? \ - distancePointF():-distancePointF()); - - bool moveAnyOnly = true; - - if (m_animDirection.testFlag(MoveUp)) { - newY -= actualDistance.x(); - moveAnyOnly = false; - } else if (m_animDirection.testFlag(MoveDown)) { - newY += actualDistance.x(); - moveAnyOnly = false; - } - - if (m_animDirection.testFlag(MoveRight)) { - newX += actualDistance.x(); - moveAnyOnly = false; - } else if (m_animDirection.testFlag(MoveLeft)) { - newX -= actualDistance.x(); - moveAnyOnly = false; - } - - if (moveAnyOnly && m_animDirection.testFlag(MoveAny)) { - newX += actualDistance.x(); - newY += actualDistance.y(); - } - - if (direction() == QAbstractAnimation::Forward) { - m_targetPos = QPointF(newX, newY); - } else { - m_targetPos = m_startPos; - m_startPos = QPointF(newX, newY); - } - } -} - -} //namespace Plasma - -#include "moc_slide_p.cpp" diff --git a/plasma/animations/slide_p.h b/plasma/animations/slide_p.h deleted file mode 100644 index 23952613..00000000 --- a/plasma/animations/slide_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2009 Mehmet Ali Akmanalp - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file This file contains the definition for the Slide effect. - */ - -#ifndef PLASMA_ANIMATIONS_SLIDE_P_H -#define PLASMA_ANIMATIONS_SLIDE_P_H - -#include "plasma/animations/easinganimation_p.h" -#include "plasma/plasma_export.h" -#include "plasma/plasma.h" - -namespace Plasma -{ - -class SlideAnimationPrivate; -/** - * @class Slide plasma/animations/slide.h - * @short Slide effect - * - * Effect that moves the object a specific distance in a given direction. The - * object is optionally made invisible at the beginning or at the end. - */ -class SlideAnimation : public EasingAnimation -{ - Q_OBJECT - Q_PROPERTY(qreal distance READ distance WRITE setDistance) - Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection) - Q_PROPERTY(QPointF distancePointF READ distancePointF WRITE setDistancePointF) - -public: - explicit SlideAnimation(QObject *parent = 0, MovementDirection direction = MoveUp, qreal distance = 0); - ~SlideAnimation(); - - /** - * Set the animation distance - * @distance animation distance - */ - void setDistance(qreal distance); - - /** - * Get the animation distance - */ - qreal distance() const; - - void setDistancePointF(const QPointF &distance); - QPointF distancePointF() const; - - /** - * Set the animation direction - * @param direction animation direction - */ - void setMovementDirection(const Animation::MovementDirection&direction); - - /** - * Get the animation direction - */ - Animation::MovementDirection movementDirection() const; - -protected: - void updateEffectiveTime(int currentTime); - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); - -private: - /** - * Animation direction: where the animation will move. - */ - Animation::MovementDirection m_animDirection; - - /** - * Animation distance: displacement factor for animations where - * there is change in the position of animated widget. - */ - QPointF m_animDistance; - QPointF m_startPos; - QPointF m_targetPos; -}; - -} - -#endif // PLASMA_ANIMATIONS_SLIDE_P_H diff --git a/plasma/animations/stackedlayout.cpp b/plasma/animations/stackedlayout.cpp deleted file mode 100644 index 29ec0b63..00000000 --- a/plasma/animations/stackedlayout.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - Copyright (C) 2009 Igor Trindade Oliveira - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "stackedlayout.h" - -#include -#include - -StackedLayout::StackedLayout(QGraphicsLayoutItem *parent) - : QObject(0), - QGraphicsLayout(parent), - m_currentWidgetIndex(-1) -{ -} - -StackedLayout::~StackedLayout() -{ -} - -void StackedLayout::setGeometry(const QRectF &rect) -{ - QGraphicsLayout::setGeometry(rect); - - const QRectF effectiveRect = geometry(); - - for(int i = 0; i < items.size(); i++) { - itemAt(i)->setGeometry(effectiveRect); - } -} - -QSizeF StackedLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -{ - Q_UNUSED(which); - Q_UNUSED(constraint); - - qreal left, top, right, bottom; - getContentsMargins(&left, &top, &right, &bottom); - - if (m_currentWidgetIndex <= 0 || !itemAt(m_currentWidgetIndex)) { - return QSizeF(); - } - - QSizeF currentWidgetSize = itemAt(m_currentWidgetIndex)->effectiveSizeHint(which, constraint); - - return QSizeF( left + right + currentWidgetSize.width(), right + bottom + currentWidgetSize.height()); -} - -int StackedLayout::count() const -{ - return items.count(); -} - -QGraphicsLayoutItem *StackedLayout::itemAt(int i) const -{ - return items.at(i); -} - -void StackedLayout::insertWidget(QGraphicsLayoutItem *item, int pos) -{ - if(!pos && (m_currentWidgetIndex == -1)) { - m_currentWidgetIndex = 0; - } else { - item->graphicsItem()->hide(); - } - - items.insert(pos, item); - activate(); -} - -void StackedLayout::addWidget(QGraphicsLayoutItem *item) -{ - insertWidget(item, items.size()); -} - -void StackedLayout::removeAt(int index) -{ - items.removeAt(index); -} - -void StackedLayout::setCurrentWidgetIndex(qint32 index) -{ - QGraphicsItem *currentWidget = itemAt(m_currentWidgetIndex)->graphicsItem(); - QGraphicsItem *hiddenWidget = itemAt(index)->graphicsItem(); - - currentWidget->hide(); - hiddenWidget->show(); - - m_currentWidgetIndex = index; -} - -qint32 StackedLayout::currentWidgetIndex() const -{ - return m_currentWidgetIndex; -} diff --git a/plasma/animations/stackedlayout.h b/plasma/animations/stackedlayout.h deleted file mode 100644 index 465ef229..00000000 --- a/plasma/animations/stackedlayout.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright (C) 2009 Igor Trindade Oliveira - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef STACKEDLAYOUT_H -#define STACKEDLAYOUT_H - -/* TODO: document the methods */ - -#include -#include -#include - -class StackedLayout : public QObject, public QGraphicsLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout) - -public: - explicit StackedLayout(QGraphicsLayoutItem *parent = 0); - ~StackedLayout(); - - void setGeometry(const QRectF &rect); - QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const; - int count() const; - QGraphicsLayoutItem *itemAt(int i) const; - - void insertWidget(QGraphicsLayoutItem *item, int pos); - void addWidget(QGraphicsLayoutItem *item); - - void removeAt(int index); - - qint32 currentWidgetIndex() const; - void setCurrentWidgetIndex(qint32 index); - - private: - QList items; - qint32 m_currentWidgetIndex; -}; - -#endif diff --git a/plasma/animations/water.cpp b/plasma/animations/water.cpp deleted file mode 100644 index 9565dc8a..00000000 --- a/plasma/animations/water.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2010 Bruno Abinader - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include -#include "water_p.h" - -namespace Plasma -{ - -WaterAnimation::WaterAnimation(QObject *parent) - : EasingAnimation(parent), - m_offset(1) -{ -} - -qint8 WaterAnimation::offset() const -{ - return m_offset; -} - -void WaterAnimation::setOffset(qint8 offset) -{ - m_offset = offset; -} - -void WaterAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -{ - QGraphicsWidget *widget = targetWidget(); - if (!widget) { - return; - } - - RippleEffect *effect = qobject_cast(widget->graphicsEffect()); - if (!effect) { - effect = new RippleEffect(widget); - widget->setGraphicsEffect(effect); - } - - if (oldState == Stopped && newState == Running) { - effect->setOffset(m_offset); - effect->setEnabled(true); - } else if (newState == Stopped) { - effect->setEnabled(false); - } -} - -void WaterAnimation::updateEffectiveTime(int currentTime) -{ - QGraphicsWidget *widget = targetWidget(); - if (widget && widget->graphicsEffect()) { - widget->graphicsEffect()->setProperty("opacity", currentTime / qreal(duration())); - } -} - -} // namespace Plasma diff --git a/plasma/animations/water_p.h b/plasma/animations/water_p.h deleted file mode 100644 index c6aa4f05..00000000 --- a/plasma/animations/water_p.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2010 Bruno Abinader - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#ifndef PLASMA_ANIMATIONS_WATER_P_H -#define PLASMA_ANIMATIONS_WATER_P_H - -#include - -namespace Plasma -{ - -/* - * @class Water plasma/animations/water_p.h - * @short Water animation using ripple effect - * - * Simulates a water animation using ripple effect - */ -class WaterAnimation : public EasingAnimation -{ - Q_OBJECT - Q_PROPERTY(qint8 offset READ offset WRITE setOffset) - -public: - /** - * Default constructor - * @param parent Animation object parent - */ - explicit WaterAnimation(QObject *parent = 0); - - /** - * Returns the ripple offset. The ripple offset is the distance between neighbour pixels used to - * calculate the wave propagation. - * @return ripple offset - */ - qint8 offset() const; - -public slots: - /** - * Sets the ripple offset - * @param offset ripple offset - */ - void setOffset(qint8 offset); - -protected: - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); - void updateEffectiveTime(int currentTime); - -private: - qint8 m_offset; /** Ripple offset (default is 1) */ -}; - -} // namespace Plasma - -#endif // PLASMA_ANIMATIONS_WATER_P_H diff --git a/plasma/animations/widgetsnapshot.cpp b/plasma/animations/widgetsnapshot.cpp deleted file mode 100644 index 4a057fde..00000000 --- a/plasma/animations/widgetsnapshot.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright (C) 2009 Adenilson Cavalcanti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "widgetsnapshot_p.h" - -#include -#include -#include -#include -#include - -static const int RECURSION_MAX = 20; - -namespace Plasma -{ - -WidgetSnapShot::WidgetSnapShot(QGraphicsItem *parent) - : QGraphicsWidget(parent), - m_iconBig(false), - stack(0), - m_target(0) -{ -} - -WidgetSnapShot::~WidgetSnapShot() -{ -} - -void WidgetSnapShot::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(widget); - - painter->setRenderHint(QPainter::Antialiasing); - painter->drawPixmap(option->exposedRect, m_snapShot, option->exposedRect); -} - -void WidgetSnapShot::paintSubChildren(QPainter *painter, - const QStyleOptionGraphicsItem *option, - QGraphicsItem *target) -{ - ++stack; - QList list = target->childItems(); - QGraphicsItem *tmp; - if (list.size() > 0) { - for (int i = 0; i < list.size(); ++i) { - tmp = list.value(i); - - if ((tmp->childItems().size() > 0) && (stack < RECURSION_MAX)) { - paintSubChildren(painter, option, tmp); - } - - if (tmp->isVisible()) { - tmp->paint(painter, option, 0); - } - } - } - --stack; -} - -void WidgetSnapShot::setTarget(QGraphicsWidget *target) -{ - stack = 0; - m_target = target; - setParentItem(target); - QSize size(target->size().toSize()); - m_iconBig = false; - - if (m_target->property("iconRepresentation").isValid()) { - m_iconBig = true; - m_snapShot = QPixmap::fromImage( - m_target->property("iconRepresentation").value()); - if ((m_snapShot.height() > 0) && (m_snapShot.width() > 0)) { - resize(m_snapShot.size()); - setTransformOriginPoint(target->geometry().center()); - return; - } - } - - resize(target->size()); - - m_snapShot = QPixmap(size); - m_snapShot.fill(Qt::transparent); - - QPainter painter(&m_snapShot); - painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - painter.fillRect(target->rect(), Qt::transparent); - - QStyleOptionGraphicsItem style; - style.exposedRect = target->boundingRect(); - style.rect = target->rect().toRect(); - - target->paint(&painter, &style, 0); - paintSubChildren(&painter, &style, target); - painter.end(); - setTransformOriginPoint(geometry().center()); -} - -QGraphicsWidget *WidgetSnapShot::target() const -{ - return m_target; -} - - -bool WidgetSnapShot::isIconBigger() const -{ - return m_iconBig; -} - -QPixmap WidgetSnapShot::snapShot() const -{ - return m_snapShot; -} - -} diff --git a/plasma/animations/widgetsnapshot_p.h b/plasma/animations/widgetsnapshot_p.h deleted file mode 100644 index c65157bf..00000000 --- a/plasma/animations/widgetsnapshot_p.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2009 Adenilson Cavalcanti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PLASMA_WIDGETSNAPSHOT_P_H -#define PLASMA_WIDGETSNAPSHOT_P_H - -#include - -namespace Plasma -{ - -class WidgetSnapShot : public QGraphicsWidget -{ - Q_OBJECT - Q_PROPERTY(QGraphicsWidget *target READ target WRITE setTarget) - -public: - explicit WidgetSnapShot(QGraphicsItem *parent = 0); - virtual ~WidgetSnapShot(); - - virtual void setTarget(QGraphicsWidget *target); - QGraphicsWidget *target() const; - - virtual void paint(QPainter *painter, - const QStyleOptionGraphicsItem *option, - QWidget *widget); - - bool isIconBigger() const; - - QPixmap snapShot() const; - -private: - void paintSubChildren(QPainter *painter, - const QStyleOptionGraphicsItem *option, - QGraphicsItem *target); - - bool m_iconBig; - int stack; - QPixmap m_snapShot; - QGraphicsWidget *m_target; -}; - -} // namespace Plasma - -#endif // PLASMA_WIDGETSNAPSHOT_P_H diff --git a/plasma/animations/zoom.cpp b/plasma/animations/zoom.cpp deleted file mode 100644 index 8f07317d..00000000 --- a/plasma/animations/zoom.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2009 Igor Trindade Oliveira - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "zoom_p.h" - -#include - -namespace Plasma -{ - -ZoomAnimation::ZoomAnimation(QObject *parent) - : EasingAnimation(parent), - m_zoom(0) -{ -} - -ZoomAnimation::~ZoomAnimation() -{ -} - -void ZoomAnimation::setZoom(qreal zoom) -{ - m_zoom = zoom; -} - -qreal ZoomAnimation::zoom() const -{ - return m_zoom; -} - -void ZoomAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -{ - QGraphicsWidget *w = targetWidget(); - if (!w) { - return; - } - - if (oldState == Stopped && newState == Running) { - w->setTransformOriginPoint(w->size().width()/2, w->size().height()/2); - w->setScale(direction() == Forward ? 1 : m_zoom); - } else if (newState == Stopped) { - w->setScale(direction() == Forward ? m_zoom : 1); - } -} - -void ZoomAnimation::updateEffectiveTime(int currentTime) -{ - QGraphicsWidget *w = targetWidget(); - if (w) { - qreal delta = currentTime / qreal(duration()); - if (m_zoom != 1) { - delta = (1 - m_zoom) * delta; - w->setScale(1 - delta); - } else { - w->setScale(delta); - } - } -} - -} //namespace Plasma diff --git a/plasma/animations/zoom_p.h b/plasma/animations/zoom_p.h deleted file mode 100644 index 2c5868fe..00000000 --- a/plasma/animations/zoom_p.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2009 Igor Trindade Oliveira - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file This file contains the definition for the Zoom animation. - */ - -#ifndef PLASMA_ANIMATIONS_ZOOM_P_H -#define PLASMA_ANIMATIONS_ZOOM_P_H - -#include -#include - -namespace Plasma -{ - -/** - * @class ZoomAnimation plasma/animations/zoom_p.h - * @short Zoom Animation - * - */ -class ZoomAnimation : public EasingAnimation -{ - Q_OBJECT - Q_PROPERTY(qreal zoom READ zoom WRITE setZoom) - -public: - explicit ZoomAnimation(QObject *parent = 0); - virtual ~ZoomAnimation(); - - qreal zoom() const; - void setZoom(qreal); - -protected: - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); - void updateEffectiveTime(int currentTime); - -private: - qreal m_zoom; -}; - -} - -#endif // PLASMA_ANIMATIONS_ZOOM_P_H diff --git a/plasma/animator.cpp b/plasma/animator.cpp deleted file mode 100644 index 033537a2..00000000 --- a/plasma/animator.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - Copyright (C) 2009 Adenilson Cavalcanti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "animator.h" -#include "private/animator_p.h" - -#include - -#include "animations/animation.h" -#include "animations/animationscriptengine_p.h" -#include "animations/fade_p.h" -#include "animations/grow_p.h" -#include "animations/pulser_p.h" -#include "animations/rotation_p.h" -#include "animations/slide_p.h" -#include "animations/rotationstacked_p.h" -#include "animations/geometry_p.h" -#include "animations/zoom_p.h" -#include "animations/pixmaptransition_p.h" -#include "animations/water_p.h" -#include "animations/pendulumcurve_p.h" -#include "animations/javascriptanimation_p.h" -#include "theme.h" - -namespace Plasma -{ - -QHash AnimatorPrivate::s_stockAnimMappings; -QHash AnimatorPrivate::s_loadableAnimMappings; - -void AnimatorPrivate::mapAnimation(Animator::Animation from, Animator::Animation to) -{ - if (from == to) { - return; - } - - s_loadableAnimMappings.remove(from); - s_stockAnimMappings.insert(from, to); -} - -void AnimatorPrivate::mapAnimation(Animator::Animation from, const QString &to) -{ - s_stockAnimMappings.remove(from); - s_loadableAnimMappings.insert(from, to); -} - -Plasma::Animation* Animator::create(Animator::Animation type, QObject *parent) -{ - if (AnimatorPrivate::s_stockAnimMappings.contains(type)) { - return create(AnimatorPrivate::s_stockAnimMappings.value(type)); - } else if (AnimatorPrivate::s_loadableAnimMappings.contains(type)) { - const QString anim = AnimatorPrivate::s_loadableAnimMappings.value(type); - return create(anim, parent); - } - - Plasma::Animation *result = 0; - - switch (type) { - case FadeAnimation: - result = create("FadeAnimation", parent); - if (!result) { - result = new Plasma::FadeAnimation(parent); - } - break; - - case GrowAnimation: - result = create("GrowAnimation", parent); - if (!result) { - result = new Plasma::GrowAnimation(parent); - } - break; - - case PulseAnimation: - result = create("PulseAnimation", parent); - if (!result) { - result = new Plasma::PulseAnimation(parent); - } - break; - - case RotationAnimation: - result = create("RotationAnimation", parent); - if (!result) { - result = new Plasma::RotationAnimation(parent); - } - break; - - case RotationStackedAnimation: - result = create("RotationStackedAnimation", parent); - if (!result) { - result = new Plasma::RotationStackedAnimation(parent); - } - break; - - case SlideAnimation: - result = create("SlideAnimation", parent); - if (!result) { - result = new Plasma::SlideAnimation(parent); - } - break; - - case GeometryAnimation: - result = create("GeometryAnimation", parent); - if (!result) { - result = new Plasma::GeometryAnimation(parent); - } - break; - - case ZoomAnimation: - result = create("ZoomAnimation", parent); - if (!result) { - result = new Plasma::ZoomAnimation(parent); - } - break; - - case PixmapTransitionAnimation: - result = create("PixmapTransitionAnimation", parent); - if (!result) { - result = new Plasma::PixmapTransition(parent); - } - break; - - case WaterAnimation: - result = create("WaterAnimation", parent); - if (!result) { - result = new Plasma::WaterAnimation(parent); - } - break; - - default: - //kDebug() << "Unsupported animation type."; - break; - } - - return result; -} - -QEasingCurve Animator::create(Animator::CurveShape type) -{ - QEasingCurve result; - - switch (type) { - case EaseInCurve: - result.setType(QEasingCurve::InQuad); - break; - - case EaseOutCurve: - result.setType(QEasingCurve::OutQuad); - break; - - case EaseInOutCurve: - result.setType(QEasingCurve::InOutQuad); - break; - - case LinearCurve: - result.setType(QEasingCurve::Linear); - break; - - case PendularCurve: - result = PendulumCurve(); - break; - - default: - kDebug() << "Unsupported easing curve type."; - break; - } - - return result; -} - -Plasma::Animation *Animator::create(const QString &anim, QObject *parent) -{ - if (AnimationScriptEngine::animationFailedToLoad(anim)) { - return 0; - } - - if (!AnimationScriptEngine::isAnimationRegistered(anim)) { - const QString path = Theme::defaultTheme()->animationPath(anim); - if (path.isEmpty()) { - AnimationScriptEngine::addToLoadFailures(anim); - //kError() << "************ failed to find script file for animation" << anim; - return 0; - } - - if (!AnimationScriptEngine::loadScript(path)) { - AnimationScriptEngine::addToLoadFailures(anim); - return 0; - } - - if (!AnimationScriptEngine::isAnimationRegistered(anim)) { - //kError() << "successfully loaded script file" << path << ", but did not get animation object for" << anim; - AnimationScriptEngine::addToLoadFailures(anim); - return 0; - } - } - - return new Plasma::JavascriptAnimation(anim, parent); -} - -} // namespace Plasma - -#include "moc_animator.cpp" - diff --git a/plasma/animator.h b/plasma/animator.h deleted file mode 100644 index 4fb963f9..00000000 --- a/plasma/animator.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright 2007 Aaron Seigo - * 2007 Alexis Ménard - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef PLASMA_ANIMATOR_H -#define PLASMA_ANIMATOR_H - -#include -#include -#include -#include - -#include - -class QGraphicsItem; -class QGraphicsWidget; -class QTimeLine; - -namespace Plasma -{ - -class AnimatorPrivate; -class Animation; - -/** - * @class Animator plasma/animator.h - * - * @short A system for applying effects to Plasma elements - */ -class PLASMA_EXPORT Animator : public QObject -{ - Q_OBJECT - Q_ENUMS(Animation) - Q_ENUMS(CurveShape) - Q_ENUMS(Movement) - -public: - - enum Animation { - AppearAnimation = 0, /*<< Animate the appearance of an element */ - DisappearAnimation, /*<< Animate the disappearance of an element */ - ActivateAnimation, /*<< When something is activated or launched, - such as an app icon being clicked */ - FadeAnimation, /*<< Can be used for both fade in and out */ - GrowAnimation, /*<< Grow animated object geometry */ - PulseAnimation, /*<< Pulse animated object (opacity/geometry/scale) */ - RotationAnimation, /*<< Rotate an animated object */ - RotationStackedAnimation, /*<< for flipping one object with another */ - SlideAnimation, /*<< Move the position of animated object */ - GeometryAnimation, /*<< Geometry animation*/ - ZoomAnimation, /*< - #include #include @@ -480,14 +478,7 @@ void Applet::destroy() d->transient = true; - if (isContainment()) { - d->cleanUpAndDelete(); - } else { - Animation *zoomAnim = Plasma::Animator::create(Plasma::Animator::ZoomAnimation); - connect(zoomAnim, SIGNAL(finished()), this, SLOT(cleanUpAndDelete())); - zoomAnim->setTargetWidget(this); - zoomAnim->start(); - } + d->cleanUpAndDelete(); } bool Applet::destroyed() const @@ -2904,14 +2895,7 @@ AppletOverlayWidget::AppletOverlayWidget(QGraphicsWidget *parent) void AppletOverlayWidget::destroy() { - Animation *anim = Plasma::Animator::create(Plasma::Animator::DisappearAnimation); - if (anim) { - connect(anim, SIGNAL(finished()), this, SLOT(overlayAnimationComplete())); - anim->setTargetWidget(this); - anim->start(); - } else { - overlayAnimationComplete(); - } + overlayAnimationComplete(); } void AppletOverlayWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) @@ -2959,12 +2943,6 @@ void AppletOverlayWidget::paint(QPainter *painter, painter->fillPath(backgroundShape, wash); } -// in QGraphicsWidget now; preserve BC by implementing it as a protected method -void Applet::geometryChanged() -{ - emit QGraphicsWidget::geometryChanged(); -} - } // Plasma namespace #include "moc_applet.cpp" diff --git a/plasma/applet.h b/plasma/applet.h index d4c32784..bdf3dd3b 100644 --- a/plasma/applet.h +++ b/plasma/applet.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -720,9 +719,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget */ void releaseVisualFocus(); - protected: - void geometryChanged(); // in QGraphicsWidget now; preserve BC - Q_SIGNALS: /** * Emitted when the user completes a transformation of the applet. diff --git a/plasma/containment.cpp b/plasma/containment.cpp index 4bcbf2ec..6a6d4bd6 100644 --- a/plasma/containment.cpp +++ b/plasma/containment.cpp @@ -53,7 +53,6 @@ #endif #include "abstracttoolbox.h" -#include "animator.h" #include "containmentactions.h" #include "containmentactionspluginsconfig.h" #include "corona.h" @@ -69,7 +68,6 @@ #include "private/wallpaper_p.h" #include "plasma/plasma.h" -#include "animations/animation.h" namespace Plasma { @@ -880,17 +878,7 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit) if (!delayInit && !currentContainment) { applet->restore(*applet->d->mainConfigGroup()); applet->init(); - Plasma::Animation *anim = Plasma::Animator::create(Plasma::Animator::AppearAnimation); - if (anim) { - connect(anim, SIGNAL(finished()), this, SLOT(appletAppearAnimationComplete())); - anim->setTargetWidget(applet); - //FIXME: small hack until we have proper js anim support; allows 'zoom' to work in the - //'right' direction for appearance - anim->setDirection(QAbstractAnimation::Backward); - anim->start(QAbstractAnimation::DeleteWhenStopped); - } else { - d->appletAppeared(applet); - } + d->appletAppeared(applet); } applet->setFlag(QGraphicsItem::ItemIsMovable, true); @@ -2124,17 +2112,6 @@ void ContainmentPrivate::appletDestroyed(Plasma::Applet *applet) emit q->configNeedsSaving(); } -void ContainmentPrivate::appletAppearAnimationComplete() -{ - Animation *anim = qobject_cast(q->sender()); - if (anim) { - Applet *applet = qobject_cast(anim->targetWidget()); - if (applet) { - appletAppeared(applet); - } - } -} - void ContainmentPrivate::appletAppeared(Applet *applet) { //kDebug() << type << Containment::DesktopContainment; diff --git a/plasma/containment.h b/plasma/containment.h index a3a61854..d02638f5 100644 --- a/plasma/containment.h +++ b/plasma/containment.h @@ -30,7 +30,6 @@ #include #include -#include namespace Plasma @@ -615,7 +614,6 @@ Q_SIGNALS: Containment(const QString &packagePath, uint appletId, const QVariantList &args); Q_PRIVATE_SLOT(d, void appletDestroyed(Plasma::Applet*)) - Q_PRIVATE_SLOT(d, void appletAppearAnimationComplete()) Q_PRIVATE_SLOT(d, void triggerShowAddWidgets()) Q_PRIVATE_SLOT(d, void positionToolBox()) Q_PRIVATE_SLOT(d, void requestConfiguration()) diff --git a/plasma/corona.cpp b/plasma/corona.cpp index 98cbb361..66cebbf3 100644 --- a/plasma/corona.cpp +++ b/plasma/corona.cpp @@ -43,12 +43,10 @@ #include #include -#include "animator.h" #include "abstracttoolbox.h" #include "containment.h" #include "containmentactionspluginsconfig.h" #include "view.h" -#include "private/animator_p.h" #include "private/applet_p.h" #include "private/containment_p.h" #include "tooltipmanager.h" @@ -356,16 +354,6 @@ Containment *Corona::addContainmentDelayed(const QString &name, const QVariantLi return 0; } -void Corona::mapAnimation(Animator::Animation from, Animator::Animation to) -{ - AnimatorPrivate::mapAnimation(from, to); -} - -void Corona::mapAnimation(Animator::Animation from, const QString &to) -{ - AnimatorPrivate::mapAnimation(from, to); -} - void Corona::addOffscreenWidget(QGraphicsWidget *widget) { foreach (QGraphicsWidget *w, d->offscreenWidgets) { diff --git a/plasma/corona.h b/plasma/corona.h index 5dc2e1c7..2a135305 100644 --- a/plasma/corona.h +++ b/plasma/corona.h @@ -456,24 +456,6 @@ protected: **/ virtual void loadDefaultLayout(); - /** - * Maps a stock animation to one of the semantic animations. Used to control things such - * as what animation is used to make a Plasma::Appear appear in a containment. - * @param from the animation to map a new value to - * @param to the animation value to map to from - * @since 4.5 - */ - void mapAnimation(Animator::Animation from, Animator::Animation to); - - /** - * Maps a loadable animation to one of the semantic animations. Used to control things such - * as what animation is used to make a Plasma::Appear appear in a containment. - * @param from the animation to map a new value to - * @param to the animation value to map to from; this must map to a Javascript animation - * @since 4.5 - */ - void mapAnimation(Animator::Animation from, const QString &to); - /** * @return The preferred toolbox plugin name for a given containment type. * @param type the containment type of which we want to know the preferred toolbox plugin. diff --git a/plasma/data/servicetypes/plasma-animator.desktop b/plasma/data/servicetypes/plasma-animator.desktop deleted file mode 100644 index 3517117f..00000000 --- a/plasma/data/servicetypes/plasma-animator.desktop +++ /dev/null @@ -1,83 +0,0 @@ -[Desktop Entry] -Type=ServiceType -X-KDE-ServiceType=Plasma/Animator - -Comment=Plasma Animation Engine -Comment[ar]=محرك تحريك البلازما -Comment[as]=Plasma Animation Engine -Comment[ast]=Motor d'animación Plasma -Comment[be@latin]=Systema animacyi „Plasma” -Comment[bg]=Ядро за анимации на Plasma -Comment[bn]=প্লাসমা অ্যানিমেশন ইঞ্জিন -Comment[bn_IN]=Plasma অ্যানিমেশন ইঞ্জিন -Comment[bs]=Plazma motor animacija -Comment[ca]=Motor d'animació del Plasma -Comment[ca@valencia]=Motor d'animació del Plasma -Comment[cs]=Animační nástroj Plasma -Comment[da]=Plasma-animationsmotor -Comment[de]=Plasma-Animations-Treiber -Comment[el]=Μηχανή εφέ κίνησης του Plasma -Comment[en_GB]=Plasma Animation Engine -Comment[eo]=Viviga motoro de Plasma -Comment[es]=Motor de animación para Plasma -Comment[et]=Plasma animatsiooni mootor -Comment[eu]=Plasma animazio motorra -Comment[fi]=Plasma-animointimoottori -Comment[fr]=Moteur d'animation Plasma -Comment[fy]=Plasma animaasje motor -Comment[ga]=Inneall Beochana Plasma -Comment[gl]=Motor de animación de Plasma -Comment[gu]=પ્લાઝમા એનિમેશન એન્જિન -Comment[he]=מנוע אנימציה של Plasma -Comment[hne]=प्लाज्मा एनिमेशन इंजिन -Comment[hr]=Plasmin animatorski mehanizam -Comment[hsb]=Plasma-engine za animacije -Comment[hu]=Plasma animációkezelő -Comment[hy]=Պլազմա կենդանության գործիք -Comment[ia]=Motor de animation Plasma -Comment[id]=Mesin Animasi Plasma -Comment[is]=Plasma hreyfingastjóri -Comment[it]=Motore animazione Plasma -Comment[ja]=Plasma アニメーションエンジン -Comment[kk]=Plasma анимация тетігі -Comment[km]=ម៉ាស៊ីន​ចលនា​របស់ប្លាស្មា -Comment[kn]=ಪ್ಲಾಸ್ಮಾ ಸಜೀವನ (ಅನಿಮೇಷನ್) ಯಂತ್ರ -Comment[ko]=Plasma 애니메이션 엔진 -Comment[ku]=Motora Zindîkirina Plasma -Comment[lt]=Plasma animacijos varikliukas -Comment[lv]=Plasma animācijas dzinējs -Comment[mai]=प्लाजमा भावचिन्ह इंजन -Comment[ml]=പ്ലാസ്മ അനിമേഷന്‍ എഞ്ചിന്‍ -Comment[mr]=प्लाज्मा एनीमेशन इंजिन -Comment[nb]=Plasma animasjonsmotor -Comment[nds]=Plasma-Animeerkarn -Comment[nl]=Plasma-animatie-engine -Comment[nn]=Plasma-animasjonsmotor -Comment[pa]=ਪਲਾਜ਼ਮਾ ਐਨੀਮੇਸ਼ਨ ਇੰਜਣ -Comment[pl]=Silnik animacji Plazmy -Comment[pt]=Motor de Animação do Plasma -Comment[pt_BR]=Mecanismo de animação do Plasma -Comment[ro]=Motor de animație Plasma -Comment[ru]=Движок анимации для Plasma -Comment[se]=Plasma-animerenmohtor -Comment[si]=Plasma සජිවීකරණ එන්ජිම -Comment[sk]=Animačný nástroj Plasma -Comment[sl]=Animacijski pogon za Plasmo -Comment[sr]=Плазма мотор анимација -Comment[sr@ijekavian]=Плазма мотор анимација -Comment[sr@ijekavianlatin]=Plasma motor animacija -Comment[sr@latin]=Plasma motor animacija -Comment[sv]=Animeringsgränssnitt i Plasma -Comment[ta]=பிளாஸ்மா அசைவூட்ட இயந்திரம் -Comment[tg]=Системаи аниматсионии Plasma -Comment[th]=กลไกแสดงความเคลื่อนไหวของพลาสมา -Comment[tr]=Plasma Canlandırma Motoru -Comment[tt]=Plasma анимация өчен корал -Comment[ug]=Plasma جانلاندۇرۇم ماتورى -Comment[uk]=Рушій анімації Плазми -Comment[vi]=Cơ chế hoạt ảnh Plasma -Comment[wa]=Moteur d' animåcion di Plasma -Comment[x-test]=xxPlasma Animation Enginexx -Comment[zh_CN]=Plasma 动画引擎 -Comment[zh_TW]=Plasma 動畫引擎 - diff --git a/plasma/dataengine.cpp b/plasma/dataengine.cpp index 2ddad493..0b849ce0 100644 --- a/plasma/dataengine.cpp +++ b/plasma/dataengine.cpp @@ -328,11 +328,10 @@ void DataEngine::removeAllSources() while (it.hasNext()) { it.next(); Plasma::DataContainer *s = it.value(); - const QString source = it.key(); it.remove(); s->disconnect(this); s->deleteLater(); - emit sourceRemoved(source); + emit sourceRemoved(it.key()); } } diff --git a/plasma/dialog.cpp b/plasma/dialog.cpp index a4640119..d9aceeaf 100644 --- a/plasma/dialog.cpp +++ b/plasma/dialog.cpp @@ -46,7 +46,6 @@ #include #include "plasma/applet.h" -#include "plasma/animator.h" #include "plasma/containment.h" #include "plasma/corona.h" #include "plasma/extenders/extender.h" diff --git a/plasma/private/abstractanimationprivate_p.h b/plasma/private/abstractanimationprivate_p.h deleted file mode 100644 index b9ed354e..00000000 --- a/plasma/private/abstractanimationprivate_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2009 Adenilson Cavalcanti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PLASMA_ABSTRACTANIMATIONPRIVATE_P_H -#define PLASMA_ABSTRACTANIMATIONPRIVATE_P_H - -#include -#include -class QAbstractAnimation; - -namespace Plasma -{ - -class AnimationPrivate -{ -public: - - AbstractAnimationPrivate(); - /** - * Object the animation(s) should act upon. - */ - QWeakPointer animObject; - - /** - * Animation direction: where the animation will move. - */ - qint8 animDirection; - - /** - * Animation distance: displacement factor for animations where - * there is change in the position of animated widget. - */ - qreal animDistance; - - /** - * Animation easing curve type - */ - QEasingCurve easingCurve; - - /** - * Animation direction, the idea is to offer a way - * to rewind the animation by setDirection(QAbstractAnimation::Backward). - */ - bool forwards; - - /** - * Duration of the animation. Default is 250ms. - */ - int duration; - -}; - -} - -#endif // PLASMA_ABSTRACTANIMATIONPRIVATE_P_H diff --git a/plasma/private/animationprivate_p.h b/plasma/private/animationprivate_p.h deleted file mode 100644 index d56a07ab..00000000 --- a/plasma/private/animationprivate_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2009 Adenilson Cavalcanti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PLASMA_ANIMATIONPRIVATE_P_H -#define PLASMA_ANIMATIONPRIVATE_P_H - -#include -#include -class QAbstractAnimation; - -namespace Plasma -{ - -class AnimationPrivate -{ -public: - - AnimationPrivate(); - /** - * Object the animation(s) should act upon. - */ - QWeakPointer animObject; - - /** - * Animation easing curve type - */ - QEasingCurve easingCurve; - - /** - * Duration of the animation. Default is 250ms. - */ - int duration; -}; - -} - -#endif // PLASMA_ANIMATIONPRIVATE_P_H diff --git a/plasma/private/animator_p.h b/plasma/private/animator_p.h deleted file mode 100644 index 36c66717..00000000 --- a/plasma/private/animator_p.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2007 Aaron Seigo - * 2007 Alexis Ménard - * - * This program 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, or - * (at your option) any later version. - * - * This program 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 General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef ANIMATOR_P_H -#define ANIMATOR_P_H - -#include -#include -#include -#include -#include - -class QGraphicsItem; - -namespace Plasma -{ - -class AnimationDriver; -class KineticScrolling; - -struct AnimationState -{ - QGraphicsItem *item; - QObject *qobj; - Animator::Animation animation; - Animator::CurveShape curve; - int interval; - int currentInterval; - int frames; - int currentFrame; - int id; -}; - -struct ElementAnimationState -{ - QGraphicsItem *item; - QObject *qobj; - Animator::CurveShape curve; - Animator::Animation animation; - int interval; - int currentInterval; - int frames; - int currentFrame; - int id; - QPixmap pixmap; -}; - -struct MovementState -{ - QGraphicsItem *item; - QObject *qobj; - Animator::CurveShape curve; - Animator::Movement movement; - int interval; - int currentInterval; - int frames; - int currentFrame; - QPoint start; - QPoint destination; - int id; -}; - -struct CustomAnimationState -{ - Animator::CurveShape curve; - int frames; - int currentFrame; - int frameInterval; - int interval; - int currentInterval; - int id; - QObject *receiver; - char *slot; -}; - -class Animator; - -class AnimatorPrivate -{ - public: - AnimatorPrivate(Animator *parent); - ~AnimatorPrivate(); - - qreal calculateProgress(int time, int duration, Animator::CurveShape curve); - void performAnimation(qreal amount, const AnimationState *state); - void performMovement(qreal amount, const MovementState *state); - - void init(Animator *q); - void cleanupStates(); - void animatedItemDestroyed(QObject*); - void movingItemDestroyed(QObject*); - void animatedElementDestroyed(QObject*); - void customAnimReceiverDestroyed(QObject*); - - void scrollStateChanged(QAbstractAnimation::State newState, - QAbstractAnimation::State oldState); - - Animator *q; - AnimationDriver *driver; - int animId; - int timerId; - QTime time; - QTimeLine timeline; - - // active items - QHash animatedItems; - QHash movingItems; - QHash animatedElements; - QHash customAnims; - - // items to cull - QSet animatedItemsToDelete; - QSet movingItemsToDelete; - QSet animatedElementsToDelete; - QSet customAnimsToDelete; - - QHash scrollingManagers; - - static void mapAnimation(Animator::Animation from, Animator::Animation to); - static void mapAnimation(Animator::Animation from, const QString &to); - - static QHash s_stockAnimMappings; - static QHash s_loadableAnimMappings; -}; - -} - -#endif - diff --git a/plasma/private/applet_p.h b/plasma/private/applet_p.h index f093c8e1..29db7158 100644 --- a/plasma/private/applet_p.h +++ b/plasma/private/applet_p.h @@ -28,7 +28,6 @@ #include #include -#include "plasma/animator.h" #include "plasma/private/applethandle_p.h" #include "plasma/private/dataengineconsumer_p.h" diff --git a/plasma/private/applethandle_p.h b/plasma/private/applethandle_p.h index f249a193..462fd90c 100644 --- a/plasma/private/applethandle_p.h +++ b/plasma/private/applethandle_p.h @@ -28,7 +28,6 @@ #include #include -#include "animator.h" #include "svg.h" class QGraphicsView; diff --git a/plasma/private/focusindicator.cpp b/plasma/private/focusindicator.cpp index 0a336076..37418490 100644 --- a/plasma/private/focusindicator.cpp +++ b/plasma/private/focusindicator.cpp @@ -27,8 +27,6 @@ #include #include -#include - namespace Plasma { @@ -59,15 +57,6 @@ void FocusIndicator::init(QGraphicsWidget *parent) m_background->setCacheAllRenderedFrames(true); - m_fade = Animator::create(Animator::FadeAnimation, this); - m_fade->setTargetWidget(this); - m_fade->setProperty("startOpacity", 0.0); - m_fade->setProperty("targetOpacity", 1.0); - - m_hoverAnimation = Animator::create(Animator::PixmapTransitionAnimation); - m_hoverAnimation->setProperty("duration", 250); - m_hoverAnimation->setTargetWidget(this); - m_testPrefix = "hover"; if (m_background->hasElementPrefix("shadow") || m_background->hasElement("shadow")) { @@ -81,7 +70,6 @@ void FocusIndicator::init(QGraphicsWidget *parent) FocusIndicator::~FocusIndicator() { m_parent->removeEventFilter(this); - delete m_fade; } void FocusIndicator::setCustomGeometry(const QRectF &geometry) @@ -138,18 +126,10 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event) if (!m_parent->hasFocus()) { m_prefix = m_customPrefix % "hover"; syncGeometry(); - m_hoverAnimation->stop(); if (m_background->hasElementPrefix(m_testPrefix)) { m_background->setElementPrefix(m_customPrefix % "shadow"); - m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); m_background->setElementPrefix(m_customPrefix % "hover"); - m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); - } else if (m_background->hasElement(m_testPrefix)) { - m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "shadow")); - m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "hover")); } - - m_hoverAnimation->start(); } break; @@ -157,18 +137,11 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event) if (!m_parent->hasFocus()) { m_prefix = m_customPrefix % "shadow"; syncGeometry(); - m_hoverAnimation->stop(); if (m_background->hasElementPrefix(m_testPrefix)) { m_background->setElementPrefix(m_customPrefix % "hover"); - m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); m_background->setElementPrefix(m_customPrefix % "shadow"); - m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); - } else if (m_background->hasElement(m_testPrefix)) { - m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "hover")); - m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow")); } - m_hoverAnimation->start(); } break; @@ -179,38 +152,23 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event) case QEvent::FocusIn: m_prefix = m_customPrefix % "focus"; syncGeometry(); - m_hoverAnimation->stop(); if (m_background->hasElementPrefix(m_customPrefix % "focus")) { //m_background->setElementPrefix(m_customPrefix % "shadow"); - m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); m_background->setElementPrefix(m_customPrefix % "focus"); - m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); - } else if (m_background->hasElement(m_customPrefix % "focus")) { - //m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "shadow")); - m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "focus")); } - m_hoverAnimation->start(); break; case QEvent::FocusOut: if (!m_isUnderMouse) { m_prefix = m_customPrefix % "shadow"; syncGeometry(); - m_hoverAnimation->stop(); if (m_background->hasElementPrefix(m_customPrefix % "focus")) { m_background->setElementPrefix("focus"); - m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); m_background->setElementPrefix("shadow"); - m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); - } else if (m_background->hasElement(m_customPrefix % "focus")) { - m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "focus")); - m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow")); } - - m_hoverAnimation->start(); } break; @@ -238,40 +196,17 @@ void FocusIndicator::resizeEvent(QGraphicsSceneResizeEvent *) m_background->resizeFrame(size()); } - if (m_hoverAnimation->state() == QAbstractAnimation::Running) { - m_hoverAnimation->stop(); - } - if (m_background->hasElementPrefix(m_testPrefix)) { m_background->setElementPrefix(m_prefix); - m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); - m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); - } else if (m_background->hasElement(m_testPrefix)) { - m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_prefix)); - m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_prefix)); } } -void FocusIndicator::animateVisibility(const bool visible) -{ - m_fade->setProperty("startOpacity", opacity()); - - if (visible) { - m_fade->setProperty("targetOpacity", 1.0); - } else { - m_fade->setProperty("targetOpacity", 0); - } - m_fade->start(); -} - void FocusIndicator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + Q_UNUSED(painter) Q_UNUSED(option) Q_UNUSED(widget) - - painter->drawPixmap( - option->rect, - m_hoverAnimation->property("currentPixmap").value()); +#pragma remove? it is a stub now... } void FocusIndicator::syncGeometry() diff --git a/plasma/private/focusindicator_p.h b/plasma/private/focusindicator_p.h index 12a81d08..31785253 100644 --- a/plasma/private/focusindicator_p.h +++ b/plasma/private/focusindicator_p.h @@ -22,8 +22,6 @@ #include -#include - namespace Plasma { class FrameSvg; @@ -40,7 +38,6 @@ public: void setCustomGeometry(const QRectF &geometry); void setCustomPrefix(const QString &prefix); - void animateVisibility(const bool visible); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void setFrameSvg(FrameSvg *svg); @@ -57,8 +54,6 @@ private: void init(QGraphicsWidget *parent); QGraphicsWidget *m_parent; Plasma::FrameSvg *m_background; - Animation *m_fade; - Animation *m_hoverAnimation; QRectF m_customGeometry; QString m_prefix; QString m_customPrefix; diff --git a/plasma/private/nativetabbar.cpp b/plasma/private/nativetabbar.cpp index d112e561..b3b09374 100644 --- a/plasma/private/nativetabbar.cpp +++ b/plasma/private/nativetabbar.cpp @@ -28,10 +28,7 @@ #include #include #include -#include #include - -#include #include // KDE @@ -43,7 +40,6 @@ #include "plasma/plasma.h" #include "plasma/theme.h" -#include "plasma/animator.h" #include "plasma/framesvg.h" #include "plasma/paintutils.h" @@ -107,8 +103,6 @@ public: QList highlightedTabs; - QWeakPointer anim; - QRect currentAnimRect; QRect startAnimRect; QPoint mousePressOffset; @@ -140,13 +134,11 @@ NativeTabBar::NativeTabBar(QWidget *parent) : KTabBar(parent), d(new NativeTabBarPrivate(this)) { - connect(this, SIGNAL(currentChanged(int)), this, SLOT(startAnimation())); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } NativeTabBar::~NativeTabBar() { - d->anim.clear(); delete d; } @@ -263,13 +255,7 @@ void NativeTabBar::paintEvent(QPaintEvent *event) } // Drawing Tabborders - QRect movingRect; - - if (d->currentAnimRect.isNull() || !d->anim || d->anim.data()->state() != QAbstractAnimation::Running) { - movingRect = tabRect(currentIndex()); - } else { - movingRect = d->currentAnimRect; - } + const QRect movingRect = d->currentAnimRect; //resizing here because in resizeevent the first time is invalid (still no tabs) d->buttonSvg->resizeFrame(movingRect.size()); @@ -445,42 +431,9 @@ void NativeTabBar::tabLayoutChange() } } -void NativeTabBar::startAnimation() -{ - d->storeLastIndex(); - - QPropertyAnimation *anim = d->anim.data(); - if (anim) { - anim->stop(); - d->anim.clear(); - } - - anim = new QPropertyAnimation(this, "onValueChanged", this); - d->anim = anim; - anim->setDuration(150); - - QRect rect = tabRect(currentIndex()); - QRect lastRect = d->startAnimRect.isNull() ? tabRect(lastIndex()) - : d->startAnimRect; - int x = isHorizontal() ? (int)(lastRect.x() - (lastRect.x() - rect.x())) : rect.x(); - int y = isHorizontal() ? rect.y() : (int)(lastRect.y() - (lastRect.y() - rect.y())); - QSizeF sz = lastRect.size() - (lastRect.size() - rect.size()); - d->currentAnimRect = QRect(x, y, (int)(sz.width()), (int)(sz.height())); - - anim->setStartValue(lastRect); - anim->setEndValue(d->currentAnimRect); - anim->start(QAbstractAnimation::DeleteWhenStopped); -} - void NativeTabBar::setOnValueChanged(QRectF value) { - if (value == d->anim.data()->endValue()) { - d->animProgress = 1; - animationFinished(); - return; - } - - d->currentAnimRect = value.toRect(); + Q_UNUSED(value); update(); } @@ -489,13 +442,6 @@ QRectF NativeTabBar::onValueChanged() const return d->currentAnimRect; } -void NativeTabBar::animationFinished() -{ - d->startAnimRect = QRect(); - d->currentAnimRect = QRect(); - update(); -} - bool NativeTabBar::isVertical() const { switch (shape()) { diff --git a/plasma/private/nativetabbar_p.h b/plasma/private/nativetabbar_p.h index 02ccb482..6b5f8866 100644 --- a/plasma/private/nativetabbar_p.h +++ b/plasma/private/nativetabbar_p.h @@ -74,8 +74,6 @@ protected: void mouseReleaseEvent(QMouseEvent *event); protected slots: - void animationFinished(); - void startAnimation(); void setOnValueChanged(QRectF val); QRectF onValueChanged() const; diff --git a/plasma/scripting/appletscript.cpp b/plasma/scripting/appletscript.cpp index a1faeb16..ac28a347 100644 --- a/plasma/scripting/appletscript.cpp +++ b/plasma/scripting/appletscript.cpp @@ -22,8 +22,6 @@ #include "kconfig.h" #include "kconfigdialog.h" -#include "animations/animationscriptengine_p.h" -#include "animator.h" #include "applet.h" #include "package.h" #include "private/applet_p.h" @@ -181,46 +179,6 @@ bool AppletScript::isRegisteredAsDragHandle(QGraphicsItem *item) return false; } -Animation *AppletScript::loadAnimationFromPackage(const QString &name, QObject *parent) -{ - if (applet()) { - const QString scopedName = applet()->pluginName() + ":" + name; - if (!AnimationScriptEngine::isAnimationRegistered(scopedName)) { - KConfig conf(applet()->package()->path() + "/metadata.desktop", KConfig::SimpleConfig); - KConfigGroup animConf(&conf, "Animations"); - QString file; - foreach (const QString &possibleFile, animConf.keyList()) { - const QStringList anims = animConf.readEntry(possibleFile, QStringList()); - if (anims.contains(name)) { - file = possibleFile; - break; - } - } - - if (file.isEmpty()) { - return 0; - } - - const QString path = applet()->package()->filePath("animations", file); - if (path.isEmpty()) { - kDebug() << "file path was empty for" << file; - return 0; - } - - if (!AnimationScriptEngine::loadScript(path, applet()->pluginName() + ':') || - !AnimationScriptEngine::isAnimationRegistered(scopedName)) { - kDebug() << "script engine loading failed for" << path; - return 0; - } - } - - Animation *anim = Animator::create(scopedName, parent ? parent : this); - return anim; - } - - return 0; -} - void AppletScript::configChanged() { } diff --git a/plasma/scripting/appletscript.h b/plasma/scripting/appletscript.h index 8572f3ae..c78cf798 100644 --- a/plasma/scripting/appletscript.h +++ b/plasma/scripting/appletscript.h @@ -252,14 +252,6 @@ protected: */ bool isRegisteredAsDragHandle(QGraphicsItem *item); - /** - * Loads an animation from the applet package - * @param animation the animation to load - * @return an Animation object on success, a NULL pointer on failure - * @since 4.5 - */ - Animation *loadAnimationFromPackage(const QString &name, QObject *parent); - private: friend class Applet; friend class PopupApplet; diff --git a/plasma/theme.cpp b/plasma/theme.cpp index e28d6d96..d48bfb3b 100644 --- a/plasma/theme.cpp +++ b/plasma/theme.cpp @@ -44,8 +44,6 @@ #include #include - -#include "animations/animationscriptengine_p.h" #include "libplasma-theme-global.h" #include "private/packages_p.h" #include "windoweffects.h" @@ -190,7 +188,6 @@ public: QHash pixmapsToCache; QHash keysToCache; QHash idsToCache; - QHash animationMapping; QHash cachedStyleSheets; QHash discoveries; QTimer *saveTimer; @@ -652,28 +649,6 @@ void ThemePrivate::processWallpaperSettings(KConfigBase *metadata) defaultWallpaperHeight = cg.readEntry("defaultHeight", DEFAULT_WALLPAPER_HEIGHT); } -void ThemePrivate::processAnimationSettings(const QString &theme, KConfigBase *metadata) -{ - KConfigGroup cg(metadata, "Animations"); - const QString animDir = QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/animations/"); - foreach (const QString &path, cg.keyList()) { - const QStringList anims = cg.readEntry(path, QStringList()); - foreach (const QString &anim, anims) { - if (!animationMapping.contains(anim)) { - kDebug() << "Registering animation. animDir: " << animDir - << "\tanim: " << anim - << "\tpath: " << path << "\t*******\n\n\n"; - //key: desktoptheme/default/animations/+ all.js - //value: ZoomAnimation - animationMapping.insert(anim, animDir % path); - } else { - kDebug() << "************Animation already registered!\n\n\n"; - } - } - } - -} - void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings) { //kDebug() << tempThemeName; @@ -723,10 +698,6 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings processWallpaperSettings(&metadata); - AnimationScriptEngine::clearAnimations(); - animationMapping.clear(); - processAnimationSettings(themeName, &metadata); - KConfigGroup cg(&metadata, "Settings"); useNativeWidgetStyle = cg.readEntry("UseNativeWidgetStyle", false); QString fallback = cg.readEntry("FallbackTheme", QString()); @@ -752,7 +723,6 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings foreach (const QString &theme, fallbackThemes) { QString metadataPath(KStandardDirs::locate("data", QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/metadata.desktop"))); KConfig metadata(metadataPath); - processAnimationSettings(theme, &metadata); processWallpaperSettings(&metadata); } } @@ -838,17 +808,6 @@ QString Theme::styleSheet(const QString &css) const return d->processStyleSheet(css); } -QString Theme::animationPath(const QString &name) const -{ - const QString path = d->animationMapping.value(name); - if (path.isEmpty()) { - //kError() << "****** FAILED TO FIND IN MAPPING!"; - return path; - } - - return KStandardDirs::locate("data", path); -} - QString Theme::wallpaperPath(const QSize &size) const { QString fullPath; diff --git a/plasma/theme.h b/plasma/theme.h index 718c6934..bbc44947 100644 --- a/plasma/theme.h +++ b/plasma/theme.h @@ -135,15 +135,6 @@ class PLASMA_EXPORT Theme : public QObject */ Q_INVOKABLE QString imagePath(const QString &name) const; - /** - * Retrieves the path for the script file that contains a given - * Javascript animation. - * @param the name of the animation - * @return the full path to the script file, or an emptry string on failure - * @since 4.5 - */ - Q_INVOKABLE QString animationPath(const QString &name) const; - /** * Retrieves the default wallpaper associated with this theme. * diff --git a/plasma/widgets/flashinglabel.cpp b/plasma/widgets/flashinglabel.cpp index f9e4a6d0..4d879651 100644 --- a/plasma/widgets/flashinglabel.cpp +++ b/plasma/widgets/flashinglabel.cpp @@ -31,8 +31,6 @@ #include -#include -#include #include using namespace Plasma; @@ -81,7 +79,6 @@ class Plasma::FlashingLabelPrivate QFont font; QPixmap pixmap; - QWeakPointer anim; QPixmap renderedPixmap; QTextOption textOption; @@ -168,14 +165,6 @@ void FlashingLabel::flash(const QPixmap &pixmap, int duration, Qt::Alignment ali void FlashingLabel::setAutohide(bool autohide) { d->autohide = autohide; - - if (autohide) { - if (d->anim.data()) { - connect(d->anim.data(), SIGNAL(finished()), this, SLOT(elementAnimationFinished())); - } - } else if (d->anim.data()) { - disconnect(d->anim.data(), SIGNAL(finished()), this, SLOT(elementAnimationFinished())); - } } bool FlashingLabel::autohide() const @@ -199,19 +188,6 @@ void FlashingLabel::fadeIn() } d->state = FlashingLabelPrivate::Visible; - if (!d->anim.data()) { - d->anim = Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation); - Plasma::Animation *animation = d->anim.data(); - animation->setProperty("startPixmap", d->renderedPixmap); - animation->setTargetWidget(this); - animation->start(); - } else { - Plasma::Animation *animation = d->anim.data(); - if (animation->state() == QAbstractAnimation::Running) { - animation->stop(); - animation->start(); - } - } } void FlashingLabel::fadeOut() @@ -221,18 +197,6 @@ void FlashingLabel::fadeOut() } d->state = FlashingLabelPrivate::Invisible; - if (d->anim.data()) { - Plasma::Animation *animation = d->anim.data(); - animation->setProperty("direction", QAbstractAnimation::Backward); - animation->start(QAbstractAnimation::DeleteWhenStopped); - } else { - d->anim = Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation); - Plasma::Animation *animation = d->anim.data(); - animation->setProperty("direction", QAbstractAnimation::Backward); - animation->setProperty("startPixmap", d->renderedPixmap); - animation->setTargetWidget(this); - animation->start(QAbstractAnimation::DeleteWhenStopped); - } } void FlashingLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) @@ -240,10 +204,7 @@ void FlashingLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt Q_UNUSED(option) Q_UNUSED(widget) - if (d->anim.data() && d->anim.data()->state() == QAbstractAnimation::Running) { - Plasma::Animation *animation = d->anim.data(); - painter->drawPixmap(0, 0, qvariant_cast(animation->property("currentPixmap"))); - } else if (d->state == FlashingLabelPrivate::Visible) { + if (d->state == FlashingLabelPrivate::Visible) { painter->drawPixmap(0, 0, d->renderedPixmap); } } @@ -291,11 +252,6 @@ void FlashingLabelPrivate::renderPixmap(const QSize &size) painter.drawPixmap(p, pixmap); } painter.end(); - - if (anim.data()) { - Plasma::Animation *animation = anim.data(); - animation->setProperty("startPixmap", renderedPixmap); - } } void FlashingLabelPrivate::setupFlash(int duration) @@ -317,7 +273,7 @@ void FlashingLabelPrivate::setupFlash(int duration) void FlashingLabelPrivate::elementAnimationFinished() { - if (autohide && state == FlashingLabelPrivate::Invisible && anim.data()) { + if (autohide && state == FlashingLabelPrivate::Invisible) { q->hide(); } } diff --git a/plasma/widgets/iconwidget.cpp b/plasma/widgets/iconwidget.cpp index ebfe71cb..0f55a396 100644 --- a/plasma/widgets/iconwidget.cpp +++ b/plasma/widgets/iconwidget.cpp @@ -44,8 +44,6 @@ #include #include -#include "animator.h" -#include "animations/animation.h" #include "paintutils.h" #include "private/themedwidgetinterface_p.h" #include "theme.h" @@ -77,11 +75,6 @@ bool IconHoverAnimation::fadeIn() const return m_fadeIn; } -QPropertyAnimation *IconHoverAnimation::animation() const -{ - return m_animation.data(); -} - void IconHoverAnimation::setValue(qreal value) { m_value = value; @@ -94,11 +87,6 @@ void IconHoverAnimation::setFadeIn(bool fadeIn) m_fadeIn = fadeIn; } -void IconHoverAnimation::setAnimation(QPropertyAnimation *animation) -{ - m_animation = animation; -} - IconWidgetPrivate::IconWidgetPrivate(IconWidget *i) : ActionWidgetInterface(i), iconSvg(0), @@ -170,38 +158,13 @@ IconAction::IconAction(IconWidget *icon, QAction *action) void IconAction::show() { - Animation *animation = m_animation.data(); - if (!animation) { - animation = Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation, m_icon); - animation->setTargetWidget(m_icon); - m_animation = animation; - } else if (animation->state() == QAbstractAnimation::Running) { - animation->pause(); - } - rebuildPixmap(); m_visible = true; - - animation->setProperty("targetPixmap", m_pixmap); - animation->setDirection(QAbstractAnimation::Forward); - animation->start(); } void IconAction::hide() { - if (!m_animation) { - return; - } - - Animation *animation = m_animation.data(); - if (animation->state() == QAbstractAnimation::Running) { - animation->pause(); - } - m_visible = false; - - animation->setDirection(QAbstractAnimation::Backward); - animation->start(QAbstractAnimation::DeleteWhenStopped); } bool IconAction::isVisible() const @@ -209,11 +172,6 @@ bool IconAction::isVisible() const return m_visible; } -bool IconAction::isAnimating() const -{ - return !m_animation.isNull(); -} - bool IconAction::isPressed() const { return m_pressed; @@ -339,12 +297,8 @@ void IconAction::paint(QPainter *painter) const return; } - Animation *animation = m_animation.data(); - if (m_visible && !animation) { + if (m_visible) { painter->drawPixmap(m_rect.toRect(), m_pixmap); - } else { - painter->drawPixmap(m_rect.toRect(), - animation->property("currentPixmap").value()); } } @@ -748,21 +702,6 @@ void IconWidgetPrivate::animateMainIcon(bool show, const IconWidgetStates state) hoverAnimation->setFadeIn(show); - QPropertyAnimation *animation = hoverAnimation->animation(); - if (!animation) { - animation = new QPropertyAnimation(hoverAnimation, "value"); - animation->setDuration(150); - animation->setEasingCurve(QEasingCurve::OutQuad); - animation->setStartValue(0.0); - animation->setEndValue(1.0); - hoverAnimation->setAnimation(animation); - q->connect(animation, SIGNAL(finished()), q, SLOT(hoverAnimationFinished())); - } else if (animation->state() == QAbstractAnimation::Running) { - animation->pause(); - } - - animation->setDirection(show ? QAbstractAnimation::Forward : QAbstractAnimation::Backward); - animation->start(show ? QAbstractAnimation::KeepWhenStopped : QAbstractAnimation::DeleteWhenStopped); q->update(); } @@ -1163,11 +1102,10 @@ void IconWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option painter->drawPixmap(iconPos, icon); } +#pragma probably drop the loop interly // Draw corner actions foreach (const IconAction *action, d->cornerActions) { - if (action->isAnimating()) { - action->paint(painter); - } + action->paint(painter); } // Draw text last because it is overlayed diff --git a/plasma/widgets/iconwidget.h b/plasma/widgets/iconwidget.h index f9cd5a65..682baa8b 100644 --- a/plasma/widgets/iconwidget.h +++ b/plasma/widgets/iconwidget.h @@ -30,11 +30,9 @@ #include #include -#include #include class QAction; -class QPropertyAnimation; /** * @class IconWidget plasma/widgets/iconwidget.h diff --git a/plasma/widgets/iconwidget_p.h b/plasma/widgets/iconwidget_p.h index dc89560f..22bec01f 100644 --- a/plasma/widgets/iconwidget_p.h +++ b/plasma/widgets/iconwidget_p.h @@ -79,7 +79,6 @@ public: void show(); void hide(); bool isVisible() const; - bool isAnimating() const; QAction *action() const; diff --git a/plasma/widgets/itembackground.cpp b/plasma/widgets/itembackground.cpp index 3a0a5139..3783e323 100644 --- a/plasma/widgets/itembackground.cpp +++ b/plasma/widgets/itembackground.cpp @@ -28,7 +28,6 @@ #include #include -#include #include namespace Plasma { @@ -63,9 +62,6 @@ ItemBackground::ItemBackground(QGraphicsWidget *parent) d(new ItemBackgroundPrivate(this)) { d->frameSvg = new Plasma::FrameSvg(this); - d->anim = new QPropertyAnimation(this, "animationUpdate", this); - d->anim->setStartValue(0); - d->anim->setEndValue(1); d->opacity = 1; d->fading = false; d->fadeIn = false; @@ -122,10 +118,6 @@ void ItemBackground::setTarget(const QRectF &newGeometry) d->newGeometry = d->newGeometry.intersected(QRectF(QPointF(0,0), pw->size())); } - if (d->anim->state() != QAbstractAnimation::Stopped) { - d->anim->stop(); - } - if (d->target && d->target->isVisible() && !isVisible()) { setZValue(d->target->zValue()-1); setGeometry(newGeometry); @@ -134,7 +126,6 @@ void ItemBackground::setTarget(const QRectF &newGeometry) } else { d->fading = false; d->opacity = 1; - d->anim->start(); } } @@ -241,19 +232,12 @@ QVariant ItemBackground::itemChange(GraphicsItemChange change, const QVariant &v if (change == ItemVisibleChange) { bool visible = value.toBool(); bool retVisible = visible; - if (visible == isVisible() || d->anim->state() == QAbstractAnimation::Stopped) { + if (visible == isVisible()) { retVisible = true; } d->fading = true; d->fadeIn = visible; - if (d->anim->state() != QAbstractAnimation::Stopped) { - d->anim->stop(); - } - - d->anim->setDuration(250); - d->anim->start(); - return retVisible; } diff --git a/plasma/widgets/meter.cpp b/plasma/widgets/meter.cpp index 8fa2c9e8..c17112aa 100644 --- a/plasma/widgets/meter.cpp +++ b/plasma/widgets/meter.cpp @@ -24,12 +24,10 @@ #include #include -#include #include #include -#include "plasma/animator.h" #include "plasma/framesvg.h" #include "plasma/theme.h" @@ -271,13 +269,10 @@ Meter::Meter(QGraphicsItem *parent) : d(new MeterPrivate(this)) { d->setSizePolicyAndPreferredSize(); - - d->animation = new QPropertyAnimation(d, "meterValue"); } Meter::~Meter() { - delete d->animation; delete d; } @@ -315,19 +310,11 @@ void Meter::setValue(int value) d->targetValue = qBound(d->minimum, value, d->maximum); int delta = abs(d->value - d->targetValue); - if (d->animation->state() != QAbstractAnimation::Running) { - d->animation->stop(); - } - //kDebug() << d->targetValue << d->value << delta; if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) || delta / qreal(d->maximum) < 0.1) { d->value = value; update(); - } else { - d->animation->setStartValue(d->value); - d->animation->setEndValue(value); - d->animation->start(); } emit valueChanged(value); } diff --git a/plasma/widgets/pushbutton.cpp b/plasma/widgets/pushbutton.cpp index 0157a5ae..e6befc38 100644 --- a/plasma/widgets/pushbutton.cpp +++ b/plasma/widgets/pushbutton.cpp @@ -30,8 +30,6 @@ #include #include -#include "animator.h" -#include "animations/animation.h" #include "framesvg.h" #include "paintutils.h" #include "private/actionwidgetinterface_p.h" @@ -102,15 +100,6 @@ public: static_cast(q->widget())->setIcon(KIcon(pm)); } - void pressedChanged() - { - if (q->nativeWidget()->isDown() || q->nativeWidget()->isChecked()) { - focusIndicator->animateVisibility(false); - } else { - focusIndicator->animateVisibility(true); - } - } - void syncFrame() { if (background) { @@ -122,11 +111,9 @@ public: background->setElementPrefix("normal"); background->resizeFrame(q->size()); - hoverAnimation->setProperty("startPixmap", background->framePixmap()); background->setElementPrefix("active"); background->resizeFrame(activeRect.size()); - hoverAnimation->setProperty("targetPixmap", background->framePixmap()); } } @@ -138,8 +125,6 @@ public: qreal opacity; QRectF activeRect; - Animation *hoverAnimation; - FocusIndicator *focusIndicator; QString imagePath; QString absImagePath; @@ -189,14 +174,9 @@ PushButton::PushButton(QGraphicsWidget *parent) d->background->setElementPrefix("normal"); - d->hoverAnimation = Animator::create(Animator::PixmapTransitionAnimation); - d->hoverAnimation->setTargetWidget(this); - KPushButton *native = new KPushButton; connect(native, SIGNAL(pressed()), this, SIGNAL(pressed())); - connect(native, SIGNAL(pressed()), this, SLOT(pressedChanged())); connect(native, SIGNAL(released()), this, SIGNAL(released())); - connect(native, SIGNAL(released()), this, SLOT(pressedChanged())); connect(native, SIGNAL(clicked()), this, SIGNAL(clicked())); connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); setWidget(native); @@ -378,17 +358,7 @@ void PushButton::paint(QPainter *painter, painter->drawPixmap(0, 0, bufferPixmap); } - //if is under mouse draw the animated glow overlay - if (!nativeWidget()->isDown() && !nativeWidget()->isChecked() && isEnabled() && acceptHoverEvents() && d->background->hasElementPrefix("active")) { - if (d->hoverAnimation->state() == QAbstractAnimation::Running && !isUnderMouse() && !nativeWidget()->isDefault()) { - d->background->setElementPrefix("active"); - d->background->paintFrame(painter, d->activeRect.topLeft()); - } else { - painter->drawPixmap( - d->activeRect.topLeft(), - d->hoverAnimation->property("currentPixmap").value()); - } - } else if (isEnabled()) { + if (isEnabled()) { d->background->paintFrame(painter); } @@ -473,15 +443,9 @@ void PushButton::hoverEnterEvent(QGraphicsSceneHoverEvent *event) return; } - d->hoverAnimation->setProperty("duration", 75); - d->background->setElementPrefix("normal"); - d->hoverAnimation->setProperty("startPixmap", d->background->framePixmap()); d->background->setElementPrefix("active"); - d->hoverAnimation->setProperty("targetPixmap", d->background->framePixmap()); - - d->hoverAnimation->start(); QGraphicsProxyWidget::hoverEnterEvent(event); } @@ -498,15 +462,9 @@ void PushButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) return; } - d->hoverAnimation->setProperty("duration", 150); - d->background->setElementPrefix("active"); - d->hoverAnimation->setProperty("startPixmap", d->background->framePixmap()); d->background->setElementPrefix("normal"); - d->hoverAnimation->setProperty("targetPixmap", d->background->framePixmap()); - - d->hoverAnimation->start(); QGraphicsProxyWidget::hoverLeaveEvent(event); } diff --git a/plasma/widgets/pushbutton.h b/plasma/widgets/pushbutton.h index 3d1becd3..5aed0587 100644 --- a/plasma/widgets/pushbutton.h +++ b/plasma/widgets/pushbutton.h @@ -229,7 +229,6 @@ protected: private: Q_PRIVATE_SLOT(d, void syncBorders()) Q_PRIVATE_SLOT(d, void setPixmap()) - Q_PRIVATE_SLOT(d, void pressedChanged()) Q_PRIVATE_SLOT(d, void syncToAction()) Q_PRIVATE_SLOT(d, void clearAction()) Q_PRIVATE_SLOT(d, void setPalette()) diff --git a/plasma/widgets/scrollwidget.cpp b/plasma/widgets/scrollwidget.cpp index 633fec7e..8fde339d 100644 --- a/plasma/widgets/scrollwidget.cpp +++ b/plasma/widgets/scrollwidget.cpp @@ -30,8 +30,6 @@ #include #include #include -#include -#include #include @@ -49,7 +47,6 @@ #include #include #include -#include #include @@ -158,17 +155,6 @@ public: layout->setRowSpacing(0, 0); layout->setRowSpacing(1, 0); - flickAnimationX = 0; - flickAnimationY = 0; - fixupAnimation.groupX = 0; - fixupAnimation.startX = 0; - fixupAnimation.endX = 0; - fixupAnimation.groupY = 0; - fixupAnimation.startY = 0; - fixupAnimation.endY = 0; - fixupAnimation.snapX = 0; - fixupAnimation.snapY = 0; - directMoveAnimation = 0; stealEvent = false; hasOvershoot = true; @@ -340,215 +326,6 @@ public: return dist; } - void animateMoveTo(const QPointF &pos) - { - qreal duration = 800; - QPointF start = q->scrollPosition(); - QSizeF threshold = q->viewportGeometry().size(); - QPointF diff = pos - start; - - //reduce if it's within the viewport - if (qAbs(diff.x()) < threshold.width() || - qAbs(diff.y()) < threshold.height()) - duration /= 2; - - fixupAnimation.groupX->stop(); - fixupAnimation.groupY->stop(); - fixupAnimation.snapX->stop(); - fixupAnimation.snapY->stop(); - - directMoveAnimation->setStartValue(start); - directMoveAnimation->setEndValue(pos); - directMoveAnimation->setDuration(duration); - directMoveAnimation->start(); - } - - void flick(QPropertyAnimation *anim, - qreal velocity, - qreal val, - qreal minExtent, - qreal maxExtent, - qreal size) - { - qreal deceleration = 500; - qreal maxDistance = -1; - qreal target = 0; - // -ve velocity means list is moving up - if (velocity > 0) { - if (val < minExtent) - maxDistance = qAbs(minExtent - val + (hasOvershoot?overShootDistance(velocity,size):0)); - target = minExtent; - deceleration = -deceleration; - } else { - if (val > maxExtent) - maxDistance = qAbs(maxExtent - val) + (hasOvershoot?overShootDistance(velocity,size):0); - target = maxExtent; - } - if (maxDistance > 0) { - qreal v = velocity; - if (MaxVelocity != -1 && MaxVelocity < qAbs(v)) { - if (v < 0) - v = -MaxVelocity; - else - v = MaxVelocity; - } - qreal duration = qAbs(v / deceleration); - qreal diffY = v * duration + (0.5 * deceleration * duration * duration); - qreal startY = val; - - qreal endY = startY + diffY; - - if (velocity > 0) { - if (endY > target) - endY = startY + maxDistance; - } else { - if (endY < target) - endY = startY - maxDistance; - } - duration = qAbs((endY-startY)/ (-v/2)); - - if (hasYProperty) { - startY = -startY; - endY = -endY; - } - - -#if DEBUG - qDebug()<<"XXX velocity = "<setEasingCurve(QEasingCurve::OutCirc); - flickAnimationY->setEasingCurve(QEasingCurve::OutCirc); - - - fixupAnimation.groupX = new QSequentialAnimationGroup(widget.data()); - fixupAnimation.groupY = new QSequentialAnimationGroup(widget.data()); - fixupAnimation.startX = new QPropertyAnimation(widget.data(), - xProp.toLatin1(), widget.data()); - fixupAnimation.startY = new QPropertyAnimation(widget.data(), - yProp.toLatin1(), widget.data()); - fixupAnimation.endX = new QPropertyAnimation(widget.data(), - xProp.toLatin1(), widget.data()); - fixupAnimation.endY = new QPropertyAnimation(widget.data(), - yProp.toLatin1(), widget.data()); - fixupAnimation.groupX->addAnimation( - fixupAnimation.startX); - fixupAnimation.groupY->addAnimation( - fixupAnimation.startY); - fixupAnimation.groupX->addAnimation( - fixupAnimation.endX); - fixupAnimation.groupY->addAnimation( - fixupAnimation.endY); - - fixupAnimation.startX->setEasingCurve(QEasingCurve::InQuad); - fixupAnimation.endX->setEasingCurve(QEasingCurve::OutQuint); - fixupAnimation.startY->setEasingCurve(QEasingCurve::InQuad); - fixupAnimation.endY->setEasingCurve(QEasingCurve::OutQuint); - - fixupAnimation.snapX = new QPropertyAnimation(widget.data(), - xProp.toLatin1(), widget.data()); - fixupAnimation.snapY = new QPropertyAnimation(widget.data(), - yProp.toLatin1(), widget.data()); - fixupAnimation.snapX->setEasingCurve(QEasingCurve::InOutQuad); - fixupAnimation.snapY->setEasingCurve(QEasingCurve::InOutQuad); - - QObject::connect(fixupAnimation.groupX, - SIGNAL(stateChanged(QAbstractAnimation::State, - QAbstractAnimation::State)), - q, SIGNAL(scrollStateChanged(QAbstractAnimation::State, - QAbstractAnimation::State))); - QObject::connect(fixupAnimation.groupY, - SIGNAL(stateChanged(QAbstractAnimation::State, - QAbstractAnimation::State)), - q, SIGNAL(scrollStateChanged(QAbstractAnimation::State, - QAbstractAnimation::State))); - - directMoveAnimation = new QPropertyAnimation(q, - "scrollPosition", - q); - QObject::connect(directMoveAnimation, SIGNAL(finished()), - q, SLOT(fixupX())); - QObject::connect(directMoveAnimation, SIGNAL(finished()), - q, SLOT(fixupY())); - QObject::connect(directMoveAnimation, - SIGNAL(stateChanged(QAbstractAnimation::State, - QAbstractAnimation::State)), - q, SIGNAL(scrollStateChanged(QAbstractAnimation::State, - QAbstractAnimation::State))); - directMoveAnimation->setEasingCurve(QEasingCurve::OutCirc); - } - } - - void deleteFlickAnimations() - { - if (flickAnimationX) - flickAnimationX->stop(); - if (flickAnimationY) - flickAnimationY->stop(); - delete flickAnimationX; - delete flickAnimationY; - delete fixupAnimation.groupX; - delete fixupAnimation.groupY; - delete directMoveAnimation; - delete fixupAnimation.snapX; - delete fixupAnimation.snapY; - } - void setScrollX() { if (horizontalScrollBarPolicy != Qt::ScrollBarAlwaysOff) { @@ -1073,21 +678,6 @@ public: QPointF lastPos; QTime pressTime; QTime lastPosTime; - QPropertyAnimation *flickAnimationX; - QPropertyAnimation *flickAnimationY; - struct { - QAnimationGroup *groupX; - QPropertyAnimation *startX; - QPropertyAnimation *endX; - - QAnimationGroup *groupY; - QPropertyAnimation *startY; - QPropertyAnimation *endY; - - QPropertyAnimation *snapX; - QPropertyAnimation *snapY; - } fixupAnimation; - QPropertyAnimation *directMoveAnimation; QSizeF snapSize; bool stealEvent; bool hasOvershoot; @@ -1126,7 +716,6 @@ ScrollWidget::~ScrollWidget() void ScrollWidget::setWidget(QGraphicsWidget *widget) { if (d->widget && d->widget.data() != widget) { - d->deleteFlickAnimations(); d->widget.data()->removeEventFilter(this); delete d->widget.data(); } @@ -1138,7 +727,6 @@ void ScrollWidget::setWidget(QGraphicsWidget *widget) d->hasOffsetProperty = widget->property("scrollPosition").isValid(); d->hasXProperty = widget->property("scrollPositionX").isValid(); d->hasYProperty = widget->property("scrollPositionY").isValid(); - d->createFlickAnimations(); connect(widget, SIGNAL(xChanged()), this, SLOT(setScrollX())); connect(widget, SIGNAL(yChanged()), this, SLOT(setScrollY())); @@ -1200,7 +788,6 @@ void ScrollWidget::ensureRectVisible(const QRectF &rect) } d->rectToBeVisible = rect; - d->makeRectVisible(); } void ScrollWidget::ensureItemVisible(QGraphicsItem *item) @@ -1379,7 +966,6 @@ void ScrollWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) return; } - d->handleMouseReleaseEvent(event); event->accept(); } @@ -1405,7 +991,6 @@ bool ScrollWidget::eventFilter(QObject *watched, QEvent *event) event->type() == QEvent::Move)) { emit viewportGeometryChanged(viewportGeometry()); } else if (watched == d->widget.data() && event->type() == QEvent::GraphicsSceneResize) { - d->stopAnimations(); d->adjustScrollbarsTimer->start(200); updateGeometry(); @@ -1499,9 +1084,6 @@ bool ScrollWidget::sceneEventFilter(QGraphicsItem *i, QEvent *e) case QEvent::GraphicsSceneMouseMove: d->handleMouseMoveEvent(static_cast(e)); break; - case QEvent::GraphicsSceneMouseRelease: - d->handleMouseReleaseEvent(static_cast(e)); - break; //Multitouch related events, we actually need only TouchUpdate case QEvent::TouchUpdate: { diff --git a/plasma/widgets/scrollwidget.h b/plasma/widgets/scrollwidget.h index 1a6f7370..90a71638 100644 --- a/plasma/widgets/scrollwidget.h +++ b/plasma/widgets/scrollwidget.h @@ -282,11 +282,8 @@ private: Q_PRIVATE_SLOT(d, void verticalScroll(int value)) Q_PRIVATE_SLOT(d, void horizontalScroll(int value)) - Q_PRIVATE_SLOT(d, void makeRectVisible()) Q_PRIVATE_SLOT(d, void makeItemVisible()) Q_PRIVATE_SLOT(d, void adjustScrollbars()) - Q_PRIVATE_SLOT(d, void fixupX()) - Q_PRIVATE_SLOT(d, void fixupY()) Q_PRIVATE_SLOT(d, void setScrollX()) Q_PRIVATE_SLOT(d, void setScrollY()) diff --git a/plasma/widgets/tabbar.cpp b/plasma/widgets/tabbar.cpp index 26bbfe73..96e96f83 100644 --- a/plasma/widgets/tabbar.cpp +++ b/plasma/widgets/tabbar.cpp @@ -33,8 +33,6 @@ #include -#include "animator.h" -#include "animations/animation.h" #include "private/nativetabbar_p.h" #include "private/themedwidgetinterface_p.h" #include "theme.h" @@ -76,8 +74,6 @@ public: tabProxy(0), currentIndex(0), tabWidgetMode(true), - oldPageAnimId(-1), - newPageAnimId(-1), tabBarShown(true) { } @@ -103,10 +99,6 @@ public: QWeakPointer oldPage; QWeakPointer newPage; - int oldPageAnimId; - int newPageAnimId; - Animation *oldPageAnim; - Animation *newPageAnim; QParallelAnimationGroup *animGroup; bool tabBarShown; QWeakPointer firstPositionWidget; @@ -162,7 +154,6 @@ void TabBarPrivate::slidingNewPageCompleted() if (newPage) { tabWidgetLayout->addItem(newPage.data()); } - newPageAnimId = -1; mainLayout->invalidate(); emit q->currentChanged(currentIndex); @@ -171,9 +162,8 @@ void TabBarPrivate::slidingNewPageCompleted() void TabBarPrivate::slidingOldPageCompleted() { - QGraphicsWidget *item = oldPageAnim->targetWidget(); + QGraphicsWidget *item = oldPage.data(); - oldPageAnimId = -1; if (item) { item->hide(); } @@ -249,20 +239,10 @@ TabBar::TabBar(QGraphicsWidget *parent) d->tabBarLayout->setContentsMargins(0,0,0,0); //d->tabBarLayout->setStretchFactor(d->tabProxy, 2); - - d->newPageAnim = Animator::create(Animator::SlideAnimation); - d->oldPageAnim = Animator::create(Animator::SlideAnimation); - d->animGroup = new QParallelAnimationGroup(this); - - d->animGroup->addAnimation(d->newPageAnim); - d->animGroup->addAnimation(d->oldPageAnim); - connect(d->tabProxy->native, SIGNAL(currentChanged(int)), this, SLOT(setCurrentIndex(int))); connect(d->tabProxy->native, SIGNAL(shapeChanged(QTabBar::Shape)), this, SLOT(shapeChanged(QTabBar::Shape))); - connect(d->newPageAnim, SIGNAL(finished()), this, SLOT(slidingNewPageCompleted())); - connect(d->oldPageAnim, SIGNAL(finished()), this, SLOT(slidingOldPageCompleted())); d->initTheming(); } @@ -396,27 +376,11 @@ void TabBar::setCurrentIndex(int index) if (index > d->currentIndex) { d->newPage.data()->setPos(d->oldPage.data()->geometry().topRight()); - d->newPageAnim->setProperty("movementDirection", Animation::MoveLeft); - d->newPageAnim->setProperty("distancePointF", QPointF(d->oldPage.data()->size().width(), 0)); - d->newPageAnim->setTargetWidget(d->newPage.data()); - - d->oldPageAnim->setProperty("movementDirection", Animation::MoveLeft); - d->oldPageAnim->setProperty("distancePointF", QPointF(beforeCurrentGeom.width(), 0)); - d->oldPageAnim->setTargetWidget(d->oldPage.data()); - - d->animGroup->start(); + d->slidingNewPageCompleted(); + d->slidingOldPageCompleted(); } else { d->newPage.data()->setPos(beforeCurrentGeom.topLeft()); - d->newPageAnim->setProperty("movementDirection", Animation::MoveRight); - d->newPageAnim->setProperty("distancePointF", QPointF(d->oldPage.data()->size().width(), 0)); - d->newPageAnim->setTargetWidget(d->newPage.data()); - - d->oldPageAnim->setProperty("movementDirection", Animation::MoveRight); - d->oldPageAnim->setProperty("distancePointF", - QPointF(d->oldPage.data()->size().width(), 0)); - d->oldPageAnim->setTargetWidget(d->oldPage.data()); - - d->animGroup->start(); + d->slidingOldPageCompleted(); } } else if (d->newPage) { d->tabWidgetLayout->addItem(d->newPage.data()); @@ -437,9 +401,6 @@ void TabBar::removeTab(int index) return; } - d->newPageAnim->stop(); - d->oldPageAnim->stop(); - int oldCurrentIndex = d->tabProxy->native->currentIndex(); d->tabProxy->native->removeTab(index); diff --git a/plasma/widgets/tabbar.h b/plasma/widgets/tabbar.h index d9633420..c7326039 100644 --- a/plasma/widgets/tabbar.h +++ b/plasma/widgets/tabbar.h @@ -278,8 +278,8 @@ private: friend class TabBarPrivate; - Q_PRIVATE_SLOT(d, void slidingNewPageCompleted()) - Q_PRIVATE_SLOT(d, void slidingOldPageCompleted()) + void slidingNewPageCompleted(); + void slidingOldPageCompleted(); Q_PRIVATE_SLOT(d, void shapeChanged(const QTabBar::Shape shape)) Q_PRIVATE_SLOT(d, void setPalette()) }; diff --git a/plasma/widgets/toolbutton.cpp b/plasma/widgets/toolbutton.cpp index 93f158a7..a0ede176 100644 --- a/plasma/widgets/toolbutton.cpp +++ b/plasma/widgets/toolbutton.cpp @@ -30,7 +30,6 @@ #include #include -#include "animator.h" #include "framesvg.h" #include "paintutils.h" #include "private/actionwidgetinterface_p.h" diff --git a/plasma/widgets/videowidget.cpp b/plasma/widgets/videowidget.cpp index 42e4d0df..a91ef186 100644 --- a/plasma/widgets/videowidget.cpp +++ b/plasma/widgets/videowidget.cpp @@ -40,7 +40,6 @@ #include #include -#include #include #include #include @@ -55,7 +54,6 @@ public: : q(video), ticking(false), forceControlsVisible(false), - animation(0), hideTimer(0), shownControls(VideoWidget::NoControls), controlsWidget(0), @@ -100,7 +98,6 @@ public: bool forceControlsVisible; //control widgets - Plasma::Animation *animation; QTimer *hideTimer; VideoWidget::Controls shownControls; Plasma::Frame *controlsWidget; @@ -198,17 +195,6 @@ void VideoWidgetPrivate::animateControlWidget(bool show) //clip only when animating q->setFlags(q->flags()|QGraphicsItem::ItemClipsChildrenToShape); - - if (!animation) { - animation = Plasma::Animator::create(Plasma::Animator::SlideAnimation, q); - animation->setTargetWidget(controlsWidget); - animation->setProperty("movementDirection", Animation::MoveDown); - q->connect(animation, SIGNAL(finished()), q, SLOT(slidingCompleted())); - } - - animation->setProperty("distance", distance); - animation->setProperty("direction", show? QAbstractAnimation::Forward : QAbstractAnimation::Backward); - animation->start(); } void VideoWidgetPrivate::hideControlWidget() diff --git a/plasma/widgets/webview.cpp b/plasma/widgets/webview.cpp index c761d408..7a6aac06 100644 --- a/plasma/widgets/webview.cpp +++ b/plasma/widgets/webview.cpp @@ -34,7 +34,6 @@ #endif #include -#include "animator.h" #include "plasma.h" #include "widgets/webview.h" #include "widgets/scrollwidget.h"