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