API cleanups
svn path=/trunk/KDE/kdelibs/; revision=1038232
This commit is contained in:
parent
b29d0a79aa
commit
8b9830dc2b
@ -37,14 +37,14 @@ AbstractAnimation::~AbstractAnimation()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractAnimation::setWidget(QGraphicsWidget* receiver)
|
void AbstractAnimation::setAnimatedWidget(QGraphicsWidget* receiver)
|
||||||
{
|
{
|
||||||
d->animObject = receiver;
|
d->animObject = receiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsWidget* AbstractAnimation::animatedObject()
|
QGraphicsWidget* AbstractAnimation::animatedWidget()
|
||||||
{
|
{
|
||||||
return d->animObject;
|
return d->animObject.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractAnimation::setEasingCurveType(QEasingCurve::Type easingCurve)
|
void AbstractAnimation::setEasingCurveType(QEasingCurve::Type easingCurve)
|
||||||
@ -57,32 +57,32 @@ QEasingCurve::Type AbstractAnimation::easingCurveType() const
|
|||||||
return d->easingCurve;
|
return d->easingCurve;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractAnimation::setAnimationDirection(AnimationDirection animationDirection)
|
void AbstractAnimation::setDirection(AnimationDirection direction)
|
||||||
{
|
{
|
||||||
d->animDirection = animationDirection;
|
d->animDirection = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationDirection AbstractAnimation::animationDirection() const
|
AnimationDirection AbstractAnimation::direction() const
|
||||||
{
|
{
|
||||||
return d->animDirection;
|
return d->animDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractAnimation::setAnimationDistance(qreal animationDistance)
|
void AbstractAnimation::setDistance(qreal distance)
|
||||||
{
|
{
|
||||||
d->animDistance = animationDistance;
|
d->animDistance = distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal AbstractAnimation::animationDistance() const
|
qreal AbstractAnimation::distance() const
|
||||||
{
|
{
|
||||||
return d->animDistance;
|
return d->animDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractAnimation::setAnimationVisible(bool animationVisible)
|
void AbstractAnimation::setVisible(bool isVisible)
|
||||||
{
|
{
|
||||||
d->animVisible = animationVisible;
|
d->animVisible = isVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractAnimation::animationVisible() const
|
bool AbstractAnimation::isVisible() const
|
||||||
{
|
{
|
||||||
return d->animVisible;
|
return d->animVisible;
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,9 @@ class PLASMA_EXPORT AbstractAnimation : public QObject
|
|||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QEasingCurve::Type easingCurveType READ easingCurveType WRITE setEasingCurveType)
|
Q_PROPERTY(QEasingCurve::Type easingCurveType READ easingCurveType WRITE setEasingCurveType)
|
||||||
Q_PROPERTY(AnimationDirection animationDirection READ animationDirection WRITE setAnimationDirection)
|
Q_PROPERTY(AnimationDirection direction READ direction WRITE setDirection)
|
||||||
Q_PROPERTY(qreal animationDistance READ animationDistance WRITE setAnimationDistance)
|
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
|
||||||
Q_PROPERTY(bool animationVisible READ animationVisible WRITE setAnimationVisible)
|
Q_PROPERTY(bool isVisible READ isVisible WRITE setVisible)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ public:
|
|||||||
* Set the widget on which the animation is to be performed.
|
* Set the widget on which the animation is to be performed.
|
||||||
* @arg receiver The QGraphicsWidget to be animated.
|
* @arg receiver The QGraphicsWidget to be animated.
|
||||||
*/
|
*/
|
||||||
virtual void setWidget(QGraphicsWidget* receiver);
|
virtual void setAnimatedWidget(QGraphicsWidget* receiver);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take an AbstractAnimation and turn it into a
|
* Take an AbstractAnimation and turn it into a
|
||||||
@ -80,36 +80,36 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the animation direction
|
* Set the animation direction
|
||||||
* @arg animationDirection animation direction
|
* @arg direction animation direction
|
||||||
*/
|
*/
|
||||||
void setAnimationDirection(AnimationDirection animationDirection);
|
void setDirection(AnimationDirection direction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the animation direction
|
* Get the animation direction
|
||||||
*/
|
*/
|
||||||
AnimationDirection animationDirection() const;
|
AnimationDirection direction() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the animation distance
|
* Set the animation distance
|
||||||
* @animationDistance animation distance
|
* @distance animation distance
|
||||||
*/
|
*/
|
||||||
void setAnimationDistance(qreal animationDistance);
|
void setDistance(qreal distance);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the animation distance
|
* Get the animation distance
|
||||||
*/
|
*/
|
||||||
qreal animationDistance() const;
|
qreal distance() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the animation visibility
|
* set the animation visibility
|
||||||
* @arg animationVisible animation visibility
|
* @arg isVisible animation visibility
|
||||||
*/
|
*/
|
||||||
void setAnimationVisible(bool animationVisible);
|
void setVisible(bool isVisible);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the animation visibility
|
* get the animation visibility
|
||||||
*/
|
*/
|
||||||
bool animationVisible() const;
|
bool isVisible() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ public slots:
|
|||||||
virtual void start() = 0;
|
virtual void start() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QGraphicsWidget *animatedObject();
|
QGraphicsWidget *animatedWidget();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractAnimationPrivate *d;
|
AbstractAnimationPrivate *d;
|
||||||
|
@ -75,7 +75,7 @@ void Animation::start()
|
|||||||
QAbstractAnimation* Animation::toQAbstractAnimation(QObject* parent)
|
QAbstractAnimation* Animation::toQAbstractAnimation(QObject* parent)
|
||||||
{
|
{
|
||||||
//check if .setObject() was done
|
//check if .setObject() was done
|
||||||
if (!animatedObject()) {
|
if (!animatedWidget()) {
|
||||||
kDebug() << "Object not set.";
|
kDebug() << "Object not set.";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -27,33 +27,33 @@ namespace Plasma
|
|||||||
|
|
||||||
ExpandAnimation::ExpandAnimation(AnimationDirection direction, qreal distance)
|
ExpandAnimation::ExpandAnimation(AnimationDirection direction, qreal distance)
|
||||||
{
|
{
|
||||||
setAnimationDirection(direction);
|
setDirection(direction);
|
||||||
setAnimationDistance(distance);
|
setDistance(distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractAnimation* ExpandAnimation::render(QObject* parent){
|
QAbstractAnimation* ExpandAnimation::render(QObject* parent){
|
||||||
|
|
||||||
//get current geometry values
|
//get current geometry values
|
||||||
QGraphicsWidget *m_object = animatedObject();
|
QGraphicsWidget *m_object = animatedWidget();
|
||||||
QRectF geometry = m_object->geometry();
|
QRectF geometry = m_object->geometry();
|
||||||
|
|
||||||
//compute new geometry values
|
//compute new geometry values
|
||||||
switch (animationDirection()) {
|
switch (direction()) {
|
||||||
|
|
||||||
case MoveUp:
|
case MoveUp:
|
||||||
geometry.setTop(geometry.y() - animationDistance());
|
geometry.setTop(geometry.y() - distance());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MoveRight:
|
case MoveRight:
|
||||||
geometry.setRight(geometry.x() + geometry.width() - 1 + animationDistance());
|
geometry.setRight(geometry.x() + geometry.width() - 1 + distance());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MoveDown:
|
case MoveDown:
|
||||||
geometry.setBottom(geometry.y() + geometry.height() - 1 + animationDistance());
|
geometry.setBottom(geometry.y() + geometry.height() - 1 + distance());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MoveLeft:
|
case MoveLeft:
|
||||||
geometry.setLeft(geometry.x() - animationDistance());
|
geometry.setLeft(geometry.x() - distance());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MoveUpRight:
|
case MoveUpRight:
|
||||||
|
@ -33,7 +33,7 @@ FadeAnimation::FadeAnimation(qreal factor)
|
|||||||
QAbstractAnimation* FadeAnimation::render(QObject* parent){
|
QAbstractAnimation* FadeAnimation::render(QObject* parent){
|
||||||
|
|
||||||
//create animation
|
//create animation
|
||||||
QGraphicsWidget *m_object = animatedObject();
|
QGraphicsWidget *m_object = animatedWidget();
|
||||||
QPropertyAnimation* anim = new QPropertyAnimation(m_object, "opacity", parent);
|
QPropertyAnimation* anim = new QPropertyAnimation(m_object, "opacity", parent);
|
||||||
anim->setEndValue(m_animFactor);
|
anim->setEndValue(m_animFactor);
|
||||||
anim->setDuration(duration());
|
anim->setDuration(duration());
|
||||||
|
@ -33,7 +33,7 @@ GrowAnimation::GrowAnimation(qreal factor)
|
|||||||
QAbstractAnimation* GrowAnimation::render(QObject* parent){
|
QAbstractAnimation* GrowAnimation::render(QObject* parent){
|
||||||
|
|
||||||
//get current geometry values
|
//get current geometry values
|
||||||
QGraphicsWidget *m_object = animatedObject();
|
QGraphicsWidget *m_object = animatedWidget();
|
||||||
QRectF geometry = m_object->geometry();
|
QRectF geometry = m_object->geometry();
|
||||||
qreal w = geometry.width();
|
qreal w = geometry.width();
|
||||||
qreal h = geometry.height();
|
qreal h = geometry.height();
|
||||||
|
@ -68,7 +68,7 @@ PulseAnimation::~PulseAnimation()
|
|||||||
|
|
||||||
void PulseAnimation::setCopy(QGraphicsWidget *copy)
|
void PulseAnimation::setCopy(QGraphicsWidget *copy)
|
||||||
{
|
{
|
||||||
QGraphicsWidget *target = animatedObject();
|
QGraphicsWidget *target = animatedWidget();
|
||||||
d->under = copy;
|
d->under = copy;
|
||||||
if (d->under != target) {
|
if (d->under != target) {
|
||||||
d->under->setParentItem(target);
|
d->under->setParentItem(target);
|
||||||
@ -116,7 +116,7 @@ void PulseAnimation::resetPulser()
|
|||||||
|
|
||||||
void PulseAnimation::createAnimation(qreal duration, qreal scale)
|
void PulseAnimation::createAnimation(qreal duration, qreal scale)
|
||||||
{
|
{
|
||||||
QGraphicsWidget *target = animatedObject();
|
QGraphicsWidget *target = animatedWidget();
|
||||||
/* Fallback to parent widget if we don't have one 'shadow' widget */
|
/* Fallback to parent widget if we don't have one 'shadow' widget */
|
||||||
if (!d->under) {
|
if (!d->under) {
|
||||||
setCopy(target);
|
setCopy(target);
|
||||||
|
@ -91,7 +91,7 @@ void RotationAnimation::setAngle(const qreal &angle)
|
|||||||
QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
QGraphicsWidget *m_object = animatedObject();
|
QGraphicsWidget *m_object = animatedWidget();
|
||||||
|
|
||||||
QVector3D vector(0, 0, 0);
|
QVector3D vector(0, 0, 0);
|
||||||
|
|
||||||
|
@ -27,35 +27,35 @@ namespace Plasma
|
|||||||
|
|
||||||
SlideAnimation::SlideAnimation(AnimationDirection direction, qreal distance)
|
SlideAnimation::SlideAnimation(AnimationDirection direction, qreal distance)
|
||||||
{
|
{
|
||||||
setAnimationDirection(direction);
|
setDirection(direction);
|
||||||
setAnimationDistance(distance);
|
setDistance(distance);
|
||||||
setAnimationVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractAnimation* SlideAnimation::render(QObject* parent)
|
QAbstractAnimation* SlideAnimation::render(QObject* parent)
|
||||||
{
|
{
|
||||||
QGraphicsWidget *m_object = animatedObject();
|
QGraphicsWidget *m_object = animatedWidget();
|
||||||
qreal x = m_object->x();
|
qreal x = m_object->x();
|
||||||
qreal y = m_object->y();
|
qreal y = m_object->y();
|
||||||
|
|
||||||
qreal newX = x;
|
qreal newX = x;
|
||||||
qreal newY = y;
|
qreal newY = y;
|
||||||
|
|
||||||
switch (animationDirection()) {
|
switch (direction()) {
|
||||||
case MoveUp:
|
case MoveUp:
|
||||||
newY = y - animationDistance();
|
newY = y - distance();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MoveRight:
|
case MoveRight:
|
||||||
newX = x + animationDistance();
|
newX = x + distance();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MoveDown:
|
case MoveDown:
|
||||||
newY = y + animationDistance();
|
newY = y + distance();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MoveLeft:
|
case MoveLeft:
|
||||||
newX = x - animationDistance();
|
newX = x - distance();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MoveUpRight:
|
case MoveUpRight:
|
||||||
@ -73,7 +73,7 @@ QAbstractAnimation* SlideAnimation::render(QObject* parent)
|
|||||||
|
|
||||||
//QObject::connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater()));
|
//QObject::connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater()));
|
||||||
|
|
||||||
if (animationVisible()) {
|
if (isVisible()) {
|
||||||
QObject::connect(anim, SIGNAL(finished()), m_object, SLOT(show()));
|
QObject::connect(anim, SIGNAL(finished()), m_object, SLOT(show()));
|
||||||
} else {
|
} else {
|
||||||
QObject::connect(anim, SIGNAL(finished()), m_object, SLOT(hide()));
|
QObject::connect(anim, SIGNAL(finished()), m_object, SLOT(hide()));
|
||||||
@ -85,7 +85,7 @@ QAbstractAnimation* SlideAnimation::render(QObject* parent)
|
|||||||
|
|
||||||
void SlideAnimation::setVisibleAtEnd(bool visibility)
|
void SlideAnimation::setVisibleAtEnd(bool visibility)
|
||||||
{
|
{
|
||||||
setAnimationVisible(visibility);
|
setVisible(visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace Plasma
|
} //namespace Plasma
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
#ifndef PLASMA_ANIMATIONPRIVATE_H
|
#ifndef PLASMA_ANIMATIONPRIVATE_H
|
||||||
#define PLASMA_ANIMATIONPRIVATE_H
|
#define PLASMA_ANIMATIONPRIVATE_H
|
||||||
|
|
||||||
#include <QEasingCurve>
|
#include <QEasingCurve>
|
||||||
|
#include <QWeakPointer>
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -32,7 +33,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Object the animation(s) should act upon.
|
* Object the animation(s) should act upon.
|
||||||
*/
|
*/
|
||||||
QGraphicsWidget* animObject;
|
QWeakPointer<QGraphicsWidget> animObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animation direction: where the animation will move.
|
* Animation direction: where the animation will move.
|
||||||
|
@ -40,9 +40,9 @@ FocusIndicator::FocusIndicator(QGraphicsWidget *parent)
|
|||||||
m_background->setCacheAllRenderedFrames(true);
|
m_background->setCacheAllRenderedFrames(true);
|
||||||
|
|
||||||
m_fadeIn = new FadeAnimation(1.0);
|
m_fadeIn = new FadeAnimation(1.0);
|
||||||
m_fadeIn->setWidget(this);
|
m_fadeIn->setAnimatedWidget(this);
|
||||||
m_fadeOut = new FadeAnimation(0.0);
|
m_fadeOut = new FadeAnimation(0.0);
|
||||||
m_fadeOut->setWidget(this);
|
m_fadeOut->setAnimatedWidget(this);
|
||||||
setOpacity(0);
|
setOpacity(0);
|
||||||
|
|
||||||
parent->installEventFilter(this);
|
parent->installEventFilter(this);
|
||||||
@ -92,6 +92,8 @@ void FocusIndicator::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||||||
|
|
||||||
void FocusIndicator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void FocusIndicator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(option)
|
||||||
|
Q_UNUSED(widget)
|
||||||
m_background->paintFrame(painter);
|
m_background->paintFrame(painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user