From 773f9ab0189bbb439c3066695c947b11a20c484f Mon Sep 17 00:00:00 2001 From: Axel Spoerl Date: Thu, 23 Nov 2023 12:02:20 +0100 Subject: [PATCH] QMesageBox: add Q_ENUM and sync assertions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Q_ENUM to StandardButton and ButtonRole. Add static assertion to enforce sync with QDialogButtonBox. Task-number: QTBUG-118489 Pick-to: 6.6 6.5 Change-Id: I38a7367d6287ab7fa5e5ca0c94ea6daa0f95fc52 Reviewed-by: Tor Arne Vestbø --- src/widgets/dialogs/qmessagebox.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h index 3498fb29c9..45e7a47cb8 100644 --- a/src/widgets/dialogs/qmessagebox.h +++ b/src/widgets/dialogs/qmessagebox.h @@ -6,6 +6,7 @@ #include #include +#include QT_REQUIRE_CONFIG(messagebox); @@ -64,6 +65,10 @@ public: NRoles }; + Q_ENUM(ButtonRole) + static_assert(static_cast(ButtonRole::NRoles) == + static_cast(QDialogButtonBox::ButtonRole::NRoles), + "QMessageBox::ButtonRole and QDialogButtonBox::ButtonRole out of sync!"); enum StandardButton { // keep this in sync with QDialogButtonBox::StandardButton and QPlatformDialogHelper::StandardButton @@ -98,6 +103,12 @@ public: FlagMask = 0x00000300, // obsolete ButtonMask = ~FlagMask // obsolete }; + Q_ENUM(StandardButton); + static_assert(static_cast(StandardButton::LastButton) == + static_cast(QDialogButtonBox::StandardButton::LastButton), + "QMessageBox::StandardButton and QDialogButtonBox::StandardButton out of sync!"); + + #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) typedef StandardButton Button; #endif