From b54e368f16e8bd977fe57fcc738fc6804af076e4 Mon Sep 17 00:00:00 2001 From: Zhao Yuhang <2546789017@qq.com> Date: 周一, 01 1月 2024 22:20:17 +0800 Subject: [PATCH] Update README --- src/core/shared/qwkwindowsextra_p.h | 76 +++++++++++-------------------------- 1 files changed, 23 insertions(+), 53 deletions(-) diff --git a/src/core/shared/qwkwindowsextra_p.h b/src/core/shared/qwkwindowsextra_p.h index 8ada487..6976b3c 100644 --- a/src/core/shared/qwkwindowsextra_p.h +++ b/src/core/shared/qwkwindowsextra_p.h @@ -1,3 +1,6 @@ +// Copyright (C) 2023-2024 Stdware Collections +// SPDX-License-Identifier: Apache-2.0 + #ifndef QWKWINDOWSEXTRA_P_H #define QWKWINDOWSEXTRA_P_H @@ -15,9 +18,7 @@ #include <timeapi.h> #include <QWKCore/qwindowkit_windows.h> - #include <QtCore/private/qsystemlibrary_p.h> -#include <QtCore/private/qwinregistry_p.h> #include <QtGui/QGuiApplication> #include <QtGui/QStyleHints> @@ -132,12 +133,14 @@ }; using PWINDOWCOMPOSITIONATTRIBDATA = WINDOWCOMPOSITIONATTRIBDATA *; - enum PREFERRED_APP_MODE - { - PAM_DEFAULT = 0, // Default behavior on systems before Win10 1809. It indicates the application doesn't support dark mode at all. - PAM_AUTO = 1, // Available since Win10 1809, let system decide whether to enable dark mode or not. + enum PREFERRED_APP_MODE { + PAM_DEFAULT = 0, // Default behavior on systems before Win10 1809. It indicates the + // application doesn't support dark mode at all. + PAM_AUTO = + 1, // Available since Win10 1809, let system decide whether to enable dark mode or not. PAM_DARK = 2, // Available since Win10 1903, force dark mode regardless of the system theme. - PAM_LIGHT = 3, // Available since Win10 1903, force light mode regardless of the system theme. + PAM_LIGHT = + 3, // Available since Win10 1903, force light mode regardless of the system theme. PAM_MAX = 4 }; @@ -170,6 +173,7 @@ DYNAMIC_API_DECLARE(DwmEnableBlurBehindWindow); DYNAMIC_API_DECLARE(GetDpiForWindow); DYNAMIC_API_DECLARE(GetSystemMetricsForDpi); + DYNAMIC_API_DECLARE(AdjustWindowRectExForDpi); DYNAMIC_API_DECLARE(GetDpiForMonitor); DYNAMIC_API_DECLARE(timeGetDevCaps); DYNAMIC_API_DECLARE(timeBeginPeriod); @@ -193,6 +197,7 @@ DYNAMIC_API_RESOLVE(user32, GetDpiForWindow); DYNAMIC_API_RESOLVE(user32, GetSystemMetricsForDpi); DYNAMIC_API_RESOLVE(user32, SetWindowCompositionAttribute); + DYNAMIC_API_RESOLVE(user32, AdjustWindowRectExForDpi); QSystemLibrary shcore(QStringLiteral("shcore")); DYNAMIC_API_RESOLVE(shcore, GetDpiForMonitor); @@ -228,7 +233,7 @@ ~DynamicApis() = default; - Q_DISABLE_COPY_MOVE(DynamicApis) + Q_DISABLE_COPY(DynamicApis) }; } @@ -308,7 +313,7 @@ } static inline constexpr MARGINS qmargins2margins(const QMargins &qmargins) { - return MARGINS{qmargins.left(), qmargins.right(), qmargins.top(), qmargins.bottom()}; + return {qmargins.left(), qmargins.right(), qmargins.top(), qmargins.bottom()}; } static inline /*constexpr*/ QString hwnd2str(const WId windowId) { @@ -320,41 +325,6 @@ static inline /*constexpr*/ QString hwnd2str(HWND hwnd) { // NULL handle is allowed here. return hwnd2str(reinterpret_cast<WId>(hwnd)); - } - - static inline bool isWin8OrGreater() { - static const bool result = IsWindows8OrGreater_Real(); - return result; - } - - static inline bool isWin8Point1OrGreater() { - static const bool result = IsWindows8Point1OrGreater_Real(); - return result; - } - - static inline bool isWin10OrGreater() { - static const bool result = IsWindows10OrGreater_Real(); - return result; - } - - static inline bool isWin101809OrGreater() { - static const bool result = IsWindows101809OrGreater_Real(); - return result; - } - - static inline bool isWin101903OrGreater() { - static const bool result = IsWindows101903OrGreater_Real(); - return result; - } - - static inline bool isWin11OrGreater() { - static const bool result = IsWindows11OrGreater_Real(); - return result; - } - - static inline bool isWin1122H2OrGreater() { - static const bool result = IsWindows1122H2OrGreater_Real(); - return result; } static inline bool isDwmCompositionEnabled() { @@ -370,11 +340,11 @@ } static inline bool isWindowFrameBorderColorized() { - const QWinRegistryKey registry(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\DWM)"); + WindowsRegistryKey registry(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\DWM)"); if (!registry.isValid()) { return false; } - const auto value = registry.dwordValue(L"ColorPrevalence"); + auto value = registry.dwordValue(L"ColorPrevalence"); if (!value.second) { return false; } @@ -392,12 +362,12 @@ #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) return QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark; #else - const QWinRegistryKey registry( + WindowsRegistryKey registry( HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)"); if (!registry.isValid()) { return false; } - const auto value = registry.dwordValue(L"AppsUseLightTheme"); + auto value = registry.dwordValue(L"AppsUseLightTheme"); if (!value.second) { return false; } @@ -423,21 +393,21 @@ #if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) return QGuiApplication::palette().color(QPalette::Accent); #else - const QWinRegistryKey registry(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\DWM)"); + WindowsRegistryKey registry(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\DWM)"); if (!registry.isValid()) { return {}; } - const auto value = registry.dwordValue(L"AccentColor"); + auto value = registry.dwordValue(L"AccentColor"); if (!value.second) { return {}; } // The retrieved value is in the #AABBGGRR format, we need to // convert it to the #AARRGGBB format which Qt expects. - const QColor abgr = QColor::fromRgba(value.first); - if (!abgr.isValid()) { + QColor color = QColor::fromRgba(value.first); + if (!color.isValid()) { return {}; } - return QColor::fromRgb(abgr.blue(), abgr.green(), abgr.red(), abgr.alpha()); + return QColor::fromRgb(color.blue(), color.green(), color.red(), color.alpha()); #endif } -- Gitblit v1.9.1