style FAB and Raised Button for disabled mode
This commit is contained in:
parent
49f9937545
commit
065a2c6304
|
@ -193,7 +193,8 @@ void FloatingActionButton::paintEvent(QPaintEvent *event)
|
||||||
QBrush brush;
|
QBrush brush;
|
||||||
brush.setStyle(Qt::SolidPattern);
|
brush.setStyle(Qt::SolidPattern);
|
||||||
brush.setColor(isEnabled()
|
brush.setColor(isEnabled()
|
||||||
? backgroundColor() : palette().color(QPalette::Disabled, QPalette::Background));
|
? backgroundColor()
|
||||||
|
: disabledTextColor());
|
||||||
painter.setBrush(brush);
|
painter.setBrush(brush);
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,25 @@ RaisedButton::~RaisedButton()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RaisedButton::setDisabledBackgroundColor(const QColor &color)
|
||||||
|
{
|
||||||
|
Q_D(RaisedButton);
|
||||||
|
|
||||||
|
d->disabledBackgroundColor = color;
|
||||||
|
setUseThemeColors(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor RaisedButton::disabledBackgroundColor() const
|
||||||
|
{
|
||||||
|
Q_D(const RaisedButton);
|
||||||
|
|
||||||
|
if (d->useThemeColors || !d->disabledBackgroundColor.isValid()) {
|
||||||
|
return Style::instance().themeColor("disabled3");
|
||||||
|
} else {
|
||||||
|
return d->disabledBackgroundColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RaisedButton::RaisedButton(RaisedButtonPrivate &d, QWidget *parent)
|
RaisedButton::RaisedButton(RaisedButtonPrivate &d, QWidget *parent)
|
||||||
: FlatButton(d, parent)
|
: FlatButton(d, parent)
|
||||||
{
|
{
|
||||||
|
@ -122,8 +141,10 @@ bool RaisedButton::event(QEvent *event)
|
||||||
if (QEvent::EnabledChange == event->type()) {
|
if (QEvent::EnabledChange == event->type()) {
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
d->machine.start();
|
d->machine.start();
|
||||||
|
d->effect->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
d->machine.stop();
|
d->machine.stop();
|
||||||
|
d->effect->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FlatButton::event(event);
|
return FlatButton::event(event);
|
||||||
|
@ -145,7 +166,8 @@ void RaisedButton::paintEvent(QPaintEvent *event)
|
||||||
QBrush brush;
|
QBrush brush;
|
||||||
brush.setStyle(Qt::SolidPattern);
|
brush.setStyle(Qt::SolidPattern);
|
||||||
brush.setColor(isEnabled()
|
brush.setColor(isEnabled()
|
||||||
? backgroundColor() : palette().color(QPalette::Disabled, QPalette::Background));
|
? backgroundColor()
|
||||||
|
: disabledBackgroundColor());
|
||||||
painter.setBrush(brush);
|
painter.setBrush(brush);
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
painter.drawRoundedRect(rect(), cr, cr);
|
painter.drawRoundedRect(rect(), cr, cr);
|
||||||
|
|
|
@ -9,10 +9,15 @@ class RaisedButton : public FlatButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QColor disabledBackgroundColor WRITE setDisabledBackgroundColor READ disabledBackgroundColor)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RaisedButton(QWidget *parent = 0);
|
explicit RaisedButton(QWidget *parent = 0);
|
||||||
~RaisedButton();
|
~RaisedButton();
|
||||||
|
|
||||||
|
void setDisabledBackgroundColor(const QColor &color);
|
||||||
|
QColor disabledBackgroundColor() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RaisedButton(RaisedButtonPrivate &d, QWidget *parent = 0);
|
RaisedButton(RaisedButtonPrivate &d, QWidget *parent = 0);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ public:
|
||||||
QState *normalState;
|
QState *normalState;
|
||||||
QState *pressedState;
|
QState *pressedState;
|
||||||
QGraphicsDropShadowEffect *effect;
|
QGraphicsDropShadowEffect *effect;
|
||||||
|
QColor disabledBackgroundColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RAISEDBUTTON_P_H
|
#endif // RAISEDBUTTON_P_H
|
||||||
|
|
|
@ -24,6 +24,8 @@ Theme::Theme(QObject *parent)
|
||||||
setColor("canvas", Material::white);
|
setColor("canvas", Material::white);
|
||||||
setColor("border", Material::grey300);
|
setColor("border", Material::grey300);
|
||||||
setColor("disabled", Material::minBlack);
|
setColor("disabled", Material::minBlack);
|
||||||
|
setColor("disabled2", Material::faintBlack);
|
||||||
|
setColor("disabled3", Material::grey300);
|
||||||
}
|
}
|
||||||
|
|
||||||
Theme::~Theme()
|
Theme::~Theme()
|
||||||
|
|
Loading…
Reference in New Issue