log isChecked status to figure out weird Toggle animation behavior

This commit is contained in:
laserpants 2016-03-30 23:30:10 +03:00
parent 7c2c6c56d0
commit db3439f604
2 changed files with 16 additions and 6 deletions

View File

@ -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

View File

@ -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;