Fix Qxt for Qt5?
BUG: 486
This commit is contained in:
21
3rdparty/qxt/qxtglobalshortcut.cpp
vendored
21
3rdparty/qxt/qxtglobalshortcut.cpp
vendored
@@ -24,24 +24,41 @@
|
||||
****************************************************************************/
|
||||
#include "qxtglobalshortcut.h"
|
||||
#include "qxtglobalshortcut_p.h"
|
||||
#if QT_VERSION<0x050000
|
||||
#include <QAbstractEventDispatcher>
|
||||
#else
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QCoreApplication>
|
||||
#endif
|
||||
#include <QtDebug>
|
||||
|
||||
bool QxtGlobalShortcutPrivate::error = false;
|
||||
int QxtGlobalShortcutPrivate::ref = 0;
|
||||
#if QT_VERSION<0x050000
|
||||
QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0;
|
||||
#endif
|
||||
QHash<QPair<quint32, quint32>, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts;
|
||||
|
||||
QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier)
|
||||
{
|
||||
if (!ref++)
|
||||
if (!ref++) {
|
||||
#if QT_VERSION<0x050000
|
||||
prevEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter);
|
||||
#else
|
||||
QCoreApplication::instance()->installNativeEventFilter(this);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate()
|
||||
{
|
||||
if (!--ref)
|
||||
if (!--ref) {
|
||||
#if QT_VERSION<0x050000
|
||||
QAbstractEventDispatcher::instance()->setEventFilter(prevEventFilter);
|
||||
#else
|
||||
QCoreApplication::instance()->removeNativeEventFilter(this);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut)
|
||||
|
||||
4
3rdparty/qxt/qxtglobalshortcut_mac.cpp
vendored
4
3rdparty/qxt/qxtglobalshortcut_mac.cpp
vendored
@@ -43,7 +43,11 @@ OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event,
|
||||
return noErr;
|
||||
}
|
||||
|
||||
#if QT_VERSION<0x050000
|
||||
bool QxtGlobalShortcutPrivate::eventFilter(void* message)
|
||||
#else
|
||||
bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray &, void *message, long *result)
|
||||
#endif
|
||||
//bool QxtGlobalShortcutPrivate::macEventFilter(EventHandlerCallRef caller, EventRef event)
|
||||
{
|
||||
EventRef event = (EventRef) message;
|
||||
|
||||
9
3rdparty/qxt/qxtglobalshortcut_p.h
vendored
9
3rdparty/qxt/qxtglobalshortcut_p.h
vendored
@@ -26,7 +26,12 @@
|
||||
#define QXTGLOBALSHORTCUT_P_H
|
||||
|
||||
#include "qxtglobalshortcut.h"
|
||||
#if QT_VERSION<0x050000
|
||||
#include <QAbstractEventDispatcher>
|
||||
#else
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QCoreApplication>
|
||||
#endif
|
||||
#include <QKeySequence>
|
||||
#include <QHash>
|
||||
|
||||
@@ -46,8 +51,12 @@ public:
|
||||
|
||||
static bool error;
|
||||
static int ref;
|
||||
#if QT_VERSION<0x050000
|
||||
static QAbstractEventDispatcher::EventFilter prevEventFilter;
|
||||
static bool eventFilter(void* message);
|
||||
#else
|
||||
bool nativeEventFilter(const QByteArray &, void *message, long *result)
|
||||
#endif
|
||||
|
||||
private:
|
||||
static quint32 nativeKeycode(Qt::Key keycode);
|
||||
|
||||
4
3rdparty/qxt/qxtglobalshortcut_win.cpp
vendored
4
3rdparty/qxt/qxtglobalshortcut_win.cpp
vendored
@@ -25,7 +25,11 @@
|
||||
#include "qxtglobalshortcut_p.h"
|
||||
#include <qt_windows.h>
|
||||
|
||||
#if QT_VERSION<0x050000
|
||||
bool QxtGlobalShortcutPrivate::eventFilter(void* message)
|
||||
#else
|
||||
bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray &, void *message, long *result)
|
||||
#endif
|
||||
{
|
||||
MSG* msg = static_cast<MSG*>(message);
|
||||
if (msg->message == WM_HOTKEY)
|
||||
|
||||
4
3rdparty/qxt/qxtglobalshortcut_x11.cpp
vendored
4
3rdparty/qxt/qxtglobalshortcut_x11.cpp
vendored
@@ -51,7 +51,11 @@ static int qxt_x_errhandler(Display* display, XErrorEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION<0x050000
|
||||
bool QxtGlobalShortcutPrivate::eventFilter(void* message)
|
||||
#else
|
||||
bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray &, void *message, long *result)
|
||||
#endif
|
||||
{
|
||||
XEvent* event = static_cast<XEvent*>(message);
|
||||
if (event->type == KeyPress)
|
||||
|
||||
Reference in New Issue
Block a user