#include "iconview.h"
#include <Plasma/PaintUtils>
+#include <Plasma/Animator>
#include <Plasma/Svg>
#include <QPainter>
m_hideActionOverlayIconTimer->setInterval(500);
m_hideActionOverlayIconTimer->setSingleShot(true);
+ fadeIn = Plasma::Animator::create(Plasma::Animator::FadeAnimation, this);
+ fadeIn->setProperty("startOpacity", 0);
+ fadeIn->setProperty("targetOpacity", 1);
+ fadeIn->setTargetWidget(this);
+
+ fadeOut = Plasma::Animator::create(Plasma::Animator::FadeAnimation, this);
+ fadeOut->setProperty("startOpacity", 1);
+ fadeOut->setProperty("targetOpacity", 0);
+ fadeOut->setTargetWidget(this);
+ connect(fadeOut, SIGNAL(finished()), SLOT(close()));
+
hide();
}
show();
if (m_hoverIndex != index) {
m_toggleButton->update();
+ fadeOut->stop();
+ fadeIn->start();
}
m_hoverIndex = index;
IconView *iview = qobject_cast<IconView*>(view);
// allow the animation to restart after hiding the ActionOverlayIcon even if m_hoverIndex didn't change
m_hoverIndex = QPersistentModelIndex();
- if (isVisible()) {
- close();
+ if (isVisible() && (fadeOut->state() != QAbstractAnimation::Running)) {
+ fadeIn->stop();
+ fadeOut->start();
}
}
#include "abstractitemview.h"
+#include <Plasma/Animation>
+
#include <QTimer>
#include <QGraphicsWidget>
#include <QtCore/qabstractitemmodel.h>
ActionIcon *m_openButton;
QPersistentModelIndex m_hoverIndex;
QTimer *m_hideActionOverlayIconTimer;
+ Plasma::Animation *fadeIn;
+ Plasma::Animation *fadeOut;
bool m_showFolderButton;
bool m_showSelectionButton;
QGraphicsGridLayout * m_layout;
#include <Plasma/Containment>
+#include <Plasma/Animator>
#include "desktoplayout.h"
connect(this, SIGNAL(availableScreenRegionChanged()), m_delayedUpdateTimer, SLOT(start()));
connect(m_delayedUpdateTimer, SIGNAL(timeout()), this, SLOT(update()));
+ mapAnimation(Plasma::Animator::AppearAnimation, Plasma::Animator::ZoomAnimation);
+ mapAnimation(Plasma::Animator::DisappearAnimation, Plasma::Animator::ZoomAnimation);
kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "DesktopCorona init end" << "(line:" << __LINE__ << ")";
}
#include <KDebug>
#include <KIconLoader>
+#include <Plasma/Animation>
#include <Plasma/Applet>
#include <Plasma/Containment>
#include <Plasma/FrameSvg>
m_toolBacker->setOpacity(0);
m_toolBacker->show();
+ Plasma::Animation *fadeAnim = Plasma::Animator::create(Plasma::Animator::FadeAnimation, m_toolBacker);
+ fadeAnim->setTargetWidget(m_toolBacker);
+ fadeAnim->setProperty("startOpacity", 0);
+ fadeAnim->setProperty("targetOpacity", 1);
+ fadeAnim->start(QAbstractAnimation::DeleteWhenStopped);
highlight(true);
setFocus();
}
void DesktopToolBox::hideToolBox()
{
if (m_toolBacker) {
- hideToolBacker();
+ Plasma::Animation *fadeAnim = Plasma::Animator::create(Plasma::Animator::FadeAnimation, m_toolBacker);
+ connect(fadeAnim, SIGNAL(finished()), this, SLOT(hideToolBacker()));
+ fadeAnim->setTargetWidget(m_toolBacker);
+ fadeAnim->setProperty("startOpacity", 1);
+ fadeAnim->setProperty("targetOpacity", 0);
+ fadeAnim->start(QAbstractAnimation::DeleteWhenStopped);
}
highlight(false);
}
m_hovering = highlighting;
+
+ QPropertyAnimation *anim = m_anim.data();
+ if (m_hovering) {
+ if (anim) {
+ anim->stop();
+ m_anim.clear();
+ }
+ anim = new QPropertyAnimation(this, "highlight", this);
+ m_anim = anim;
+ }
+
+ if (anim->state() != QAbstractAnimation::Stopped) {
+ anim->stop();
+ }
+
+ anim->setDuration(250);
+ anim->setStartValue(0);
+ anim->setEndValue(1);
+
+ if (m_hovering) {
+ anim->start();
+ } else {
+ anim->setDirection(QAbstractAnimation::Backward);
+ anim->start(QAbstractAnimation::DeleteWhenStopped);
+
+ }
}
void DesktopToolBox::setHighlight(qreal progress)
#include <KIcon>
+#include <Plasma/Animator>
#include <Plasma/IconWidget>
#include "internaltoolbox.h"
#include <KIcon>
+#include <Plasma/Animator>
+
#include "internaltoolbox.h"
class Widget;
#include <plasma/theme.h>
#include <plasma/framesvg.h>
+#include <plasma/animator.h>
#include <plasma/paintutils.h>
#include <Plasma/ComboBox>
#include <kwebwallet.h>
#include <KStandardDirs>
+#include <Plasma/Animation>
#include <Plasma/IconWidget>
#include <Plasma/WebView>
#include <Plasma/TreeView>
m_removeBookmarkAction = new QAction(KIcon("list-remove"), QString(), this);
m_organizeBookmarks = addTool("bookmarks-organize", m_statusbarLayout);
+ m_bookmarksViewAnimation = Plasma::Animator::create(Plasma::Animator::FadeAnimation, this);
+ m_bookmarksViewAnimation->setTargetWidget(m_bookmarksView);
+ connect(m_bookmarksViewAnimation, SIGNAL(finished()), this, SLOT(bookmarksAnimationFinished()));
+
m_stop = addTool("process-stop", m_statusbarLayout);
QGraphicsWidget *spacer = new QGraphicsWidget(this);
void WebBrowser::bookmarksToggle()
{
if (m_bookmarksView->isVisible()) {
- bookmarksAnimationFinished();
+ m_bookmarksViewAnimation->setProperty("startOpacity", 1);
+ m_bookmarksViewAnimation->setProperty("targetOpacity", 0);
+ m_bookmarksViewAnimation->start();
} else {
m_bookmarksView->show();
m_bookmarksView->setOpacity(0);
updateOverlaysGeometry();
- bookmarksAnimationFinished();
+ m_bookmarksViewAnimation->setProperty("startOpacity", 0);
+ m_bookmarksViewAnimation->setProperty("targetOpacity", 1);
+ m_bookmarksViewAnimation->start();
}
}
KBookmarkManager *m_bookmarkManager;
QStandardItemModel *m_bookmarkModel;
Plasma::TreeView *m_bookmarksView;
+ Plasma::Animation *m_bookmarksViewAnimation;
QTimer *m_autoRefreshTimer;
bool m_autoRefresh;
#include "desktop.h"
#include <QtGui/qgraphicssceneevent.h>
+#include <QtGui/qgraphicssceneevent.h>
#include <KDebug>
#include <KMenu>
#include <QParallelAnimationGroup>
#include <QTimer>
+
#include <KIconLoader>
+#include <plasma/animations/animation.h>
#include <plasma/applet.h>
#include <plasma/svg.h>
#include <plasma/theme.h>
setZValue(10000);
+
+ m_pulse =
+ Plasma::Animator::create(Plasma::Animator::PulseAnimation);
+ m_pulse->setTargetWidget(applet);
+
m_maximizeButtonRect = m_configureButtonRect = m_closeButtonRect = QRect(0, 0, KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium);
m_icons = new Plasma::Svg(this);
AppletTitleBar::~AppletTitleBar()
{
+ delete m_pulse;
+ delete m_animations.data();
}
void AppletTitleBar::setButtonsVisible(bool visible)
}
m_buttonsVisible = visible;
+
+ if (visible) {
+ if (!m_animations) {
+ initAnimations();
+
+ m_animations.data()->start();
+ m_animations.data()->setCurrentTime(0);
+ } else {
+ QParallelAnimationGroup *group = m_animations.data();
+
+ group->stop();
+ group->setCurrentTime(0);
+ group->setDirection(QAbstractAnimation::Forward);
+
+ group->start();
+ }
+ } else {
+ initAnimations();
+ QParallelAnimationGroup *group = m_animations.data();
+ group->setDirection(QAbstractAnimation::Backward);
+ group->start(QAbstractAnimation::DeleteWhenStopped);
+ }
}
bool AppletTitleBar::buttonsVisible() const
return m_active;
}
+void AppletTitleBar::initAnimations()
+{
+ if (m_animations) {
+ return;
+ }
+
+ m_animations = new QParallelAnimationGroup(this);
+ QParallelAnimationGroup *group = m_animations.data();
+
+ if (m_applet->hasValidAssociatedApplication()) {
+ Plasma::Animation *maximizeAnim =
+ Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation);
+ maximizeAnim->setProperty("targetPixmap", m_icons->pixmap("maximize"));
+ maximizeAnim->setTargetWidget(this);
+ group->addAnimation(maximizeAnim);
+ }
+
+ Plasma::Animation *confAnim =
+ Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation);
+ Plasma::Animation *closeAnim =
+ Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation);
+ confAnim->setProperty("targetPixmap", m_icons->pixmap("configure"));
+ confAnim->setTargetWidget(this);
+
+ closeAnim->setProperty("targetPixmap", m_icons->pixmap("close"));
+ closeAnim->setTargetWidget(this);
+ group->addAnimation(confAnim);
+ group->addAnimation(closeAnim);
+}
+
void AppletTitleBar::syncMargins()
{
const int extraMargin = 2;
{
if (m_pressedButton == MaximizeButton && m_maximizeButtonRect.contains(event->pos())) {
if (m_applet->hasValidAssociatedApplication()) {
+ m_pulse->start();
m_applet->runAssociatedApplication();
}
} else if (m_pressedButton == ConfigureButton && m_configureButtonRect.contains(event->pos())) {
QParallelAnimationGroup *group = m_animations.data();
int i = 0;
- // TODO: revisit
+
if (m_applet->hasValidAssociatedApplication()) {
if (group) {
if (group->state() == QAbstractAnimation::Running) {
#include <QParallelAnimationGroup>
#include <QtCore/qsharedpointer.h>
+#include <plasma/animations/animation.h>
+
namespace Plasma
{
class Applet;
Plasma::Svg *m_separator;
Plasma::FrameSvg *m_background;
+ Plasma::Animation *m_pulse;
+
qreal m_savedAppletTopMargin;
bool m_underMouse;
bool m_buttonsVisible;
#include <KLocale>
#include <KRun>
+#include <Plasma/Animation>
#include <Plasma/Applet>
#include <Plasma/Extender>
#include <Plasma/ExtenderItem>
void registerSimpleAppletMetaTypes(QScriptEngine *engine);
KSharedPtr<UiLoader> SimpleJavaScriptApplet::s_widgetLoader;
+QHash<QString, Plasma::Animator::Animation> SimpleJavaScriptApplet::s_animationDefs;
SimpleJavaScriptApplet::SimpleJavaScriptApplet(QObject *parent, const QVariantList &args)
: AbstractJsAppletScript(parent),
return m_env->include(path);
}
+void SimpleJavaScriptApplet::populateAnimationsHash()
+{
+ if (s_animationDefs.isEmpty()) {
+ s_animationDefs.insert("fade", Plasma::Animator::FadeAnimation);
+ s_animationDefs.insert("geometry", Plasma::Animator::GeometryAnimation);
+ s_animationDefs.insert("grow", Plasma::Animator::GrowAnimation);
+ s_animationDefs.insert("pulse", Plasma::Animator::PulseAnimation);
+ s_animationDefs.insert("rotate", Plasma::Animator::RotationAnimation);
+ s_animationDefs.insert("rotateStacked", Plasma::Animator::RotationStackedAnimation);
+ s_animationDefs.insert("slide", Plasma::Animator::SlideAnimation);
+ s_animationDefs.insert("zoom", Plasma::Animator::ZoomAnimation);
+ }
+}
+
bool SimpleJavaScriptApplet::init()
{
connect(applet(), SIGNAL(extenderItemRestored(Plasma::ExtenderItem*)),
{
QScriptValue global = m_engine->globalObject();
+ // Bindings for animations
+ global.setProperty("animation", m_engine->newFunction(SimpleJavaScriptApplet::animation));
+ global.setProperty("AnimationGroup", m_engine->newFunction(SimpleJavaScriptApplet::animationGroup));
+ global.setProperty("ParallelAnimationGroup", m_engine->newFunction(SimpleJavaScriptApplet::parallelAnimationGroup));
+
QScriptValue v = m_engine->newVariant(QVariant::fromValue(*applet()->package()));
global.setProperty("__plasma_package", v,
QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
return engine->newQObject(service, QScriptEngine::AutoOwnership);
}
+QScriptValue SimpleJavaScriptApplet::animation(QScriptContext *context, QScriptEngine *engine)
+{
+ if (context->argumentCount() != 1) {
+ return context->throwError(i18n("animation() takes one argument"));
+ }
+
+ populateAnimationsHash();
+ QString name = context->argument(0).toString();
+ QString animName = name.toLower();
+ const bool isPause = animName == "pause";
+ const bool isProperty = animName == "property";
+
+ bool parentIsApplet = false;
+ QGraphicsWidget *parent = extractParent(context, engine, 0, &parentIsApplet);
+ QAbstractAnimation *anim = 0;
+ Plasma::Animation *plasmaAnim = 0;
+ if (isPause) {
+ anim = new QPauseAnimation(parent);
+ } else if (isProperty) {
+ anim = new QPropertyAnimation(parent);
+ } else if (s_animationDefs.contains(animName)) {
+ plasmaAnim = Plasma::Animator::create(s_animationDefs.value(animName), parent);
+ } else {
+ SimpleJavaScriptApplet *jsApplet = qobject_cast<SimpleJavaScriptApplet *>(engine->parent());
+ if (jsApplet) {
+ //kDebug() << "trying to load it from the package";
+ plasmaAnim = jsApplet->loadAnimationFromPackage(name, parent);
+ }
+
+ if (!plasmaAnim) {
+ plasmaAnim = Plasma::Animator::create(animName, parent);
+ }
+ }
+
+ if (plasmaAnim) {
+ if (!parentIsApplet) {
+ plasmaAnim->setTargetWidget(parent);
+ }
+ anim = plasmaAnim;
+ }
+
+ if (anim) {
+ QScriptValue value = engine->newQObject(anim);
+ ScriptEnv::registerEnums(value, *anim->metaObject());
+ return value;
+ }
+
+ context->throwError(i18n("%1 is not a known animation type", animName));
+
+ ScriptEnv *env = ScriptEnv::findScriptEnv(engine);
+ if (env) {
+ env->checkForErrors(false);
+ }
+ return engine->undefinedValue();
+}
+
+QScriptValue SimpleJavaScriptApplet::animationGroup(QScriptContext *context, QScriptEngine *engine)
+{
+ QGraphicsWidget *parent = extractParent(context, engine);
+ SequentialAnimationGroup *group = new SequentialAnimationGroup(parent);
+ return engine->newQObject(group);
+}
+
+QScriptValue SimpleJavaScriptApplet::parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine)
+{
+ QGraphicsWidget *parent = extractParent(context, engine);
+ ParallelAnimationGroup *group = new ParallelAnimationGroup(parent);
+ return engine->newQObject(group);
+}
+
QScriptValue SimpleJavaScriptApplet::loadui(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) {
#include <QScriptValue>
+#include <Plasma/Animator>
#include <Plasma/DataEngine>
#include "simplebindings/uiloader.h"
static void populateAnimationsHash();
static QString findSvg(QScriptContext *context, QScriptEngine *engine, const QString &file);
+ static QScriptValue animation(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue animationGroup(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine);
static QScriptValue jsi18n(QScriptContext *context, QScriptEngine *engine);
static QScriptValue jsi18nc(QScriptContext *context, QScriptEngine *engine);
static QScriptValue jsi18np(QScriptContext *context, QScriptEngine *engine);
private:
static KSharedPtr<UiLoader> s_widgetLoader;
+ static QHash<QString, Plasma::Animator::Animation> s_animationDefs;
ScriptEnv *m_env;
QScriptEngine *m_engine;
QScriptValue m_self;
#include <QScriptEngine>
#include <Plasma/Applet>
+#include <Plasma/Animation>
#include <Plasma/Extender>
#include <Plasma/VideoWidget>
Q_DECLARE_METATYPE(QGraphicsWidget*)
Q_DECLARE_METATYPE(QGraphicsLayout*)
+Q_DECLARE_METATYPE(Plasma::Animation*)
Q_DECLARE_METATYPE(Plasma::Applet*)
Q_DECLARE_METATYPE(Plasma::Extender*)
Q_DECLARE_METATYPE(Plasma::VideoWidget::Controls)
}
}
+typedef Plasma::Animation* AnimationPtr;
+QScriptValue qScriptValueFromAnimation(QScriptEngine *engine, const AnimationPtr &anim)
+{
+ return engine->newQObject(const_cast<Plasma::Animation *>(anim), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
+}
+
+void abstractAnimationFromQScriptValue(const QScriptValue &scriptValue, AnimationPtr &anim)
+{
+ QObject *obj = scriptValue.toQObject();
+ anim = static_cast<Plasma::Animation *>(obj);
+}
+
typedef QGraphicsWidget * QGraphicsWidgetPtr;
QScriptValue qScriptValueFromQGraphicsWidget(QScriptEngine *engine, const QGraphicsWidgetPtr &anim)
{
qScriptRegisterMetaType<Plasma::Svg*>(engine, qScriptValueFromSvg, svgFromQScriptValue);
qScriptRegisterSequenceMetaType<QList<double> >(engine);
+ qScriptRegisterMetaType<Plasma::Animation *>(engine, qScriptValueFromAnimation, abstractAnimationFromQScriptValue);
qScriptRegisterMetaType<Plasma::Extender *>(engine, qScriptValueFromExtender, extenderFromQScriptValue);
qScriptRegisterMetaType<Plasma::VideoWidget::Controls>(engine, qScriptValueFromControls, controlsFromScriptValue, QScriptValue());
qScriptRegisterMetaType<Qt::MouseButton>(engine, qScriptValueFromMouseButton, mouseButtonFromScriptValue);