diff --git a/components/iconmenu.cpp b/components/iconmenu.cpp index 5227be0..1fc8916 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(270); + _animation->setDuration(200); _animation->setStartValue(1); _animation->setEndValue(0); - _animation->setEasingCurve(QEasingCurve::OutCubic); + _animation->setEasingCurve(QEasingCurve::InCurve); _menu->hide(); @@ -108,7 +108,7 @@ void IconMenu::animationFinished() bool IconMenu::eventFilter(QObject *obj, QEvent *event) { - if (QEvent::MouseButtonRelease == event->type() && _menuOverlay == obj) + if (QEvent::MouseButtonRelease == event->type() && _menuVisible && _menuOverlay == obj) toggleMenu(); return IconButton::eventFilter(obj, event); } @@ -130,5 +130,11 @@ void IconMenu::updateOverlayGeometry() { const QPoint pos = _menuPos; const QSize size = _menu->layout()->sizeHint(); - _menu->setGeometry(QRect(pos, size * _progress)); + 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)); + } else { + _menu->setGeometry(QRect(pos, size)); + } } diff --git a/components/iconmenu.h b/components/iconmenu.h index 7b64873..ea06c75 100644 --- a/components/iconmenu.h +++ b/components/iconmenu.h @@ -47,13 +47,13 @@ protected: void updateOverlayGeometry(); private: - MenuOverlay *const _menuOverlay; - Menu *const _menu; - QPropertyAnimation *const _animation; + MenuOverlay *const _menuOverlay; + Menu *const _menu; + QPropertyAnimation *const _animation; //ScaleEffect *const _effect; - QPoint _menuPos; - bool _menuVisible; - qreal _progress; + QPoint _menuPos; + bool _menuVisible; + qreal _progress; }; #endif // ICONMENU_H