diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2022-09-16 15:29:10 +0200 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2022-09-29 08:20:56 +0200 |
commit | 72a3da3d4d69e09e90399aef8434cc6b194ff984 (patch) | |
tree | 502a20d26be5cecc4a86729046f344888bda6a81 /src/widgets/styles | |
parent | b6db79d82f10ff13e2688a298a7bb328999641e5 (diff) |
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 <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
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<Declaration> &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 |