| | |
| | | #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> |
| | |
| | | }; |
| | | 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. |
| | | 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. |
| | | 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_MAX = 4 |
| | | }; |
| | | |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | |
| | | ~DynamicApis() = default; |
| | | |
| | | Q_DISABLE_COPY_MOVE(DynamicApis) |
| | | Q_DISABLE_COPY(DynamicApis) |
| | | }; |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | static inline bool isWindowFrameBorderColorized() { |
| | | 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; |
| | | } |
| | |
| | | #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) |
| | | return QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark; |
| | | #else |
| | | QWinRegistryKey registry( |
| | | WindowsRegistryKey registry( |
| | | HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)"); |
| | | if (!registry.isValid()) { |
| | | return false; |
| | |
| | | #if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) |
| | | return QGuiApplication::palette().color(QPalette::Accent); |
| | | #else |
| | | QWinRegistryKey registry(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\DWM)"); |
| | | WindowsRegistryKey registry(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\DWM)"); |
| | | if (!registry.isValid()) { |
| | | return {}; |
| | | } |