Default to WindowText color in QTextDocumentLayoutPrivate::drawBlock()

When a block is drawn in a text document, drawBlock is checking,
whether the block has a BackgroundBrush property defined. If none is
defined, the color used to draw lines around the block defaults to
QPalette::Dark. This was implemented, assuming a light color scheme.
In a dark color scheme, the lines become hardly or even not visible.

This patch changes the default to Inactive/WindowText of the underlying
QPalette. This provides contrast to the document's text content and
is dark/light sensitive.

Fixes: QTBUG-113990
Pick-to: 6.5
Change-Id: Ie855852f441a0efb11c318c7edb27395151cbcce
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
This commit is contained in:
Axel Spoerl 2023-06-01 14:11:45 +02:00
parent 54d8d8055e
commit 8a9e3c7869

View File

@ -2070,7 +2070,7 @@ void QTextDocumentLayoutPrivate::drawBlock(const QPointF &offset, QPainter *pain
const qreal width = blockFormat.lengthProperty(QTextFormat::BlockTrailingHorizontalRulerWidth).value(r.width());
const auto color = blockFormat.hasProperty(QTextFormat::BackgroundBrush)
? qvariant_cast<QBrush>(blockFormat.property(QTextFormat::BackgroundBrush)).color()
: context.palette.color(QPalette::Dark);
: context.palette.color(QPalette::Inactive, QPalette::WindowText);
painter->setPen(color);
qreal y = r.bottom();
if (bl.length() == 1)