| | |
| | | } |
| | | |
| | | private: |
| | | Q_DISABLE_COPY_MOVE(WindowBarPrivate) |
| | | Q_DISABLE_COPY(WindowBarPrivate) |
| | | }; |
| | | |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) |
| | | WindowsRegistryKey::WindowsRegistryKey(HKEY parentHandle, QStringView subKey, |
| | | REGSAM permissions, REGSAM access) { |
| | | if (::RegOpenKeyExW(parentHandle, reinterpret_cast<const wchar_t *>(subKey.utf16()), 0, |
| | | permissions | access, &m_key) != ERROR_SUCCESS) { |
| | | m_key = nullptr; |
| | | } |
| | | } |
| | | |
| | | WindowsRegistryKey::~WindowsRegistryKey() { |
| | | close(); |
| | | } |
| | | |
| | | void WindowsRegistryKey::close() { |
| | | if (isValid()) { |
| | | ::RegCloseKey(m_key); |
| | | m_key = nullptr; |
| | | } |
| | | } |
| | | |
| | | QString WindowsRegistryKey::stringValue(QStringView subKey) const { |
| | | QString result; |
| | | if (!isValid()) |
| | | return result; |
| | | DWORD type; |
| | | DWORD size; |
| | | auto subKeyC = reinterpret_cast<const wchar_t *>(subKey.utf16()); |
| | | if (::RegQueryValueExW(m_key, subKeyC, nullptr, &type, nullptr, &size) != ERROR_SUCCESS || |
| | | (type != REG_SZ && type != REG_EXPAND_SZ) || size <= 2) { |
| | | return result; |
| | | } |
| | | // Reserve more for rare cases where trailing '\0' are missing in registry. |
| | | // Rely on 0-termination since strings of size 256 padded with 0 have been |
| | | // observed (QTBUG-84455). |
| | | size += 2; |
| | | QVarLengthArray<unsigned char> buffer(static_cast<int>(size)); |
| | | std::fill(buffer.data(), buffer.data() + size, 0u); |
| | | if (::RegQueryValueExW(m_key, subKeyC, nullptr, &type, buffer.data(), &size) == |
| | | ERROR_SUCCESS) |
| | | result = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(buffer.constData())); |
| | | return result; |
| | | } |
| | | |
| | | QPair<DWORD, bool> WindowsRegistryKey::dwordValue(QStringView subKey) const { |
| | | if (!isValid()) |
| | | return qMakePair(0, false); |
| | | DWORD type; |
| | | auto subKeyC = reinterpret_cast<const wchar_t *>(subKey.utf16()); |
| | | if (::RegQueryValueExW(m_key, subKeyC, nullptr, &type, nullptr, nullptr) != ERROR_SUCCESS || |
| | | type != REG_DWORD) { |
| | | return qMakePair(0, false); |
| | | } |
| | | DWORD value = 0; |
| | | DWORD size = sizeof(value); |
| | | const bool ok = |
| | | ::RegQueryValueExW(m_key, subKeyC, nullptr, nullptr, |
| | | reinterpret_cast<unsigned char *>(&value), &size) == ERROR_SUCCESS; |
| | | return qMakePair(value, ok); |
| | | } |
| | | #endif |
| | | |
| | | } |
| | |
| | | #include <QtCore/qt_windows.h> |
| | | #include <QtCore/qglobal.h> |
| | | |
| | | #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) |
| | | # include <QtCore/private/qwinregistry_p.h> |
| | | #endif |
| | | |
| | | #include <QWKCore/qwkglobal.h> |
| | | |
| | | #ifndef GET_X_LPARAM |
| | |
| | | } |
| | | |
| | | // |
| | | // Registry Helpers |
| | | // |
| | | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) |
| | | class QWK_CORE_EXPORT WindowsRegistryKey { |
| | | public: |
| | | WindowsRegistryKey(HKEY parentHandle, QStringView subKey, REGSAM permissions = KEY_READ, |
| | | REGSAM access = 0); |
| | | |
| | | ~WindowsRegistryKey(); |
| | | |
| | | inline bool isValid() const; |
| | | |
| | | void close(); |
| | | QString stringValue(QStringView subKey) const; |
| | | QPair<DWORD, bool> dwordValue(QStringView subKey) const; |
| | | |
| | | private: |
| | | HKEY m_key; |
| | | |
| | | Q_DISABLE_COPY(WindowsRegistryKey) |
| | | }; |
| | | |
| | | inline bool WindowsRegistryKey::isValid() const { |
| | | return m_key != nullptr; |
| | | } |
| | | #else |
| | | using WindowsRegistryKey = QWinRegistryKey; |
| | | #endif |
| | | |
| | | // |
| | | // Version Helpers |
| | | // |
| | | |
| | |
| | | #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 |
| | | }; |
| | | |
| | |
| | | |
| | | ~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 {}; |
| | | } |
| | |
| | | static WindowContextFactoryMethod windowContextFactoryMethod; |
| | | |
| | | private: |
| | | Q_DISABLE_COPY_MOVE(WindowAgentBasePrivate) |
| | | Q_DISABLE_COPY(WindowAgentBasePrivate) |
| | | }; |
| | | |
| | | } |
| | |
| | | Q_INVOKABLE void setHitTestVisible(const QQuickItem *item, bool visible = true); |
| | | |
| | | #ifdef Q_OS_MAC |
| | | // The system button area APIs are experimental, may be changed in the future. |
| | | // The system button area APIs are experimental, very likely to change in the future. |
| | | Q_INVOKABLE QQuickItem *systemButtonArea() const; |
| | | Q_INVOKABLE void setSystemButtonArea(QQuickItem *item); |
| | | |
| | |
| | | void setSystemButton(SystemButton button, QWidget *w); |
| | | |
| | | #ifdef Q_OS_MAC |
| | | // The system button area APIs are experimental, may be changed in the future. |
| | | // The system button area APIs are experimental, very likely to change in the future. |
| | | QWidget *systemButtonArea() const; |
| | | void setSystemButtonArea(QWidget *widget); |
| | | |