From e6fd12d8bf062b3cd1171c4980ae1bc4ebbff9bd Mon Sep 17 00:00:00 2001 From: laserpants Date: Mon, 21 Mar 2016 01:03:44 +0300 Subject: [PATCH] check that value differs from current value in setters --- lib/ripple.cpp | 18 ++++++++++++++++++ lib/ripple.h | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/ripple.cpp b/lib/ripple.cpp index fe76d2b..f5d00ad 100644 --- a/lib/ripple.cpp +++ b/lib/ripple.cpp @@ -20,6 +20,24 @@ Ripple::~Ripple() { } +void Ripple::setRadius(qreal radius) +{ + if (radius == _radius) + return; + + _radius = radius; + emit valueChanged(); +} + +void Ripple::setOpacity(qreal opacity) +{ + if (opacity == _opacity) + return; + + _opacity = opacity; + emit valueChanged(); +} + QPropertyAnimation *Ripple::animate(const QByteArray &property) { QPropertyAnimation *animation = new QPropertyAnimation; diff --git a/lib/ripple.h b/lib/ripple.h index 2227237..73a8767 100644 --- a/lib/ripple.h +++ b/lib/ripple.h @@ -17,10 +17,10 @@ public: explicit Ripple(const QPoint ¢er, QObject *parent = 0); ~Ripple(); - inline void setRadius(qreal radius) { _radius = radius; emit valueChanged(); } + void setRadius(qreal radius); inline qreal radius() const { return _radius; } - inline void setOpacity(qreal opacity) { _opacity = opacity; emit valueChanged(); } + void setOpacity(qreal opacity); inline qreal opacity() const { return _opacity; } inline const QPoint ¢er() const { return _center; }