Skip to content

Commit 7b10ea6

Browse files
authored
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
1 parent 79e5dd6 commit 7b10ea6

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

QHotkey/qhotkey.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ bool QHotkey::NativeShortcut::operator !=(QHotkey::NativeShortcut other) const
366366
valid != other.valid;
367367
}
368368

369-
uint qHash(QHotkey::NativeShortcut key)
369+
QHOTKEY_HASH_SEED qHash(QHotkey::NativeShortcut key)
370370
{
371371
return qHash(key.key) ^ qHash(key.modifier);
372372
}

QHotkey/qhotkey.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public slots:
120120
bool _registered;
121121
};
122122

123-
uint QHOTKEY_SHARED_EXPORT qHash(QHotkey::NativeShortcut key);
123+
QHOTKEY_HASH_SEED QHOTKEY_SHARED_EXPORT qHash(QHotkey::NativeShortcut key);
124124
QHOTKEY_HASH_SEED QHOTKEY_SHARED_EXPORT qHash(QHotkey::NativeShortcut key, QHOTKEY_HASH_SEED seed);
125125

126126
QHOTKEY_SHARED_EXPORT Q_DECLARE_LOGGING_CATEGORY(logQHotkey)

QHotkey/qhotkey_mac.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class QHotkeyPrivateMac : public QHotkeyPrivate
77
{
88
public:
99
// QAbstractNativeEventFilter interface
10-
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
10+
bool nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result) override;
1111

1212
static OSStatus hotkeyPressEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data);
1313
static OSStatus hotkeyReleaseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data);
@@ -33,7 +33,7 @@ bool QHotkeyPrivate::isPlatformSupported()
3333
bool QHotkeyPrivateMac::isHotkeyHandlerRegistered = false;
3434
QHash<QHotkey::NativeShortcut, EventHotKeyRef> QHotkeyPrivateMac::hotkeyRefs;
3535

36-
bool QHotkeyPrivateMac::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
36+
bool QHotkeyPrivateMac::nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result)
3737
{
3838
Q_UNUSED(eventType)
3939
Q_UNUSED(message)
@@ -288,4 +288,4 @@ OSStatus QHotkeyPrivateMac::hotkeyReleaseEventHandler(EventHandlerCallRef nextHa
288288
}
289289

290290
return noErr;
291-
}
291+
}

QHotkey/qhotkey_p.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
#include <QMutex>
88
#include <QGlobalStatic>
99

10+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
11+
#define _NATIVE_EVENT_RESULT qintptr
12+
#else
13+
#define _NATIVE_EVENT_RESULT long
14+
#endif
15+
1016
class QHOTKEY_SHARED_EXPORT QHotkeyPrivate : public QObject, public QAbstractNativeEventFilter
1117
{
1218
Q_OBJECT

QHotkey/qhotkey_win.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class QHotkeyPrivateWin : public QHotkeyPrivate
1515
public:
1616
QHotkeyPrivateWin();
1717
// QAbstractNativeEventFilter interface
18-
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
18+
bool nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result) override;
1919

2020
protected:
2121
void pollForHotkeyRelease();
@@ -42,7 +42,7 @@ bool QHotkeyPrivate::isPlatformSupported()
4242
return true;
4343
}
4444

45-
bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
45+
bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result)
4646
{
4747
Q_UNUSED(eventType)
4848
Q_UNUSED(result)

QHotkey/qhotkey_x11.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33

44
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
55
#include <QGuiApplication>
6-
7-
#define _NATIVE_EVENT_RESULT qintptr
86
#else
97
#include <QDebug>
108
#include <QX11Info>
11-
12-
#define _NATIVE_EVENT_RESULT long
139
#endif
1410

1511
#include <QThreadStorage>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy