remove changed signal from ripple
This commit is contained in:
parent
a6bf946190
commit
d876ecc443
|
@ -1,7 +1,9 @@
|
||||||
#include "ripple.h"
|
#include "ripple.h"
|
||||||
|
#include "rippleoverlay.h"
|
||||||
|
|
||||||
Ripple::Ripple(const QPoint ¢er, QObject *parent)
|
Ripple::Ripple(const QPoint ¢er, RippleOverlay *overlay, QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
|
_overlay(overlay),
|
||||||
_radiusAnimation(animate("radius")),
|
_radiusAnimation(animate("radius")),
|
||||||
_opacityAnimation(animate("opacity")),
|
_opacityAnimation(animate("opacity")),
|
||||||
_radius(0),
|
_radius(0),
|
||||||
|
@ -23,22 +25,31 @@ Ripple::~Ripple()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ripple::setOverlay(RippleOverlay *overlay)
|
||||||
|
{
|
||||||
|
_overlay = overlay;
|
||||||
|
}
|
||||||
|
|
||||||
void Ripple::setRadius(qreal radius)
|
void Ripple::setRadius(qreal radius)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(_overlay);
|
||||||
|
|
||||||
if (radius == _radius)
|
if (radius == _radius)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_radius = radius;
|
_radius = radius;
|
||||||
emit changed();
|
_overlay->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ripple::setOpacity(qreal opacity)
|
void Ripple::setOpacity(qreal opacity)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(_overlay);
|
||||||
|
|
||||||
if (opacity == _opacity)
|
if (opacity == _opacity)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_opacity = opacity;
|
_opacity = opacity;
|
||||||
emit changed();
|
_overlay->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ripple::setColor(const QColor &color)
|
void Ripple::setColor(const QColor &color)
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
|
|
||||||
|
class RippleOverlay;
|
||||||
|
|
||||||
class Ripple : public QObject
|
class Ripple : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -15,9 +17,11 @@ class Ripple : public QObject
|
||||||
Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity)
|
Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Ripple(const QPoint ¢er, QObject *parent = 0);
|
explicit Ripple(const QPoint ¢er, RippleOverlay *overlay = 0, QObject *parent = 0);
|
||||||
~Ripple();
|
~Ripple();
|
||||||
|
|
||||||
|
void setOverlay(RippleOverlay *overlay);
|
||||||
|
|
||||||
void setRadius(qreal radius);
|
void setRadius(qreal radius);
|
||||||
inline qreal radius() const { return _radius; }
|
inline qreal radius() const { return _radius; }
|
||||||
|
|
||||||
|
@ -64,13 +68,13 @@ public:
|
||||||
inline void startAnimation() { _group.start(); }
|
inline void startAnimation() { _group.start(); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPropertyAnimation *animate(const QByteArray &property);
|
QPropertyAnimation *animate(const QByteArray &property);
|
||||||
|
|
||||||
QParallelAnimationGroup _group;
|
QParallelAnimationGroup _group;
|
||||||
|
RippleOverlay *_overlay;
|
||||||
QPropertyAnimation *const _radiusAnimation;
|
QPropertyAnimation *const _radiusAnimation;
|
||||||
QPropertyAnimation *const _opacityAnimation;
|
QPropertyAnimation *const _opacityAnimation;
|
||||||
qreal _radius;
|
qreal _radius;
|
||||||
|
|
|
@ -17,15 +17,15 @@ RippleOverlay::~RippleOverlay()
|
||||||
|
|
||||||
void RippleOverlay::addRipple(const QPoint &position, qreal radius)
|
void RippleOverlay::addRipple(const QPoint &position, qreal radius)
|
||||||
{
|
{
|
||||||
Ripple *ripple = new Ripple(position);
|
Ripple *ripple = new Ripple(position, this);
|
||||||
ripple->setRadiusEndValue(radius);
|
ripple->setRadiusEndValue(radius);
|
||||||
addRipple(ripple);
|
addRipple(ripple);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RippleOverlay::addRipple(Ripple *ripple)
|
void RippleOverlay::addRipple(Ripple *ripple)
|
||||||
{
|
{
|
||||||
|
ripple->setOverlay(this);
|
||||||
ripples.push_back(ripple);
|
ripples.push_back(ripple);
|
||||||
connect(ripple, SIGNAL(changed()), this, SLOT(update()));
|
|
||||||
connect(ripple, SIGNAL(finished()), this, SLOT(deleteRipple()));
|
connect(ripple, SIGNAL(finished()), this, SLOT(deleteRipple()));
|
||||||
ripple->startAnimation();
|
ripple->startAnimation();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue