Q(Plain)TextEdit: Observe color hints from style sheet depending on focus state
Ask the style sheet style to adapt the palette in WidgetTextControl::getPaintContext() as is done for QLineEdit. Use the palette color in QPlainTextEdit. Change-Id: I67758716b66feaeac8c2433c2a4d3744cd0d5327 Fixes: QTBUG-72100 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
81b33a8252
commit
90c683e41c
@ -1957,6 +1957,7 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QAbstractTextDocumentLayout::PaintContext context = getPaintContext();
|
QAbstractTextDocumentLayout::PaintContext context = getPaintContext();
|
||||||
|
painter.setPen(context.palette.text().color());
|
||||||
|
|
||||||
while (block.isValid()) {
|
while (block.isValid()) {
|
||||||
|
|
||||||
|
@ -64,6 +64,9 @@
|
|||||||
#include "private/qtextdocument_p.h"
|
#include "private/qtextdocument_p.h"
|
||||||
#include "qtextlist.h"
|
#include "qtextlist.h"
|
||||||
#include "private/qwidgettextcontrol_p.h"
|
#include "private/qwidgettextcontrol_p.h"
|
||||||
|
#if QT_CONFIG(style_stylesheet)
|
||||||
|
# include "private/qstylesheetstyle_p.h"
|
||||||
|
#endif
|
||||||
#if QT_CONFIG(graphicsview)
|
#if QT_CONFIG(graphicsview)
|
||||||
#include "qgraphicssceneevent.h"
|
#include "qgraphicssceneevent.h"
|
||||||
#endif
|
#endif
|
||||||
@ -3187,6 +3190,15 @@ QAbstractTextDocumentLayout::PaintContext QWidgetTextControl::getPaintContext(QW
|
|||||||
|
|
||||||
ctx.selections = d->extraSelections;
|
ctx.selections = d->extraSelections;
|
||||||
ctx.palette = d->palette;
|
ctx.palette = d->palette;
|
||||||
|
#if QT_CONFIG(style_stylesheet)
|
||||||
|
if (widget) {
|
||||||
|
if (auto cssStyle = qt_styleSheet(widget->style())) {
|
||||||
|
QStyleOption option;
|
||||||
|
option.initFrom(widget);
|
||||||
|
cssStyle->styleSheetPalette(widget, &option, &ctx.palette);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // style_stylesheet
|
||||||
if (d->cursorOn && d->isEnabled) {
|
if (d->cursorOn && d->isEnabled) {
|
||||||
if (d->hideCursor)
|
if (d->hideCursor)
|
||||||
ctx.cursorPosition = -1;
|
ctx.cursorPosition = -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user