summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-10-13 21:27:58 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-10-14 23:43:38 +0200
commit2cc8d801aace8cd8983751ede23ea6a052d72aac (patch)
tree5374856e02dac96d58ca52735309eec483b5226c /src/gui/kernel
parent63790184c79d2765ea726488726cd9f2b43b91d1 (diff)
Unwrap private QPalette data member
Following 556511f9f39ddc887481e0cd5a877134ceb0da6b, there is only one data member in addition to the shared QPalettePrivate, so we don't need a data struct anymore. Change-Id: I8d7f33ed042e47464eb5f60a048956f8bf70e0b9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qpalette.cpp14
-rw-r--r--src/gui/kernel/qpalette.h13
2 files changed, 12 insertions, 15 deletions
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 7860b1f597..da418c7eed 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -669,7 +669,7 @@ QPalette::QPalette(const QColor &button, const QColor &window)
This constructor is fast thanks to \l{implicit sharing}.
*/
QPalette::QPalette(const QPalette &p)
- : d(p.d), data(p.data)
+ : d(p.d), currentGroup(p.currentGroup)
{
d->ref.ref();
}
@@ -709,7 +709,7 @@ void QPalette::init()
QPalette &QPalette::operator=(const QPalette &p)
{
p.d->ref.ref();
- data = p.data;
+ currentGroup = p.currentGroup;
if (d && !d->ref.deref())
delete d;
d = p.d;
@@ -754,7 +754,7 @@ const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const
Q_ASSERT(cr < NColorRoles);
if(gr >= (int)NColorGroups) {
if(gr == Current) {
- gr = data.currentGroup;
+ gr = currentGroup;
} else {
qWarning("QPalette::brush: Unknown ColorGroup: %d", (int)gr);
gr = Active;
@@ -792,7 +792,7 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b)
}
if (cg == Current) {
- cg = data.currentGroup;
+ cg = currentGroup;
} else if (cg >= NColorGroups) {
qWarning("QPalette::setBrush: Unknown ColorGroup: %d", cg);
cg = Active;
@@ -823,7 +823,7 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b)
bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const
{
if (cg == Current)
- cg = data.currentGroup;
+ cg = currentGroup;
if (cg >= NColorGroups) {
qWarning() << "Wrong color group:" << cg;
@@ -901,7 +901,7 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2)
{
if(group1 >= (int)NColorGroups) {
if(group1 == Current) {
- group1 = data.currentGroup;
+ group1 = currentGroup;
} else {
qWarning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1);
group1 = Active;
@@ -909,7 +909,7 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2)
}
if(group2 >= (int)NColorGroups) {
if(group2 == Current) {
- group2 = data.currentGroup;
+ group2 = currentGroup;
} else {
qWarning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2);
group2 = Active;
diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h
index 8b291dec58..776d489d44 100644
--- a/src/gui/kernel/qpalette.h
+++ b/src/gui/kernel/qpalette.h
@@ -68,13 +68,13 @@ public:
~QPalette();
QPalette &operator=(const QPalette &palette);
QPalette(QPalette &&other) noexcept
- : d(qExchange(other.d, nullptr)), data(other.data)
+ : d(qExchange(other.d, nullptr)), currentGroup(other.currentGroup)
{}
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPalette)
void swap(QPalette &other) noexcept
{
- qSwap(data, other.data);
+ qSwap(currentGroup, other.currentGroup);
qSwap(d, other.d);
}
@@ -95,8 +95,8 @@ public:
};
Q_ENUM(ColorRole)
- inline ColorGroup currentColorGroup() const { return data.currentGroup; }
- inline void setCurrentColorGroup(ColorGroup cg) { data.currentGroup = cg; }
+ inline ColorGroup currentColorGroup() const { return currentGroup; }
+ inline void setCurrentColorGroup(ColorGroup cg) { currentGroup = cg; }
inline const QColor &color(ColorGroup cg, ColorRole cr) const
{ return brush(cg, cr).color(); }
@@ -169,10 +169,7 @@ private:
void detach();
QPalettePrivate *d;
- struct Data {
- ColorGroup currentGroup{Active};
- };
- Data data;
+ ColorGroup currentGroup{Active};
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p);
};