From 2f02dbb6020583c8f50ee618477130d6ce4abfdd Mon Sep 17 00:00:00 2001 From: Igor Trindade Oliveira Date: Fri, 23 Oct 2009 02:45:55 +0000 Subject: [PATCH] create properties to rotatestackedanimation svn path=/trunk/KDE/kdelibs/; revision=1039220 --- animations/rotationstacked.cpp | 26 ++++++++++++++------------ animations/rotationstacked.h | 17 +++++++++++++---- animations/stackedlayout.cpp | 2 +- animations/stackedlayout.h | 2 +- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/animations/rotationstacked.cpp b/animations/rotationstacked.cpp index 284b83a29..99bf190c2 100644 --- a/animations/rotationstacked.cpp +++ b/animations/rotationstacked.cpp @@ -1,5 +1,5 @@ /***********************************************************************/ -/* stackedlayout.h */ +/* rotationstacked.h */ /* */ /* Copyright(C) 2009 Igor Trindade Oliveira */ /* */ @@ -35,7 +35,7 @@ class RotationStackedAnimationPrivate { AbstractAnimation::Reference reference; - QPair animObjects; + QGraphicsWidget *backWidget; StackedLayout *sLayout; }; @@ -65,12 +65,19 @@ AbstractAnimation::Reference RotationStackedAnimation::reference() return d->reference; } -void RotationStackedAnimation::setWidgetsToAnimate(QGraphicsWidget *front, QGraphicsWidget *back) +QGraphicsWidget *RotationStackedAnimation::backWidget() { - d->animObjects = qMakePair(front, back); + return d->backWidget; +} - d->sLayout->addWidget(front); - d->sLayout->addWidget(back); +void RotationStackedAnimation::setBackWidget(QGraphicsWidget *backWidget) +{ + d->backWidget = backWidget; + + if(widgetToAnimate()) { + d->sLayout->addWidget(widgetToAnimate()); + d->sLayout->addWidget(backWidget); + } } QGraphicsLayoutItem *RotationStackedAnimation::layout() @@ -78,16 +85,11 @@ QGraphicsLayoutItem *RotationStackedAnimation::layout() return d->sLayout; } -QPair RotationStackedAnimation::widgetsToAnimate() -{ - return d->animObjects; -} - QAbstractAnimation *RotationStackedAnimation::render(QObject *parent) { Q_UNUSED(parent); - QPair widgets = widgetsToAnimate(); + QPair widgets = qMakePair(widgetToAnimate(), d->backWidget); QSequentialAnimationGroup *groupAnim = new QSequentialAnimationGroup(parent); diff --git a/animations/rotationstacked.h b/animations/rotationstacked.h index b6ff724e8..1d6ac7bf7 100644 --- a/animations/rotationstacked.h +++ b/animations/rotationstacked.h @@ -1,5 +1,5 @@ #//////////////////////////////////////////////////////////////////////// -// rotation.cpp // +// rotationstacked.h // // // // Copyright(C) 2009 Igor Trindade Oliveira // // // @@ -25,14 +25,24 @@ #include #include +#include + namespace Plasma { class RotationStackedAnimationPrivate; +/* TODO: + * create a parent class for rotations + */ + class RotationStackedAnimation : public Animation { Q_OBJECT + Q_PROPERTY(QGraphicsLayoutItem* layout READ layout) + Q_PROPERTY(Reference reference READ reference WRITE setReference) + Q_PROPERTY(QGraphicsWidget* backWidget READ backWidget WRITE setBackWidget) + public: RotationStackedAnimation(QObject *parent = 0); ~RotationStackedAnimation(); @@ -44,9 +54,8 @@ class RotationStackedAnimation : public Animation QGraphicsLayoutItem *layout(); - void setWidgetsToAnimate(QGraphicsWidget *front, QGraphicsWidget *back); - - QPair widgetsToAnimate(); + QGraphicsWidget *backWidget(); + void setBackWidget(QGraphicsWidget *backWidget); public Q_SLOTS: void rotateBackWidget(); diff --git a/animations/stackedlayout.cpp b/animations/stackedlayout.cpp index fa8bc040c..cf6979c4a 100644 --- a/animations/stackedlayout.cpp +++ b/animations/stackedlayout.cpp @@ -1,5 +1,5 @@ /***********************************************************************/ -/* stackedlayout.h */ +/* stackedlayout.c */ /* */ /* Copyright(C) 2009 Igor Trindade Oliveira */ /* */ diff --git a/animations/stackedlayout.h b/animations/stackedlayout.h index 4d14b16f1..4e58b08dc 100644 --- a/animations/stackedlayout.h +++ b/animations/stackedlayout.h @@ -1,5 +1,5 @@ //////////////////////////////////////////////////////////////////////// -// rotation.cpp // +// stackedlayout.h // // // // Copyright(C) 2009 Igor Trindade Oliveira // // //