log isChecked status to figure out weird Toggle animation behavior
This commit is contained in:
parent
7c2c6c56d0
commit
db3439f604
|
@ -55,14 +55,15 @@ void Thumb::mouseReleaseEvent(QMouseEvent *event)
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
|
|
||||||
const bool checked = _toggle->isChecked();
|
const bool checked = _toggle->isChecked();
|
||||||
|
_toggle->setChecked(!checked);
|
||||||
_animation->setDirection(checked
|
_animation->setDirection(checked
|
||||||
? QAbstractAnimation::Forward
|
? QAbstractAnimation::Forward
|
||||||
: QAbstractAnimation::Backward);
|
: QAbstractAnimation::Backward);
|
||||||
if (QAbstractAnimation::Running != _animation->state()) {
|
// if (QAbstractAnimation::Running != _animation->state()) {
|
||||||
_animation->setEasingCurve(checked
|
// _animation->setEasingCurve(checked
|
||||||
? QEasingCurve::OutCubic
|
// ? QEasingCurve::OutCubic
|
||||||
: QEasingCurve::InCubic);
|
// : QEasingCurve::InCubic);
|
||||||
}
|
// }
|
||||||
_animation->start();
|
_animation->start();
|
||||||
|
|
||||||
emit clicked();
|
emit clicked();
|
||||||
|
@ -107,8 +108,10 @@ Toggle::Toggle(QWidget *parent)
|
||||||
_thumb->setGraphicsEffect(effect);
|
_thumb->setGraphicsEffect(effect);
|
||||||
_thumb->installEventFilter(this);
|
_thumb->installEventFilter(this);
|
||||||
|
|
||||||
connect(_thumb, SIGNAL(clicked()), this, SLOT(toggle()));
|
|
||||||
connect(_thumb, SIGNAL(clicked()), this, SLOT(addRipple()));
|
connect(_thumb, SIGNAL(clicked()), this, SLOT(addRipple()));
|
||||||
|
|
||||||
|
connect(_thumb, SIGNAL(clicked()), this, SLOT(logCheckedStatus()));
|
||||||
|
|
||||||
connect(_thumb, SIGNAL(progressChanged(qreal)), this, SLOT(updateOverlayGeometry()));
|
connect(_thumb, SIGNAL(progressChanged(qreal)), this, SLOT(updateOverlayGeometry()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +119,11 @@ Toggle::~Toggle()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Toggle::logCheckedStatus()
|
||||||
|
{
|
||||||
|
qDebug() << "checked : " << isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
QSize Toggle::sizeHint() const
|
QSize Toggle::sizeHint() const
|
||||||
{
|
{
|
||||||
return Qt::Horizontal == _orientation
|
return Qt::Horizontal == _orientation
|
||||||
|
|
|
@ -55,12 +55,14 @@ public:
|
||||||
protected slots:
|
protected slots:
|
||||||
void addRipple();
|
void addRipple();
|
||||||
void updateOverlayGeometry();
|
void updateOverlayGeometry();
|
||||||
|
void logCheckedStatus();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
||||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Thumb *const _thumb;
|
Thumb *const _thumb;
|
||||||
RippleOverlay *const _overlay;
|
RippleOverlay *const _overlay;
|
||||||
Qt::Orientation _orientation;
|
Qt::Orientation _orientation;
|
||||||
|
|
Loading…
Reference in New Issue