summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanthosh Kumar <[email protected]>2023-08-16 13:56:29 +0200
committerSanthosh Kumar <[email protected]>2023-08-18 00:38:38 +0200
commit90980a54e87147ae59ed0628f8b1de67d98ecae4 (patch)
tree344915686a6acc4845bd3a615f8816f5b9d6b9d2
parent7c55651ff2537fdc9b7c8667aff38d98c0cd9b65 (diff)
Rename accent color in QPalette
Accent color role has been renamed according to name rule of other color roles in QPalette. Fixes: QTBUG-116107 Pick-to: 6.6 Change-Id: I70ac98a1e97afbdc7ea5f8d79f808c307e170712 Reviewed-by: Mitch Curtis <[email protected]>
-rw-r--r--src/gui/kernel/qpalette.cpp18
-rw-r--r--src/gui/kernel/qpalette.h6
-rw-r--r--src/gui/kernel/qplatformtheme.cpp6
-rw-r--r--src/gui/text/qcssparser.cpp6
-rw-r--r--src/gui/text/qcssparser_p.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm2
-rw-r--r--src/plugins/platforms/ios/qiostheme.mm2
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp8
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc4
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp16
-rw-r--r--tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp4
-rw-r--r--tests/auto/gui/kernel/qpalette/tst_qpalette.cpp12
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp4
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp6
14 files changed, 49 insertions, 49 deletions
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 1cd4257b1ad..a949fe922de 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -13,15 +13,15 @@ QT_BEGIN_NAMESPACE
constexpr QPalette::ResolveMask QPalettePrivate::colorRoleOffset(QPalette::ColorGroup colorGroup)
{
- // Exclude NoRole; that bit is used for AccentColor
+ // Exclude NoRole; that bit is used for Accent
return (qToUnderlying(QPalette::NColorRoles) - 1) * qToUnderlying(colorGroup);
}
constexpr QPalette::ResolveMask QPalettePrivate::bitPosition(QPalette::ColorGroup colorGroup,
QPalette::ColorRole colorRole)
{
- // Map AccentColor into NoRole for resolving purposes
- if (colorRole == QPalette::AccentColor)
+ // Map Accent into NoRole for resolving purposes
+ if (colorRole == QPalette::Accent)
colorRole = QPalette::NoRole;
return colorRole + colorRoleOffset(colorGroup);
@@ -74,12 +74,12 @@ static void qt_ensure_default_accent_color(QPalette &pal)
// Act only for color groups where no accent color is set
for (int i = 0; i < QPalette::NColorGroups; ++i) {
const QPalette::ColorGroup group = static_cast<QPalette::ColorGroup>(i);
- if (!pal.isBrushSet(group, QPalette::AccentColor)) {
+ if (!pal.isBrushSet(group, QPalette::Accent)) {
// Default to highlight if available, otherwise use a shade of base
const QBrush accentBrush = pal.isBrushSet(group, QPalette::Highlight)
? pal.brush(group, QPalette::Highlight)
: pal.brush(group, QPalette::Base).color().lighter(lighter);
- pal.setBrush(group, QPalette::AccentColor, accentBrush);
+ pal.setBrush(group, QPalette::Accent, accentBrush);
}
}
}
@@ -509,7 +509,7 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button)
item. By default, the highlight color is
Qt::darkBlue.
- \value [since 6.6] AccentColor
+ \value [since 6.6] Accent
A color that typically contrasts or complements
Base, Window and Button colors. It usually represents
the users' choice of desktop personalisation.
@@ -983,7 +983,7 @@ QPalette QPalette::resolve(const QPalette &other) const
palette.detach();
for (int role = 0; role < int(NColorRoles); ++role) {
- // Don't resolve NoRole, its bits are needed for AccentColor (see bitPosition)
+ // Don't resolve NoRole, its bits are needed for Accent (see bitPosition)
if (role == NoRole)
continue;
@@ -1122,9 +1122,9 @@ QDataStream &operator>>(QDataStream &s, QPalette &p)
p.setBrush(group, (QPalette::ColorRole)role, tmp);
}
- // AccentColor defaults to Highlight for stream versions that don't have it.
+ // Accent defaults to Highlight for stream versions that don't have it.
if (s.version() < QDataStream::Qt_6_6)
- p.setBrush(group, QPalette::AccentColor, p.brush(group, QPalette::Highlight));
+ p.setBrush(group, QPalette::Accent, p.brush(group, QPalette::Highlight));
}
}
diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h
index 92d2502afe8..7f05129a2c8 100644
--- a/src/gui/kernel/qpalette.h
+++ b/src/gui/kernel/qpalette.h
@@ -55,8 +55,8 @@ public:
NoRole,
ToolTipBase, ToolTipText,
PlaceholderText,
- AccentColor,
- NColorRoles = AccentColor + 1,
+ Accent,
+ NColorRoles = Accent + 1,
};
Q_ENUM(ColorRole)
@@ -99,7 +99,7 @@ public:
inline const QBrush &link() const { return brush(Link); }
inline const QBrush &linkVisited() const { return brush(LinkVisited); }
inline const QBrush &placeholderText() const { return brush(PlaceholderText); }
- inline const QBrush &accentColor() const { return brush(AccentColor); }
+ inline const QBrush &accent() const { return brush(Accent); }
bool operator==(const QPalette &p) const;
inline bool operator!=(const QPalette &p) const { return !(operator==(p)); }
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 938a0dab729..f7f547097bc 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -395,9 +395,9 @@ Q_GUI_EXPORT QPalette qt_fusionPalette()
fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, highlight);
fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, disabledHighlight);
- fusionPalette.setBrush(QPalette::Active, QPalette::AccentColor, highlight);
- fusionPalette.setBrush(QPalette::Inactive, QPalette::AccentColor, highlight);
- fusionPalette.setBrush(QPalette::Disabled, QPalette::AccentColor, disabledHighlight);
+ fusionPalette.setBrush(QPalette::Active, QPalette::Accent, highlight);
+ fusionPalette.setBrush(QPalette::Inactive, QPalette::Accent, highlight);
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Accent, disabledHighlight);
fusionPalette.setBrush(QPalette::PlaceholderText, placeholder);
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 02d99a82edf..2082263d7c0 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -47,7 +47,7 @@ static const QCssKnownValue properties[NumProperties - 1] = {
{ "-qt-style-features", QtStyleFeatures },
{ "-qt-table-type", QtTableType },
{ "-qt-user-state", QtUserState },
- { "accent-color", QtAccentColor },
+ { "accent-color", QtAccent },
{ "alternate-background-color", QtAlternateBackground },
{ "background", Background },
{ "background-attachment", BackgroundAttachment },
@@ -1347,7 +1347,7 @@ bool ValueExtractor::extractPalette(QBrush *foreground,
QBrush *selectedBackground,
QBrush *alternateBackground,
QBrush *placeHolderTextForeground,
- QBrush *accentColor)
+ QBrush *accent)
{
bool hit = false;
for (int i = 0; i < declarations.size(); ++i) {
@@ -1358,7 +1358,7 @@ bool ValueExtractor::extractPalette(QBrush *foreground,
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;
+ case QtAccent: *accent = 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 20177312af8..1369bdf162f 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -166,7 +166,7 @@ enum Property {
WordSpacing,
TextDecorationColor,
QtPlaceHolderTextColor,
- QtAccentColor,
+ QtAccent,
NumProperties
};
@@ -826,7 +826,7 @@ struct Q_GUI_EXPORT ValueExtractor
bool extractOutline(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii, int *offsets);
bool extractPalette(QBrush *foreground, QBrush *selectedForeground, QBrush *selectedBackground,
QBrush *alternateBackground, QBrush *placeHolderTextForeground,
- QBrush *accentColor);
+ QBrush *accent);
int extractStyleFeatures();
bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size);
bool extractIcon(QIcon *icon, QSize *size);
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index 3ef36ccd396..ac5bdf0ceb9 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -95,7 +95,7 @@ static QPalette *qt_mac_createSystemPalette()
palette->setColor(QPalette::Disabled, QPalette::PlaceholderText, qc);
qc = qt_mac_toQColor([NSColor controlAccentColor]);
- palette->setColor(QPalette::AccentColor, qc);
+ palette->setColor(QPalette::Accent, qc);
return palette;
}
diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm
index 3917378f012..4126ce8d1e4 100644
--- a/src/plugins/platforms/ios/qiostheme.mm
+++ b/src/plugins/platforms/ios/qiostheme.mm
@@ -71,7 +71,7 @@ void QIOSTheme::initializeSystemPalette()
s_systemPalette.setBrush(QPalette::HighlightedText, qt_mac_toQBrush(UIColor.labelColor.CGColor));
if (@available(ios 15.0, *))
- s_systemPalette.setBrush(QPalette::AccentColor, qt_mac_toQBrush(UIColor.tintColor.CGColor));
+ s_systemPalette.setBrush(QPalette::Accent, qt_mac_toQBrush(UIColor.tintColor.CGColor));
}
const QPalette *QIOSTheme::palette(QPlatformTheme::Palette type) const
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index 872c78bb8ef..febec34d683 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -277,7 +277,7 @@ static void populateLightSystemBasePalette(QPalette &result)
result.setColor(QPalette::Midlight, getSysColor(COLOR_3DLIGHT));
result.setColor(QPalette::Shadow, getSysColor(COLOR_3DDKSHADOW));
result.setColor(QPalette::HighlightedText, getSysColor(COLOR_HIGHLIGHTTEXT));
- result.setColor(QPalette::AccentColor, accent);
+ result.setColor(QPalette::Accent, accent);
result.setColor(QPalette::Link, linkColor);
result.setColor(QPalette::LinkVisited, accentDarkest);
@@ -351,7 +351,7 @@ static void populateDarkSystemBasePalette(QPalette &result)
result.setColor(QPalette::All, QPalette::ToolTipBase, buttonColor);
result.setColor(QPalette::All, QPalette::ToolTipText, foreground.darker(120));
result.setColor(QPalette::All, QPalette::PlaceholderText, placeHolderColor(foreground));
- result.setColor(QPalette::All, QPalette::AccentColor, accent);
+ result.setColor(QPalette::All, QPalette::Accent, accent);
}
static inline QPalette toolTipPalette(const QPalette &systemPalette, bool light)
@@ -591,7 +591,7 @@ QPalette QWindowsTheme::systemPalette(Qt::ColorScheme colorScheme)
result.color(QPalette::Inactive, QPalette::Window));
result.setColor(QPalette::Inactive, QPalette::HighlightedText,
result.color(QPalette::Inactive, QPalette::Text));
- result.setColor(QPalette::Inactive, QPalette::AccentColor,
+ result.setColor(QPalette::Inactive, QPalette::Accent,
result.color(QPalette::Inactive, QPalette::Window));
}
@@ -606,7 +606,7 @@ QPalette QWindowsTheme::systemPalette(Qt::ColorScheme colorScheme)
result.setColor(QPalette::Disabled, QPalette::ButtonText, disabled);
result.setColor(QPalette::Disabled, QPalette::Highlight, result.color(QPalette::Highlight));
result.setColor(QPalette::Disabled, QPalette::HighlightedText, result.color(QPalette::HighlightedText));
- result.setColor(QPalette::Disabled, QPalette::AccentColor, disabled);
+ result.setColor(QPalette::Disabled, QPalette::Accent, disabled);
result.setColor(QPalette::Disabled, QPalette::Base, result.window().color());
return result;
}
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
index fa48777c303..50e51505a66 100644
--- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
@@ -1345,7 +1345,7 @@
\row
\li \b{\c accent-color}
\li \l{#Brush}{Brush} \br
- \li The property sets the \c AccentColor, which is used to emphasize
+ \li The property sets the \c Accent, which is used to emphasize
interactive UI elements.
If this property is not set, it defaults to the \c highlight color.
@@ -3056,7 +3056,7 @@
\row
\li \b{PaletteRole} \target PaletteRole
\li \c alternate-base \br
- | \c accentColor \br
+ | \c accent \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 4c271996c5b..e3ca85d29e4 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -439,13 +439,13 @@ struct QStyleSheetPaletteData : public QSharedData
const QBrush &selectedBackground,
const QBrush &alternateBackground,
const QBrush &placeHolderTextForeground,
- const QBrush &accentColor)
+ const QBrush &accent)
: foreground(foreground)
, selectionForeground(selectedForeground)
, selectionBackground(selectedBackground)
, alternateBackground(alternateBackground)
, placeholderForeground(placeHolderTextForeground)
- , accentColor(accentColor)
+ , accent(accent)
{ }
QBrush foreground;
@@ -453,7 +453,7 @@ struct QStyleSheetPaletteData : public QSharedData
QBrush selectionBackground;
QBrush alternateBackground;
QBrush placeholderForeground;
- QBrush accentColor;
+ QBrush accent;
};
struct QStyleSheetGeometryData : public QSharedData
@@ -970,11 +970,11 @@ QRenderRule::QRenderRule(const QList<Declaration> &declarations, const QObject *
QBrush selectedBackground;
QBrush alternateBackground;
QBrush placeHolderTextForeground;
- QBrush accentColor;
+ QBrush accent;
if (v.extractPalette(&foreground, &selectedForeground, &selectedBackground,
- &alternateBackground, &placeHolderTextForeground, &accentColor)) {
+ &alternateBackground, &placeHolderTextForeground, &accent)) {
pal = new QStyleSheetPaletteData(foreground, selectedForeground, selectedBackground,
- alternateBackground, placeHolderTextForeground, accentColor);
+ alternateBackground, placeHolderTextForeground, accent);
}
QIcon imgIcon;
@@ -1514,8 +1514,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);
+ if (pal->accent.style() != Qt::NoBrush)
+ p->setBrush(cg, QPalette::Accent, pal->accent);
}
bool QRenderRule::hasModification() const
diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
index 1b2fb299443..80c18187d5d 100644
--- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
@@ -295,7 +295,7 @@ static int NColorRoles[] = {
QPalette::PlaceholderText + 1, // Qt_5_12
QPalette::PlaceholderText + 1, // Qt_5_13, Qt_5_14, Qt_5_15
QPalette::PlaceholderText + 1, // Qt_6_0
- QPalette::AccentColor + 1, // Qt_6_6
+ QPalette::Accent + 1, // Qt_6_6
0 // add the correct value for Qt_5_14 here later
};
@@ -2393,7 +2393,7 @@ void tst_QDataStream::setVersion()
*/
// revise the test if new color roles or color groups are added
- QCOMPARE(QPalette::NColorRoles, QPalette::AccentColor + 1);
+ QCOMPARE(QPalette::NColorRoles, QPalette::Accent + 1);
QCOMPARE(static_cast<int>(QPalette::NColorGroups), 3);
QByteArray ba2;
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
index bf9799724e1..e5f3e3d100a 100644
--- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
+++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
@@ -52,7 +52,7 @@ void tst_QPalette::roleValues_data()
QTest::newRow("QPalette::ToolTipBase") << int(QPalette::ToolTipBase) << 18;
QTest::newRow("QPalette::ToolTipText") << int(QPalette::ToolTipText) << 19;
QTest::newRow("QPalette::PlaceholderText") << int(QPalette::PlaceholderText) << 20;
- QTest::newRow("QPalette::AccentColor") << int(QPalette::AccentColor) << 21;
+ QTest::newRow("QPalette::Accent") << int(QPalette::Accent) << 21;
// Change this value as you add more roles.
QTest::newRow("QPalette::NColorRoles") << int(QPalette::NColorRoles) << 22;
@@ -355,9 +355,9 @@ void tst_QPalette::dataStream()
const QColor accent(13, 13, 13);
QPalette palette;
palette.setBrush(QPalette::Highlight, highlight);
- palette.setBrush(QPalette::AccentColor, accent);
+ palette.setBrush(QPalette::Accent, accent);
- // When saved with Qt_6_5 or earlier, AccentColor defaults to Highlight
+ // When saved with Qt_6_5 or earlier, Accent defaults to Highlight
{
QByteArray b;
{
@@ -369,10 +369,10 @@ void tst_QPalette::dataStream()
QDataStream stream (&b, QIODevice::ReadOnly);
stream.setVersion(QDataStream::Qt_6_5);
stream >> test;
- QCOMPARE(test.accentColor().color(), highlight);
+ QCOMPARE(test.accent().color(), highlight);
}
- // When saved with Qt_6_6 or later, AccentColor is saved explicitly
+ // When saved with Qt_6_6 or later, Accent is saved explicitly
{
QByteArray b;
{
@@ -384,7 +384,7 @@ void tst_QPalette::dataStream()
QDataStream stream (&b, QIODevice::ReadOnly);
stream.setVersion(QDataStream::Qt_6_6);
stream >> test;
- QCOMPARE(test.accentColor().color(), accent);
+ QCOMPARE(test.accent().color(), accent);
}
}
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
index 778c4a002e8..bb6ed1db91c 100644
--- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
@@ -1548,9 +1548,9 @@ void tst_QCssParser::gradient()
QBrush selectedBackground;
QBrush alternateBackground;
QBrush placeHolderTextForeground;
- QBrush accentColor;
+ QBrush accent;
QVERIFY(ve.extractPalette(&foreground, &selectedForeground, &selectedBackground,
- &alternateBackground, &placeHolderTextForeground, &accentColor));
+ &alternateBackground, &placeHolderTextForeground, &accent));
if (type == "linear") {
QCOMPARE(selectedBackground.style(), Qt::LinearGradientPattern);
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index ef26351b39f..55050e21982 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -106,7 +106,7 @@ private slots:
void QTBUG36933_brokenPseudoClassLookup();
void styleSheetChangeBeforePolish();
void placeholderColor();
- void accentColor();
+ void accent();
void enumPropertySelector_data();
void enumPropertySelector();
//at the end because it mess with the style.
@@ -2363,13 +2363,13 @@ void tst_QStyleSheetStyle::placeholderColor()
QCOMPARE(le1.palette().placeholderText().color(), QColor(phSpec));
}
-void tst_QStyleSheetStyle::accentColor()
+void tst_QStyleSheetStyle::accent()
{
QLineEdit lineEdit;
const QColor universe(42, 42, 42);
lineEdit.setStyleSheet(QString("QLineEdit { accent-color: %1; }").arg(universe.name()));
lineEdit.ensurePolished();
- QCOMPARE(lineEdit.palette().accentColor().color(), universe);
+ QCOMPARE(lineEdit.palette().accent().color(), universe);
}
void tst_QStyleSheetStyle::enumPropertySelector_data()