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
This commit is contained in:
Daniel Bermond
2021-10-03 14:18:23 +03:00
committed by GitHub
parent 79e5dd65be
commit 7b10ea6d64
6 changed files with 13 additions and 11 deletions
+1 -1
View File
@@ -366,7 +366,7 @@ bool QHotkey::NativeShortcut::operator !=(QHotkey::NativeShortcut other) const
valid != other.valid; valid != other.valid;
} }
uint qHash(QHotkey::NativeShortcut key) QHOTKEY_HASH_SEED qHash(QHotkey::NativeShortcut key)
{ {
return qHash(key.key) ^ qHash(key.modifier); return qHash(key.key) ^ qHash(key.modifier);
} }
+1 -1
View File
@@ -120,7 +120,7 @@ private:
bool _registered; 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_HASH_SEED QHOTKEY_SHARED_EXPORT qHash(QHotkey::NativeShortcut key, QHOTKEY_HASH_SEED seed);
QHOTKEY_SHARED_EXPORT Q_DECLARE_LOGGING_CATEGORY(logQHotkey) QHOTKEY_SHARED_EXPORT Q_DECLARE_LOGGING_CATEGORY(logQHotkey)
+3 -3
View File
@@ -7,7 +7,7 @@ class QHotkeyPrivateMac : public QHotkeyPrivate
{ {
public: public:
// QAbstractNativeEventFilter interface // 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 hotkeyPressEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data);
static OSStatus hotkeyReleaseEventHandler(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; bool QHotkeyPrivateMac::isHotkeyHandlerRegistered = false;
QHash<QHotkey::NativeShortcut, EventHotKeyRef> QHotkeyPrivateMac::hotkeyRefs; QHash<QHotkey::NativeShortcut, EventHotKeyRef> 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(eventType)
Q_UNUSED(message) Q_UNUSED(message)
@@ -288,4 +288,4 @@ OSStatus QHotkeyPrivateMac::hotkeyReleaseEventHandler(EventHandlerCallRef nextHa
} }
return noErr; return noErr;
} }
+6
View File
@@ -7,6 +7,12 @@
#include <QMutex> #include <QMutex>
#include <QGlobalStatic> #include <QGlobalStatic>
#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 class QHOTKEY_SHARED_EXPORT QHotkeyPrivate : public QObject, public QAbstractNativeEventFilter
{ {
Q_OBJECT Q_OBJECT
+2 -2
View File
@@ -15,7 +15,7 @@ class QHotkeyPrivateWin : public QHotkeyPrivate
public: public:
QHotkeyPrivateWin(); QHotkeyPrivateWin();
// QAbstractNativeEventFilter interface // 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: protected:
void pollForHotkeyRelease(); void pollForHotkeyRelease();
@@ -42,7 +42,7 @@ bool QHotkeyPrivate::isPlatformSupported()
return true; 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(eventType)
Q_UNUSED(result) Q_UNUSED(result)
-4
View File
@@ -3,13 +3,9 @@
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
#include <QGuiApplication> #include <QGuiApplication>
#define _NATIVE_EVENT_RESULT qintptr
#else #else
#include <QDebug> #include <QDebug>
#include <QX11Info> #include <QX11Info>
#define _NATIVE_EVENT_RESULT long
#endif #endif
#include <QThreadStorage> #include <QThreadStorage>