diff --git a/components/iconmenu.cpp b/components/iconmenu.cpp index 1fc8916..5a979f6 100644 --- a/components/iconmenu.cpp +++ b/components/iconmenu.cpp @@ -32,11 +32,11 @@ IconMenu::IconMenu(const QIcon &icon, QWidget *parent) _animation->setPropertyName("progress"); _animation->setTargetObject(this); - _animation->setDuration(200); + _animation->setDuration(340); _animation->setStartValue(1); _animation->setEndValue(0); - _animation->setEasingCurve(QEasingCurve::InCurve); + _animation->setEasingCurve(QEasingCurve::InBounce); _menu->hide(); @@ -85,6 +85,12 @@ void IconMenu::setOverlayParent(QWidget *parent) void IconMenu::toggleMenu() { + if (QAbstractAnimation::Running != _animation->state()) { + _animation->setEasingCurve(_menuVisible + ? QEasingCurve::OutCubic + : QEasingCurve::InBounce); + } + _animation->setDirection(_menuVisible ? QAbstractAnimation::Forward : QAbstractAnimation::Backward); @@ -131,9 +137,7 @@ void IconMenu::updateOverlayGeometry() const QPoint pos = _menuPos; const QSize size = _menu->layout()->sizeHint(); if (QAbstractAnimation::Running == _animation->state()) { - const QSize menuSize = size*(_progress*0.4 + 0.6); - _menu->setGeometry(QRect(pos, menuSize)); - _menu->layout()->setGeometry(QRect(0, 0, menuSize.width(), size.height()*_progress)); + _menu->setGeometry(QRect(pos, size*_progress)); } else { _menu->setGeometry(QRect(pos, size)); } diff --git a/components/toggle.cpp b/components/toggle.cpp index 2b7cbbe..ec17d6c 100644 --- a/components/toggle.cpp +++ b/components/toggle.cpp @@ -56,12 +56,15 @@ bool Thumb::eventFilter(QObject *obj, QEvent *event) void Thumb::mouseReleaseEvent(QMouseEvent *event) { const bool checked = _toggle->isChecked(); + _toggle->setChecked(!checked); + if (QAbstractAnimation::Running != _animation->state()) { _animation->setEasingCurve(checked ? QEasingCurve::OutCubic : QEasingCurve::InCubic); } + _animation->setDirection(checked ? QAbstractAnimation::Forward : QAbstractAnimation::Backward);