From d64908cb92302755f356b6a38d1db63c51f80893 Mon Sep 17 00:00:00 2001 From: johanneshilden Date: Mon, 2 Oct 2017 16:29:31 +0300 Subject: [PATCH] Fix ripple geometry in Icon Button --- components/qtmaterialiconbutton.cpp | 16 +++++++++++++++- components/qtmaterialiconbutton_p.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/components/qtmaterialiconbutton.cpp b/components/qtmaterialiconbutton.cpp index 0efe6b5..f42ea3e 100644 --- a/components/qtmaterialiconbutton.cpp +++ b/components/qtmaterialiconbutton.cpp @@ -35,6 +35,16 @@ void QtMaterialIconButtonPrivate::init() q->setSizePolicy(policy); } +void QtMaterialIconButtonPrivate::updateRipple() +{ + Q_Q(QtMaterialIconButton); + + QRect r(q->rect()); + r.setSize(QSize(q->width()*2, q->height()*2)); + r.moveCenter(q->geometry().center()); + rippleOverlay->setGeometry(r); +} + /*! * \class QtMaterialIconButton */ @@ -131,6 +141,10 @@ bool QtMaterialIconButton::event(QEvent *event) switch (event->type()) { + case QEvent::Move: + case QEvent::Resize: + d->updateRipple(); + break; case QEvent::ParentChange: { QWidget *widget; if ((widget = parentWidget())) { @@ -153,7 +167,7 @@ bool QtMaterialIconButton::eventFilter(QObject *obj, QEvent *event) { Q_D(QtMaterialIconButton); - d->rippleOverlay->setGeometry(geometry().adjusted(-8, -8, 8, 8)); + d->updateRipple(); } return QAbstractButton::eventFilter(obj, event); } diff --git a/components/qtmaterialiconbutton_p.h b/components/qtmaterialiconbutton_p.h index 3f7fe61..a532abc 100644 --- a/components/qtmaterialiconbutton_p.h +++ b/components/qtmaterialiconbutton_p.h @@ -17,6 +17,7 @@ public: virtual ~QtMaterialIconButtonPrivate(); void init(); + void updateRipple(); QtMaterialIconButton *const q_ptr; QtMaterialRippleOverlay *rippleOverlay;