summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-05-15 15:06:20 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-05-24 13:06:20 +0200
commit90c683e41cd978b55de57cb424a986db3b637fcc (patch)
tree220f2267ad4e4dffdb635eeb4fe005f81a012377
parent81b33a8252d8a69277782f51c9c7401c7009c72e (diff)
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>
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp1
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp12
2 files changed, 13 insertions, 0 deletions
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 0b5e69b6c3..3b5132a8c8 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -1957,6 +1957,7 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e)
}
QAbstractTextDocumentLayout::PaintContext context = getPaintContext();
+ painter.setPen(context.palette.text().color());
while (block.isValid()) {
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 6b8ce63380..ee757bf870 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -64,6 +64,9 @@
#include "private/qtextdocument_p.h"
#include "qtextlist.h"
#include "private/qwidgettextcontrol_p.h"
+#if QT_CONFIG(style_stylesheet)
+# include "private/qstylesheetstyle_p.h"
+#endif
#if QT_CONFIG(graphicsview)
#include "qgraphicssceneevent.h"
#endif
@@ -3187,6 +3190,15 @@ QAbstractTextDocumentLayout::PaintContext QWidgetTextControl::getPaintContext(QW
ctx.selections = d->extraSelections;
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->hideCursor)
ctx.cursorPosition = -1;