summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-02-28 13:03:36 +0100
committerLiang Qi <liang.qi@qt.io>2017-02-28 13:03:36 +0100
commit1a4f0deeb44e2bfb107a22a714df3796ac1d0c20 (patch)
treeb1c8db2d1b742d25106225c80893e0b32f98fb15 /src/widgets/kernel
parentdb0064b767474a89bc72ea4374f477682983c5f4 (diff)
parent35fa30e65d26b9e4840cfa793ed8369b3475c1fd (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qsizepolicy.cpp11
-rw-r--r--src/widgets/kernel/qsizepolicy.h25
-rw-r--r--src/widgets/kernel/qwidget.cpp1
3 files changed, 25 insertions, 12 deletions
diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp
index a03523d2af..b08a9abb1e 100644
--- a/src/widgets/kernel/qsizepolicy.cpp
+++ b/src/widgets/kernel/qsizepolicy.cpp
@@ -255,6 +255,11 @@ QSizePolicy::ControlType QSizePolicy::controlType() const
*/
void QSizePolicy::setControlType(ControlType type)
{
+ bits.ctype = toControlTypeFieldValue(type);
+}
+
+quint32 QSizePolicy::toControlTypeFieldValue(ControlType type) Q_DECL_NOTHROW
+{
/*
The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10,
etc. In memory, we pack it onto the available bits (CTSize) in
@@ -271,10 +276,8 @@ void QSizePolicy::setControlType(ControlType type)
int i = 0;
while (true) {
- if (type & (0x1 << i)) {
- bits.ctype = i;
- return;
- }
+ if (type & (0x1 << i))
+ return i;
++i;
}
}
diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h
index 3ab672a8e8..83ce5853ab 100644
--- a/src/widgets/kernel/qsizepolicy.h
+++ b/src/widgets/kernel/qsizepolicy.h
@@ -119,18 +119,25 @@ public:
QT_SIZEPOLICY_CONSTEXPR QSizePolicy() : data(0) { }
+#ifdef Q_COMPILER_UNIFORM_INIT
+ QT_SIZEPOLICY_CONSTEXPR QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType)
+ : bits{0, 0, quint32(horizontal), quint32(vertical),
+ type == DefaultType ? 0 : toControlTypeFieldValue(type), 0, 0, 0}
+ {}
+#else
QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType)
: data(0) {
bits.horPolicy = horizontal;
bits.verPolicy = vertical;
setControlType(type);
}
+#endif // uniform-init
QT_SIZEPOLICY_CONSTEXPR Policy horizontalPolicy() const { return static_cast<Policy>(bits.horPolicy); }
QT_SIZEPOLICY_CONSTEXPR Policy verticalPolicy() const { return static_cast<Policy>(bits.verPolicy); }
ControlType controlType() const;
- void setHorizontalPolicy(Policy d) { bits.horPolicy = d; }
- void setVerticalPolicy(Policy d) { bits.verPolicy = d; }
+ Q_DECL_RELAXED_CONSTEXPR void setHorizontalPolicy(Policy d) { bits.horPolicy = d; }
+ Q_DECL_RELAXED_CONSTEXPR void setVerticalPolicy(Policy d) { bits.verPolicy = d; }
void setControlType(ControlType type);
QT_SIZEPOLICY_CONSTEXPR Qt::Orientations expandingDirections() const {
@@ -138,9 +145,9 @@ public:
| ( (horizontalPolicy() & ExpandFlag) ? Qt::Horizontal : Qt::Orientations() ) ;
}
- void setHeightForWidth(bool b) { bits.hfw = b; }
+ Q_DECL_RELAXED_CONSTEXPR void setHeightForWidth(bool b) { bits.hfw = b; }
QT_SIZEPOLICY_CONSTEXPR bool hasHeightForWidth() const { return bits.hfw; }
- void setWidthForHeight(bool b) { bits.wfh = b; }
+ Q_DECL_RELAXED_CONSTEXPR void setWidthForHeight(bool b) { bits.wfh = b; }
QT_SIZEPOLICY_CONSTEXPR bool hasWidthForHeight() const { return bits.wfh; }
QT_SIZEPOLICY_CONSTEXPR bool operator==(const QSizePolicy& s) const { return data == s.data; }
@@ -152,13 +159,13 @@ public:
QT_SIZEPOLICY_CONSTEXPR int horizontalStretch() const { return static_cast<int>(bits.horStretch); }
QT_SIZEPOLICY_CONSTEXPR int verticalStretch() const { return static_cast<int>(bits.verStretch); }
- void setHorizontalStretch(int stretchFactor) { bits.horStretch = static_cast<quint32>(qBound(0, stretchFactor, 255)); }
- void setVerticalStretch(int stretchFactor) { bits.verStretch = static_cast<quint32>(qBound(0, stretchFactor, 255)); }
+ Q_DECL_RELAXED_CONSTEXPR void setHorizontalStretch(int stretchFactor) { bits.horStretch = static_cast<quint32>(qBound(0, stretchFactor, 255)); }
+ Q_DECL_RELAXED_CONSTEXPR void setVerticalStretch(int stretchFactor) { bits.verStretch = static_cast<quint32>(qBound(0, stretchFactor, 255)); }
QT_SIZEPOLICY_CONSTEXPR bool retainSizeWhenHidden() const { return bits.retainSizeWhenHidden; }
- void setRetainSizeWhenHidden(bool retainSize) { bits.retainSizeWhenHidden = retainSize; }
+ Q_DECL_RELAXED_CONSTEXPR void setRetainSizeWhenHidden(bool retainSize) { bits.retainSizeWhenHidden = retainSize; }
- void transpose() { *this = transposed(); }
+ Q_DECL_RELAXED_CONSTEXPR void transpose() { *this = transposed(); }
#ifndef Q_QDOC
QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT
#endif
@@ -176,6 +183,8 @@ private:
struct Bits;
QT_SIZEPOLICY_CONSTEXPR explicit QSizePolicy(Bits b) Q_DECL_NOTHROW : bits(b) { }
+ static quint32 toControlTypeFieldValue(ControlType type) Q_DECL_NOTHROW;
+
struct Bits {
quint32 horStretch : 8;
quint32 verStretch : 8;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 2ced12fb7d..cf9fbe2572 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -9190,6 +9190,7 @@ bool QWidget::event(QEvent *event)
const QWindow *win = te->window;
d->setWinId((win && win->handle()) ? win->handle()->winId() : 0);
}
+ d->updateFont(d->data.fnt);
#ifndef QT_NO_OPENGL
d->renderToTextureReallyDirty = 1;
#endif