From 8a9e3c78694f85582c53c66fd7dbdc7e0e5f4ab3 Mon Sep 17 00:00:00 2001 From: Axel Spoerl Date: Thu, 1 Jun 2023 14:11:45 +0200 Subject: [PATCH] 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 --- src/gui/text/qtextdocumentlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 56ce6861f1..fe049766ab 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -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(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)