diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/text/qcssparser.cpp | 19 | ||||
-rw-r--r-- | src/gui/text/qcssparser_p.h | 5 | ||||
-rw-r--r-- | src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc | 8 | ||||
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 35 |
4 files changed, 52 insertions, 15 deletions
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index f79369a36b..02d99a82ed 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -47,6 +47,7 @@ static const QCssKnownValue properties[NumProperties - 1] = { { "-qt-style-features", QtStyleFeatures }, { "-qt-table-type", QtTableType }, { "-qt-user-state", QtUserState }, + { "accent-color", QtAccentColor }, { "alternate-background-color", QtAlternateBackground }, { "background", Background }, { "background-attachment", BackgroundAttachment }, @@ -1341,17 +1342,23 @@ bool ValueExtractor::extractFont(QFont *font, int *fontSizeAdjustment) return hit; } -bool ValueExtractor::extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg, QBrush *pfg) +bool ValueExtractor::extractPalette(QBrush *foreground, + QBrush *selectedForeground, + QBrush *selectedBackground, + QBrush *alternateBackground, + QBrush *placeHolderTextForeground, + QBrush *accentColor) { bool hit = false; for (int i = 0; i < declarations.size(); ++i) { const Declaration &decl = declarations.at(i); switch (decl.d->propertyId) { - case Color: *fg = decl.brushValue(pal); break; - case QtSelectionForeground: *sfg = decl.brushValue(pal); break; - case QtSelectionBackground: *sbg = decl.brushValue(pal); break; - case QtAlternateBackground: *abg = decl.brushValue(pal); break; - case QtPlaceHolderTextColor: *pfg = decl.brushValue(pal); break; + case Color: *foreground = decl.brushValue(pal); break; + case QtSelectionForeground: *selectedForeground = decl.brushValue(pal); break; + case QtSelectionBackground: *selectedBackground = decl.brushValue(pal); break; + case QtAlternateBackground: *alternateBackground = decl.brushValue(pal); break; + case QtPlaceHolderTextColor: *placeHolderTextForeground = decl.brushValue(pal); break; + case QtAccentColor: *accentColor = decl.brushValue(pal); break; default: continue; } hit = true; diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index 8e4c7ce62d..20177312af 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -166,6 +166,7 @@ enum Property { WordSpacing, TextDecorationColor, QtPlaceHolderTextColor, + QtAccentColor, NumProperties }; @@ -823,7 +824,9 @@ struct Q_GUI_EXPORT ValueExtractor bool extractBox(int *margins, int *paddings, int *spacing = nullptr); bool extractBorder(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii); bool extractOutline(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii, int *offsets); - bool extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg, QBrush *pfg); + bool extractPalette(QBrush *foreground, QBrush *selectedForeground, QBrush *selectedBackground, + QBrush *alternateBackground, QBrush *placeHolderTextForeground, + QBrush *accentColor); int extractStyleFeatures(); bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size); bool extractIcon(QIcon *icon, QSize *size); diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index 0115285454..5315fe85d4 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -1358,6 +1358,13 @@ \li Description \row + \li \b{\c accent-color} + \li \l{#Brush}{Brush} \br + \li The property sets the \c AccentColor, which is used to emphasize + interactive UI elements. + If this property is not set, it defaults to the \c highlight color. + + \row \li \b{\c alternate-background-color} \target alternate-background-color-prop \li \l{#Brush}{Brush} \br \li The \l{QAbstractItemView::alternatingRowColors} @@ -3064,6 +3071,7 @@ \row \li \b{PaletteRole} \target PaletteRole \li \c alternate-base \br + | \c accentColor \br | \c base \br | \c bright-text \br | \c button \br diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index c2a720c433..5d0432d2e0 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -434,16 +434,26 @@ struct QStyleSheetBoxData : public QSharedData struct QStyleSheetPaletteData : public QSharedData { - QStyleSheetPaletteData(const QBrush &fg, const QBrush &sfg, const QBrush &sbg, - const QBrush &abg, const QBrush &pfg) - : foreground(fg), selectionForeground(sfg), selectionBackground(sbg), - alternateBackground(abg), placeholderForeground(pfg) { } + QStyleSheetPaletteData(const QBrush &foreground, + const QBrush &selectedForeground, + const QBrush &selectedBackground, + const QBrush &alternateBackground, + const QBrush &placeHolderTextForeground, + const QBrush &accentColor) + : foreground(foreground) + , selectionForeground(selectedForeground) + , selectionBackground(selectedBackground) + , alternateBackground(alternateBackground) + , placeholderForeground(placeHolderTextForeground) + , accentColor(accentColor) + { } QBrush foreground; QBrush selectionForeground; QBrush selectionBackground; QBrush alternateBackground; QBrush placeholderForeground; + QBrush accentColor; }; struct QStyleSheetGeometryData : public QSharedData @@ -955,10 +965,17 @@ QRenderRule::QRenderRule(const QList<Declaration> &declarations, const QObject * bg = new QStyleSheetBackgroundData(brush, pixmap, repeat, alignment, origin, attachment, clip); } - QBrush sfg, fg, pfg; - QBrush sbg, abg; - if (v.extractPalette(&fg, &sfg, &sbg, &abg, &pfg)) - pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg, pfg); + QBrush foreground; + QBrush selectedForeground; + QBrush selectedBackground; + QBrush alternateBackground; + QBrush placeHolderTextForeground; + QBrush accentColor; + if (v.extractPalette(&foreground, &selectedForeground, &selectedBackground, + &alternateBackground, &placeHolderTextForeground, &accentColor)) { + pal = new QStyleSheetPaletteData(foreground, selectedForeground, selectedBackground, + alternateBackground, placeHolderTextForeground, accentColor); + } QIcon imgIcon; alignment = Qt::AlignCenter; @@ -1487,6 +1504,8 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q p->setBrush(cg, QPalette::AlternateBase, pal->alternateBackground); if (pal->placeholderForeground.style() != Qt::NoBrush) p->setBrush(cg, QPalette::PlaceholderText, pal->placeholderForeground); + if (pal->accentColor.style() != Qt::NoBrush) + p->setBrush(cg, QPalette::AccentColor, pal->accentColor); } bool QRenderRule::hasModification() const |