Add isPlatformSupported() (#28)

* Add isPlatformSupported()
* Remove extra semicolons
* Add newlines before new methods
This commit is contained in:
Hennadii Chernyshchyk
2020-01-07 09:31:37 +01:00
committed by Felix Barz
parent 96a0710e1b
commit 9583eafe76
6 changed files with 31 additions and 7 deletions
+5
View File
@@ -16,6 +16,11 @@ void QHotkey::addGlobalMapping(const QKeySequence &shortcut, const QHotkey::Nati
Q_ARG(QHotkey::NativeShortcut, nativeShortcut));
}
bool QHotkey::isPlatformSupported()
{
return QHotkeyPrivate::isPlatformSupported();
}
QHotkey::QHotkey(QObject *parent) :
QObject(parent),
_keyCode(Qt::Key_unknown),
+3
View File
@@ -57,6 +57,9 @@ public:
//! Adds a global mapping of a key sequence to a replacement native shortcut
static void addGlobalMapping(const QKeySequence &shortcut, const NativeShortcut &nativeShortcut);
//! Checks if global shortcuts are supported by the current platform
static bool isPlatformSupported();
//! Default Constructor
explicit QHotkey(QObject *parent = nullptr);
//! Constructs a hotkey with a shortcut and optionally registers it
+8 -3
View File
@@ -24,14 +24,19 @@ private:
};
NATIVE_INSTANCE(QHotkeyPrivateMac)
bool QHotkeyPrivate::isPlatformSupported()
{
return true;
}
bool QHotkeyPrivateMac::isHotkeyHandlerRegistered = false;
QHash<QHotkey::NativeShortcut, EventHotKeyRef> QHotkeyPrivateMac::hotkeyRefs;
bool QHotkeyPrivateMac::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
Q_UNUSED(eventType);
Q_UNUSED(message);
Q_UNUSED(result);
Q_UNUSED(eventType)
Q_UNUSED(message)
Q_UNUSED(result)
return false;
}
+1
View File
@@ -16,6 +16,7 @@ public:
~QHotkeyPrivate();
static QHotkeyPrivate *instance();
static bool isPlatformSupported();
QHotkey::NativeShortcut nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers);
+7 -2
View File
@@ -23,10 +23,15 @@ private:
};
NATIVE_INSTANCE(QHotkeyPrivateWin)
bool QHotkeyPrivate::isPlatformSupported()
{
return true;
}
bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
Q_UNUSED(eventType);
Q_UNUSED(result);
Q_UNUSED(eventType)
Q_UNUSED(result)
MSG* msg = static_cast<MSG*>(message);
if(msg->message == WM_HOTKEY)
+7 -2
View File
@@ -47,13 +47,18 @@ private:
};
NATIVE_INSTANCE(QHotkeyPrivateX11)
bool QHotkeyPrivate::isPlatformSupported()
{
return QX11Info::isPlatformX11();
}
const QVector<quint32> QHotkeyPrivateX11::specialModifiers = {0, Mod2Mask, LockMask, (Mod2Mask | LockMask)};
const quint32 QHotkeyPrivateX11::validModsMask = ShiftMask | ControlMask | Mod1Mask | Mod4Mask;
bool QHotkeyPrivateX11::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
Q_UNUSED(eventType);
Q_UNUSED(result);
Q_UNUSED(eventType)
Q_UNUSED(result)
xcb_generic_event_t *genericEvent = static_cast<xcb_generic_event_t *>(message);
if (genericEvent->response_type == XCB_KEY_PRESS) {