Fix highlighted piece color

PR #20971.
This commit is contained in:
Prince Gupta 2024-09-02 10:41:35 +05:30 committed by GitHub
parent 9d0fa213be
commit a7f7c5fb73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

@ -195,10 +195,8 @@ void PiecesBar::paintEvent(QPaintEvent *)
if (!m_highlightedRegion.isNull()) if (!m_highlightedRegion.isNull())
{ {
QColor highlightColor {this->palette().color(QPalette::Active, QPalette::Highlight)};
highlightColor.setAlphaF(0.35f);
QRect targetHighlightRect {m_highlightedRegion.adjusted(borderWidth, borderWidth, borderWidth, height() - 2 * borderWidth)}; QRect targetHighlightRect {m_highlightedRegion.adjusted(borderWidth, borderWidth, borderWidth, height() - 2 * borderWidth)};
painter.fillRect(targetHighlightRect, highlightColor); painter.fillRect(targetHighlightRect, highlightedPieceColor());
} }
QPainterPath border; QPainterPath border;
@ -231,6 +229,13 @@ QColor PiecesBar::pieceColor() const
return palette().color(QPalette::Active, QPalette::Highlight); return palette().color(QPalette::Active, QPalette::Highlight);
} }
QColor PiecesBar::highlightedPieceColor() const
{
QColor col = palette().color(QPalette::Highlight).darker();
col.setAlphaF(0.35);
return col;
}
QColor PiecesBar::colorBoxBorderColor() const QColor PiecesBar::colorBoxBorderColor() const
{ {
return palette().color(QPalette::Active, QPalette::ToolTipText); return palette().color(QPalette::Active, QPalette::ToolTipText);

View file

@ -68,7 +68,9 @@ protected:
QColor backgroundColor() const; QColor backgroundColor() const;
QColor borderColor() const; QColor borderColor() const;
QColor pieceColor() const; QColor pieceColor() const;
QColor highlightedPieceColor() const;
QColor colorBoxBorderColor() const; QColor colorBoxBorderColor() const;
const QList<QRgb> &pieceColors() const; const QList<QRgb> &pieceColors() const;
// mix two colors by light model, ratio <0, 1> // mix two colors by light model, ratio <0, 1>