From 72a3da3d4d69e09e90399aef8434cc6b194ff984 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 16 Sep 2022 15:29:10 +0200 Subject: Style sheets: add placeholder text color property for edit widgets The placeholder text was given its own QPalette color role in Qt 5.12, but there has been no way to specify it from a Qt style sheet. Fixes: QTBUG-93009 Change-Id: If58ca844c19c65b7eee14c6d5730a4ba27640c33 Reviewed-by: Volker Hilsheimer --- src/widgets/styles/qstylesheetstyle.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index b64093ada5..7f22656fc8 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -437,14 +437,15 @@ struct QStyleSheetBoxData : public QSharedData struct QStyleSheetPaletteData : public QSharedData { QStyleSheetPaletteData(const QBrush &fg, const QBrush &sfg, const QBrush &sbg, - const QBrush &abg) + const QBrush &abg, const QBrush &pfg) : foreground(fg), selectionForeground(sfg), selectionBackground(sbg), - alternateBackground(abg) { } + alternateBackground(abg), placeholderForeground(pfg) { } QBrush foreground; QBrush selectionForeground; QBrush selectionBackground; QBrush alternateBackground; + QBrush placeholderForeground; }; struct QStyleSheetGeometryData : public QSharedData @@ -956,10 +957,10 @@ QRenderRule::QRenderRule(const QList &declarations, const QObject * bg = new QStyleSheetBackgroundData(brush, pixmap, repeat, alignment, origin, attachment, clip); } - QBrush sfg, fg; + QBrush sfg, fg, pfg; QBrush sbg, abg; - if (v.extractPalette(&fg, &sfg, &sbg, &abg)) - pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg); + if (v.extractPalette(&fg, &sfg, &sbg, &abg, &pfg)) + pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg, pfg); QIcon imgIcon; alignment = Qt::AlignCenter; @@ -1486,6 +1487,8 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q p->setBrush(cg, QPalette::HighlightedText, pal->selectionForeground); if (pal->alternateBackground.style() != Qt::NoBrush) p->setBrush(cg, QPalette::AlternateBase, pal->alternateBackground); + if (pal->placeholderForeground.style() != Qt::NoBrush) + p->setBrush(cg, QPalette::PlaceholderText, pal->placeholderForeground); } bool QRenderRule::hasModification() const -- cgit v1.2.3