diff --git a/ui/widgets/buttons.cpp b/ui/widgets/buttons.cpp index a76aab0..2760a79 100644 --- a/ui/widgets/buttons.cpp +++ b/ui/widgets/buttons.cpp @@ -206,6 +206,11 @@ void FlatButton::setWidth(int w) { resize(_width, height()); } +void FlatButton::setColorOverride(std::optional color) { + _colorOverride = color; + update(); +} + int32 FlatButton::textWidth() const { return _st.font->width(_text); } @@ -225,7 +230,11 @@ void FlatButton::paintEvent(QPaintEvent *e) { p.setFont(isOver() ? _st.overFont : _st.font); p.setRenderHint(QPainter::TextAntialiasing); - p.setPen(isOver() ? _st.overColor : _st.color); + if (_colorOverride) { + p.setPen(*_colorOverride); + } else { + p.setPen(isOver() ? _st.overColor : _st.color); + } const auto textRect = inner.marginsRemoved( _textMargins diff --git a/ui/widgets/buttons.h b/ui/widgets/buttons.h index 64354fc..9b1e3f8 100644 --- a/ui/widgets/buttons.h +++ b/ui/widgets/buttons.h @@ -94,6 +94,7 @@ public: void setText(const QString &text); void setWidth(int w); + void setColorOverride(std::optional color); void setTextMargins(QMargins margins); int32 textWidth() const; @@ -107,6 +108,7 @@ private: QString _text; QMargins _textMargins; int _width = 0; + std::optional _colorOverride; const style::FlatButton &_st;