From 87da6cb5dad576510b80991db88f4fe82338d807 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Thu, 13 Oct 2022 09:44:50 +0800 Subject: [PATCH] move static_assert to cpp source files To speed up compilation time. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- include/FramelessHelper/Core/framelesshelpercore_global.h | 3 +-- include/FramelessHelper/Core/private/framelessmanager_p.h | 2 +- include/FramelessHelper/Quick/framelesshelperquick_global.h | 2 +- src/core/framelesshelpercore_global.cpp | 4 ++++ src/core/utils_win.cpp | 4 ++-- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/FramelessHelper/Core/framelesshelpercore_global.h b/include/FramelessHelper/Core/framelesshelpercore_global.h index c64f77b..a2893fe 100644 --- a/include/FramelessHelper/Core/framelesshelpercore_global.h +++ b/include/FramelessHelper/Core/framelesshelpercore_global.h @@ -278,7 +278,7 @@ Q_ENUM_NS(SystemButtonType) #ifdef Q_OS_WINDOWS enum class DwmColorizationArea { - None_ = 0, // Avoid name conflicts with X11 headers. + None = 0, StartMenu_TaskBar_ActionCenter = 1, TitleBar_WindowBorder = 2, All = 3 @@ -579,7 +579,6 @@ struct SystemParameters {10, 0, 22000}, // Windows 11 Version 21H2 (21H2) {10, 0, 22621}, // Windows 11 Version 22H2 (22H2) }; -static_assert(std::size(WindowsVersions) == (static_cast(WindowsVersion::Latest) + 1)); #endif // Q_OS_WINDOWS struct VersionInfo diff --git a/include/FramelessHelper/Core/private/framelessmanager_p.h b/include/FramelessHelper/Core/private/framelessmanager_p.h index 5fd7801..c1c4b55 100644 --- a/include/FramelessHelper/Core/private/framelessmanager_p.h +++ b/include/FramelessHelper/Core/private/framelessmanager_p.h @@ -66,7 +66,7 @@ private: Global::SystemTheme m_systemTheme = Global::SystemTheme::Unknown; QColor m_accentColor = {}; #ifdef Q_OS_WINDOWS - Global::DwmColorizationArea m_colorizationArea = Global::DwmColorizationArea::None_; + Global::DwmColorizationArea m_colorizationArea = Global::DwmColorizationArea::None; #endif QString m_wallpaper = {}; Global::WallpaperAspectStyle m_wallpaperAspectStyle = Global::WallpaperAspectStyle::Fill; diff --git a/include/FramelessHelper/Quick/framelesshelperquick_global.h b/include/FramelessHelper/Quick/framelesshelperquick_global.h index 26539ad..fd390f6 100644 --- a/include/FramelessHelper/Quick/framelesshelperquick_global.h +++ b/include/FramelessHelper/Quick/framelesshelperquick_global.h @@ -116,7 +116,7 @@ public: #ifdef Q_OS_WINDOWS enum class DwmColorizationArea { - FRAMELESSHELPER_QUICK_ENUM_VALUE(DwmColorizationArea, None_) + FRAMELESSHELPER_QUICK_ENUM_VALUE(DwmColorizationArea, None) FRAMELESSHELPER_QUICK_ENUM_VALUE(DwmColorizationArea, StartMenu_TaskBar_ActionCenter) FRAMELESSHELPER_QUICK_ENUM_VALUE(DwmColorizationArea, TitleBar_WindowBorder) FRAMELESSHELPER_QUICK_ENUM_VALUE(DwmColorizationArea, All) diff --git a/src/core/framelesshelpercore_global.cpp b/src/core/framelesshelpercore_global.cpp index fcdb465..9a8ee78 100644 --- a/src/core/framelesshelpercore_global.cpp +++ b/src/core/framelesshelpercore_global.cpp @@ -78,6 +78,10 @@ Q_LOGGING_CATEGORY(lcCoreGlobal, "wangwenx190.framelesshelper.core.global") using namespace Global; +#ifdef Q_OS_WINDOWS +static_assert(std::size(WindowsVersions) == (static_cast(WindowsVersion::Latest) + 1)); +#endif + #ifdef Q_OS_LINUX [[maybe_unused]] static constexpr const char QT_QPA_ENV_VAR[] = "QT_QPA_PLATFORM"; FRAMELESSHELPER_BYTEARRAY_CONSTANT(xcb) diff --git a/src/core/utils_win.cpp b/src/core/utils_win.cpp index 8838b96..0f0b0f3 100644 --- a/src/core/utils_win.cpp +++ b/src/core/utils_win.cpp @@ -853,7 +853,7 @@ DwmColorizationArea Utils::getDwmColorizationArea() { // It's a Win10 only feature. (TO BE VERIFIED) if (!WindowsVersionHelper::isWin10OrGreater()) { - return DwmColorizationArea::None_; + return DwmColorizationArea::None; } const RegistryKey themeRegistry(RegistryRootKey::CurrentUser, personalizeRegistryKey()); const DWORD themeValue = themeRegistry.isValid() ? themeRegistry.value(qDwmColorKeyName).value_or(0) : 0; @@ -868,7 +868,7 @@ DwmColorizationArea Utils::getDwmColorizationArea() } else if (dwm) { return DwmColorizationArea::TitleBar_WindowBorder; } - return DwmColorizationArea::None_; + return DwmColorizationArea::None; } void Utils::showSystemMenu(const WId windowId, const QPoint &pos, const bool selectFirstEntry,