diff --git a/components/raisedbutton.cpp b/components/raisedbutton.cpp index ae55dfb..d84c4dd 100644 --- a/components/raisedbutton.cpp +++ b/components/raisedbutton.cpp @@ -122,6 +122,20 @@ void RaisedButton::setRole(Material::Role role) update(); } +bool RaisedButton::event(QEvent *event) +{ + Q_D(RaisedButton); + + if (QEvent::EnabledChange == event->type()) { + if (isEnabled()) { + d->machine.start(); + } else { + d->machine.stop(); + } + } + return FlatButton::event(event); +} + void RaisedButton::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -135,13 +149,13 @@ void RaisedButton::paintEvent(QPaintEvent *event) QBrush brush; - if (isEnabled()) { - brush.setStyle(Qt::SolidPattern); - brush.setColor(palette().color(QPalette::Active, QPalette::Background)); - painter.setBrush(brush); - painter.setPen(Qt::NoPen); - painter.drawRoundedRect(rect(), 3, 3); - } + brush.setStyle(Qt::SolidPattern); + brush.setColor(isEnabled() + ? palette().color(QPalette::Active, QPalette::Background) + : palette().color(QPalette::Disabled, QPalette::Background)); + painter.setBrush(brush); + painter.setPen(Qt::NoPen); + painter.drawRoundedRect(rect(), 3, 3); if (isEnabled()) { const qreal hs = static_cast(width())*d->delegate->focusHaloSize()/2; diff --git a/components/raisedbutton.h b/components/raisedbutton.h index 27bf13c..357cd31 100644 --- a/components/raisedbutton.h +++ b/components/raisedbutton.h @@ -16,6 +16,7 @@ public: void setRole(Material::Role role) Q_DECL_OVERRIDE; protected: + bool event(QEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: diff --git a/examples/raisedbuttonexamples.cpp b/examples/raisedbuttonexamples.cpp index 6963d8b..6da577e 100644 --- a/examples/raisedbuttonexamples.cpp +++ b/examples/raisedbuttonexamples.cpp @@ -13,7 +13,7 @@ RaisedButtonExamples::RaisedButtonExamples(QWidget *parent) raisedButton->setRole(Material::Primary); raisedButton->setText("Press me!"); - raisedButton->setDisabled(true); + //raisedButton->setDisabled(true); //raisedButton->setFixedSize(400, 50);