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;