aboutsummaryrefslogtreecommitdiff
path: root/src/corelib/animation/widget/mwidgetmoveanimation.cpp
diff options
context:
space:
mode:
authorJörgen Scheibengruber <jorgen.scheibengruber@nokia.com>2010-06-02 17:27:26 +0300
committerJörgen Scheibengruber <jorgen.scheibengruber@nokia.com>2010-06-02 17:27:26 +0300
commit74cd4f40bd629ab2782f518234ebf3bceecd0f22 (patch)
tree523d11e3c998d7efa7e2c5e0123855413b14fb35 /src/corelib/animation/widget/mwidgetmoveanimation.cpp
parent86322ab7fa72e32f8830b7cb23dfb5c1de988f58 (diff)
parentdd9a00977c21f19291b5ff2f87a39e1f5a8df77d (diff)
Merge branch 'master' of gitorious.org:maemo-6-ui-framework/libdui0.20.14-1
Diffstat (limited to 'src/corelib/animation/widget/mwidgetmoveanimation.cpp')
-rw-r--r--src/corelib/animation/widget/mwidgetmoveanimation.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/corelib/animation/widget/mwidgetmoveanimation.cpp b/src/corelib/animation/widget/mwidgetmoveanimation.cpp
new file mode 100644
index 00000000..25a73db4
--- /dev/null
+++ b/src/corelib/animation/widget/mwidgetmoveanimation.cpp
@@ -0,0 +1,92 @@
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of libmeegotouch.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+#include <QPauseAnimation>
+#include <QPropertyAnimation>
+#include <QSequentialAnimationGroup>
+
+#include "mwidgetmoveanimation.h"
+#include "mwidgetmoveanimation_p.h"
+#include "mwidgetcontroller.h"
+
+void MWidgetMoveAnimationPrivate::init()
+{
+ Q_Q(MWidgetMoveAnimation);
+
+ widget = 0;
+
+ QSequentialAnimationGroup *delayedAnimation = new QSequentialAnimationGroup;
+
+ delay = new QPauseAnimation;
+ delay->setDuration(q->style()->delay());
+ positionAnimation = new QPropertyAnimation;
+ positionAnimation->setPropertyName("pos");
+ positionAnimation->setDuration(q->style()->duration());
+ positionAnimation->setEasingCurve(q->style()->easingCurve());
+
+ delayedAnimation->addAnimation(delay);
+ delayedAnimation->addAnimation(positionAnimation);
+ q->addAnimation(delayedAnimation);
+}
+
+MWidgetMoveAnimation::MWidgetMoveAnimation(QObject *parent) :
+ MParallelAnimationGroup(new MWidgetMoveAnimationPrivate, parent)
+{
+ Q_D(MWidgetMoveAnimation);
+
+ d->init();
+}
+
+MWidgetMoveAnimation::MWidgetMoveAnimation(MWidgetMoveAnimationPrivate *dd, QObject *parent) :
+ MParallelAnimationGroup(dd, parent)
+{
+ Q_D(MWidgetMoveAnimation);
+
+ d->init();
+}
+
+void MWidgetMoveAnimation::setWidget(MWidgetController *widget)
+{
+ Q_D(MWidgetMoveAnimation);
+
+ d->widget = widget;
+}
+
+void MWidgetMoveAnimation::setFinalPos(const QPointF &pos)
+{
+ Q_D(MWidgetMoveAnimation);
+
+ d->finalPos = pos;
+}
+
+void MWidgetMoveAnimation::updateState(QAbstractAnimation::State newState,
+ QAbstractAnimation::State oldState)
+{
+ Q_D(MWidgetMoveAnimation);
+
+ if (oldState == QAbstractAnimation::Stopped &&
+ newState == QAbstractAnimation::Running)
+ {
+ d->positionAnimation->setTargetObject(d->widget);
+ d->positionAnimation->setStartValue(d->widget->pos());
+ d->positionAnimation->setEndValue(d->finalPos);
+ }
+}
+
+#include "moc_mwidgetmoveanimation.cpp"