Skip to content

Add isPlatformSupported() #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions QHotkey/qhotkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions QHotkey/qhotkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class QHOTKEY_SHARED_EXPORT QHotkey : public QObject
//! 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
Expand Down
11 changes: 8 additions & 3 deletions QHotkey/qhotkey_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ class QHotkeyPrivateMac : public QHotkeyPrivate
};
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;
}

Expand Down
1 change: 1 addition & 0 deletions QHotkey/qhotkey_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class QHOTKEY_SHARED_EXPORT QHotkeyPrivate : public QObject, public QAbstractNat
~QHotkeyPrivate();

static QHotkeyPrivate *instance();
static bool isPlatformSupported();

QHotkey::NativeShortcut nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers);

Expand Down
9 changes: 7 additions & 2 deletions QHotkey/qhotkey_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ class QHotkeyPrivateWin : public QHotkeyPrivate
};
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)
Expand Down
9 changes: 7 additions & 2 deletions QHotkey/qhotkey_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,18 @@ class QHotkeyPrivateX11 : public QHotkeyPrivate
};
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) {
Expand Down
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