From e98c026fc99d1a1f8689e1491722a47abaf34d91 Mon Sep 17 00:00:00 2001 From: johanneshilden Date: Sun, 1 Oct 2017 22:34:55 +0300 Subject: [PATCH] Fix Icon Button ripple geometry --- components/qtmaterialiconbutton.cpp | 16 ++++++++++++++++ components/qtmaterialiconbutton.h | 1 + 2 files changed, 17 insertions(+) diff --git a/components/qtmaterialiconbutton.cpp b/components/qtmaterialiconbutton.cpp index 71fd70f..0efe6b5 100644 --- a/components/qtmaterialiconbutton.cpp +++ b/components/qtmaterialiconbutton.cpp @@ -26,6 +26,8 @@ void QtMaterialIconButtonPrivate::init() rippleOverlay = new QtMaterialRippleOverlay(q->parentWidget()); useThemeColors = true; + rippleOverlay->installEventFilter(q); + q->setStyle(&QtMaterialStyle::instance()); QSizePolicy policy; @@ -142,6 +144,20 @@ bool QtMaterialIconButton::event(QEvent *event) return QAbstractButton::event(event); } +/*! + * \reimp + */ +bool QtMaterialIconButton::eventFilter(QObject *obj, QEvent *event) +{ + if (QEvent::Resize == event->type()) + { + Q_D(QtMaterialIconButton); + + d->rippleOverlay->setGeometry(geometry().adjusted(-8, -8, 8, 8)); + } + return QAbstractButton::eventFilter(obj, event); +} + /*! * \reimp */ diff --git a/components/qtmaterialiconbutton.h b/components/qtmaterialiconbutton.h index 90dd91f..5c2afc4 100644 --- a/components/qtmaterialiconbutton.h +++ b/components/qtmaterialiconbutton.h @@ -28,6 +28,7 @@ protected: QtMaterialIconButton(QtMaterialIconButtonPrivate &d, QWidget *parent = 0); bool event(QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;