From 7b10ea6d64acb9d9f8ccd86b7bcd503435fcc844 Mon Sep 17 00:00:00 2001 From: Daniel Bermond Date: Sun, 3 Oct 2021 08:18:23 -0300 Subject: [PATCH] Qt6 support for Windows and Mac (#54) This follows commit 25f2184. On Windows, changing the return value of the qHash() variant that takes one argument fixes the following warning on MSVC 2019: qhotkey.cpp:(371,45): warning C4267: 'return': conversion from 'size_t' to 'uint', possible loss of data --- QHotkey/qhotkey.cpp | 2 +- QHotkey/qhotkey.h | 2 +- QHotkey/qhotkey_mac.cpp | 6 +++--- QHotkey/qhotkey_p.h | 6 ++++++ QHotkey/qhotkey_win.cpp | 4 ++-- QHotkey/qhotkey_x11.cpp | 4 ---- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/QHotkey/qhotkey.cpp b/QHotkey/qhotkey.cpp index e1ce190..3b76d9c 100644 --- a/QHotkey/qhotkey.cpp +++ b/QHotkey/qhotkey.cpp @@ -366,7 +366,7 @@ bool QHotkey::NativeShortcut::operator !=(QHotkey::NativeShortcut other) const valid != other.valid; } -uint qHash(QHotkey::NativeShortcut key) +QHOTKEY_HASH_SEED qHash(QHotkey::NativeShortcut key) { return qHash(key.key) ^ qHash(key.modifier); } diff --git a/QHotkey/qhotkey.h b/QHotkey/qhotkey.h index f21a2c8..c520ba3 100644 --- a/QHotkey/qhotkey.h +++ b/QHotkey/qhotkey.h @@ -120,7 +120,7 @@ private: bool _registered; }; -uint QHOTKEY_SHARED_EXPORT qHash(QHotkey::NativeShortcut key); +QHOTKEY_HASH_SEED QHOTKEY_SHARED_EXPORT qHash(QHotkey::NativeShortcut key); QHOTKEY_HASH_SEED QHOTKEY_SHARED_EXPORT qHash(QHotkey::NativeShortcut key, QHOTKEY_HASH_SEED seed); QHOTKEY_SHARED_EXPORT Q_DECLARE_LOGGING_CATEGORY(logQHotkey) diff --git a/QHotkey/qhotkey_mac.cpp b/QHotkey/qhotkey_mac.cpp index 0e06299..2cf0db4 100644 --- a/QHotkey/qhotkey_mac.cpp +++ b/QHotkey/qhotkey_mac.cpp @@ -7,7 +7,7 @@ class QHotkeyPrivateMac : public QHotkeyPrivate { public: // QAbstractNativeEventFilter interface - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; + bool nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result) override; static OSStatus hotkeyPressEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data); static OSStatus hotkeyReleaseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data); @@ -33,7 +33,7 @@ bool QHotkeyPrivate::isPlatformSupported() bool QHotkeyPrivateMac::isHotkeyHandlerRegistered = false; QHash QHotkeyPrivateMac::hotkeyRefs; -bool QHotkeyPrivateMac::nativeEventFilter(const QByteArray &eventType, void *message, long *result) +bool QHotkeyPrivateMac::nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result) { Q_UNUSED(eventType) Q_UNUSED(message) @@ -288,4 +288,4 @@ OSStatus QHotkeyPrivateMac::hotkeyReleaseEventHandler(EventHandlerCallRef nextHa } return noErr; -} \ No newline at end of file +} diff --git a/QHotkey/qhotkey_p.h b/QHotkey/qhotkey_p.h index b7c1721..d1bd1d2 100644 --- a/QHotkey/qhotkey_p.h +++ b/QHotkey/qhotkey_p.h @@ -7,6 +7,12 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + #define _NATIVE_EVENT_RESULT qintptr +#else + #define _NATIVE_EVENT_RESULT long +#endif + class QHOTKEY_SHARED_EXPORT QHotkeyPrivate : public QObject, public QAbstractNativeEventFilter { Q_OBJECT diff --git a/QHotkey/qhotkey_win.cpp b/QHotkey/qhotkey_win.cpp index a03b8c0..715b92e 100644 --- a/QHotkey/qhotkey_win.cpp +++ b/QHotkey/qhotkey_win.cpp @@ -15,7 +15,7 @@ class QHotkeyPrivateWin : public QHotkeyPrivate public: QHotkeyPrivateWin(); // QAbstractNativeEventFilter interface - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; + bool nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result) override; protected: void pollForHotkeyRelease(); @@ -42,7 +42,7 @@ bool QHotkeyPrivate::isPlatformSupported() return true; } -bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *message, long *result) +bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result) { Q_UNUSED(eventType) Q_UNUSED(result) diff --git a/QHotkey/qhotkey_x11.cpp b/QHotkey/qhotkey_x11.cpp index fc06c7a..ce408e6 100644 --- a/QHotkey/qhotkey_x11.cpp +++ b/QHotkey/qhotkey_x11.cpp @@ -3,13 +3,9 @@ #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) #include - - #define _NATIVE_EVENT_RESULT qintptr #else #include #include - - #define _NATIVE_EVENT_RESULT long #endif #include