adjust menu geometry on animation progress instead of zoom effect
This commit is contained in:
parent
61049f2944
commit
1395f1c1eb
|
@ -5,7 +5,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "iconmenu.h"
|
#include "iconmenu.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "lib/scaleeffect.h"
|
//#include "lib/scaleeffect.h"
|
||||||
|
|
||||||
MenuOverlay::MenuOverlay(QWidget *parent)
|
MenuOverlay::MenuOverlay(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
@ -23,7 +23,7 @@ IconMenu::IconMenu(const QIcon &icon, QWidget *parent)
|
||||||
_menuOverlay(new MenuOverlay),
|
_menuOverlay(new MenuOverlay),
|
||||||
_menu(new Menu(_menuOverlay)),
|
_menu(new Menu(_menuOverlay)),
|
||||||
_animation(new QPropertyAnimation(this)),
|
_animation(new QPropertyAnimation(this)),
|
||||||
_effect(new ScaleEffect(this)),
|
//_effect(new ScaleEffect(this)),
|
||||||
_menuVisible(false),
|
_menuVisible(false),
|
||||||
_progress(1)
|
_progress(1)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,8 @@ IconMenu::IconMenu(const QIcon &icon, QWidget *parent)
|
||||||
_animation->setEasingCurve(QEasingCurve::OutCubic);
|
_animation->setEasingCurve(QEasingCurve::OutCubic);
|
||||||
|
|
||||||
_menu->hide();
|
_menu->hide();
|
||||||
|
|
||||||
|
/*
|
||||||
_menu->setGraphicsEffect(_effect);
|
_menu->setGraphicsEffect(_effect);
|
||||||
|
|
||||||
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
|
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
|
||||||
|
@ -46,6 +48,7 @@ IconMenu::IconMenu(const QIcon &icon, QWidget *parent)
|
||||||
effect->setOffset(QPoint(0, 0));
|
effect->setOffset(QPoint(0, 0));
|
||||||
effect->setColor(QColor(0, 0, 0, 200));
|
effect->setColor(QColor(0, 0, 0, 200));
|
||||||
_menuOverlay->setGraphicsEffect(effect);
|
_menuOverlay->setGraphicsEffect(effect);
|
||||||
|
*/
|
||||||
|
|
||||||
_menuOverlay->installEventFilter(this);
|
_menuOverlay->installEventFilter(this);
|
||||||
|
|
||||||
|
@ -68,7 +71,8 @@ void IconMenu::setProgress(qreal progress)
|
||||||
return;
|
return;
|
||||||
_progress = progress;
|
_progress = progress;
|
||||||
|
|
||||||
_effect->setScale(progress, progress);
|
//_effect->setScale(progress, progress);
|
||||||
|
updateOverlayGeometry();
|
||||||
|
|
||||||
emit progressChanged(progress);
|
emit progressChanged(progress);
|
||||||
update();
|
update();
|
||||||
|
@ -124,7 +128,7 @@ bool IconMenu::event(QEvent *event)
|
||||||
|
|
||||||
void IconMenu::updateOverlayGeometry()
|
void IconMenu::updateOverlayGeometry()
|
||||||
{
|
{
|
||||||
const QSize size = iconSize();
|
const QPoint pos = _menuPos;
|
||||||
const QPoint pos = _menuPos + QPoint(size.width()/2, size.height()/2);
|
const QSize size = _menu->layout()->sizeHint();
|
||||||
_menu->setGeometry(QRect(pos, _menu->layout()->sizeHint()));
|
_menu->setGeometry(QRect(pos, size * _progress));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
class QPropertyAnimation;
|
class QPropertyAnimation;
|
||||||
class ScaleEffect;
|
//class ScaleEffect;
|
||||||
class Menu;
|
class Menu;
|
||||||
|
|
||||||
class IconMenu : public IconButton
|
class IconMenu : public IconButton
|
||||||
|
@ -50,7 +50,7 @@ private:
|
||||||
MenuOverlay *const _menuOverlay;
|
MenuOverlay *const _menuOverlay;
|
||||||
Menu *const _menu;
|
Menu *const _menu;
|
||||||
QPropertyAnimation *const _animation;
|
QPropertyAnimation *const _animation;
|
||||||
ScaleEffect *const _effect;
|
//ScaleEffect *const _effect;
|
||||||
QPoint _menuPos;
|
QPoint _menuPos;
|
||||||
bool _menuVisible;
|
bool _menuVisible;
|
||||||
qreal _progress;
|
qreal _progress;
|
||||||
|
|
Loading…
Reference in New Issue