diff --git a/components/toggle.cpp b/components/toggle.cpp index 2005130..5ff2d75 100644 --- a/components/toggle.cpp +++ b/components/toggle.cpp @@ -55,14 +55,15 @@ void Thumb::mouseReleaseEvent(QMouseEvent *event) Q_UNUSED(event) const bool checked = _toggle->isChecked(); + _toggle->setChecked(!checked); _animation->setDirection(checked ? QAbstractAnimation::Forward : QAbstractAnimation::Backward); - if (QAbstractAnimation::Running != _animation->state()) { - _animation->setEasingCurve(checked - ? QEasingCurve::OutCubic - : QEasingCurve::InCubic); - } +// if (QAbstractAnimation::Running != _animation->state()) { +// _animation->setEasingCurve(checked +// ? QEasingCurve::OutCubic +// : QEasingCurve::InCubic); +// } _animation->start(); emit clicked(); @@ -107,8 +108,10 @@ Toggle::Toggle(QWidget *parent) _thumb->setGraphicsEffect(effect); _thumb->installEventFilter(this); - connect(_thumb, SIGNAL(clicked()), this, SLOT(toggle())); connect(_thumb, SIGNAL(clicked()), this, SLOT(addRipple())); + + connect(_thumb, SIGNAL(clicked()), this, SLOT(logCheckedStatus())); + connect(_thumb, SIGNAL(progressChanged(qreal)), this, SLOT(updateOverlayGeometry())); } @@ -116,6 +119,11 @@ Toggle::~Toggle() { } +void Toggle::logCheckedStatus() +{ + qDebug() << "checked : " << isChecked(); +} + QSize Toggle::sizeHint() const { return Qt::Horizontal == _orientation diff --git a/components/toggle.h b/components/toggle.h index 32b633e..dd5d319 100644 --- a/components/toggle.h +++ b/components/toggle.h @@ -55,12 +55,14 @@ public: protected slots: void addRipple(); void updateOverlayGeometry(); + void logCheckedStatus(); protected: bool event(QEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: + Thumb *const _thumb; RippleOverlay *const _overlay; Qt::Orientation _orientation;