QLayoutPolicy: fix annoying -Wdeprecated-enum-enum-conversion
Says GCC -std=c++20: src/gui/util/qlayoutpolicy_p.h:127:30: warning: bitwise operation between different enumeration types ‘QLayoutPolicy::Policy’ and ‘QLayoutPolicy::PolicyFlag’ is deprecated [-Wdeprecated-enum-enum-conversion] 127 | if (verticalPolicy() & ExpandFlag) | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ Fix by making Policy a QFlags<PolicyFlag>, which we can do because the class is private. In QSizePolicy, this would break BC. Since a QFlags cannot be opened for constants like an enum, we need to define the ex-Policy-enumerators as static inline constexpr objects instead. Pick-to: 6.2 Change-Id: I29bc938f86508deed3f99ad9d1c1892547206c05 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
2d2104da7c
commit
020191d2ef
@ -67,7 +67,6 @@ class QVariant;
|
||||
class QLayoutPolicy
|
||||
{
|
||||
Q_GADGET_EXPORT(Q_GUI_EXPORT)
|
||||
Q_ENUMS(Policy)
|
||||
|
||||
public:
|
||||
enum PolicyFlag {
|
||||
@ -76,16 +75,16 @@ public:
|
||||
ShrinkFlag = 4,
|
||||
IgnoreFlag = 8
|
||||
};
|
||||
Q_DECLARE_FLAGS(Policy, PolicyFlag)
|
||||
Q_FLAG(Policy)
|
||||
|
||||
enum Policy {
|
||||
Fixed = 0,
|
||||
Minimum = GrowFlag,
|
||||
Maximum = ShrinkFlag,
|
||||
Preferred = GrowFlag | ShrinkFlag,
|
||||
MinimumExpanding = GrowFlag | ExpandFlag,
|
||||
Expanding = GrowFlag | ShrinkFlag | ExpandFlag,
|
||||
Ignored = ShrinkFlag | GrowFlag | IgnoreFlag
|
||||
};
|
||||
static constexpr inline Policy Fixed = {};
|
||||
static constexpr inline Policy Minimum = GrowFlag;
|
||||
static constexpr inline Policy Maximum = ShrinkFlag;
|
||||
static constexpr inline Policy Preferred = Minimum | Maximum;
|
||||
static constexpr inline Policy MinimumExpanding = Minimum | ExpandFlag;
|
||||
static constexpr inline Policy Expanding = Preferred | ExpandFlag;
|
||||
static constexpr inline Policy Ignored = Preferred | IgnoreFlag;
|
||||
|
||||
enum ControlType {
|
||||
DefaultType = 0x00000001,
|
||||
@ -169,6 +168,7 @@ private:
|
||||
};
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QLayoutPolicy::Policy)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QLayoutPolicy::ControlTypes)
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
|
Loading…
x
Reference in New Issue
Block a user