From cb35f2de540c33dc44fb057443bf1d6fa552560b Mon Sep 17 00:00:00 2001 From: Shatur95 Date: Mon, 6 Jan 2020 00:19:05 +0200 Subject: [PATCH 1/3] Add isPlatformSupported() --- QHotkey/qhotkey.cpp | 5 +++++ QHotkey/qhotkey.h | 3 +++ QHotkey/qhotkey_mac.cpp | 4 ++++ QHotkey/qhotkey_p.h | 1 + QHotkey/qhotkey_win.cpp | 4 ++++ QHotkey/qhotkey_x11.cpp | 4 ++++ 6 files changed, 21 insertions(+) diff --git a/QHotkey/qhotkey.cpp b/QHotkey/qhotkey.cpp index 8b11bdd..8dadc08 100644 --- a/QHotkey/qhotkey.cpp +++ b/QHotkey/qhotkey.cpp @@ -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), diff --git a/QHotkey/qhotkey.h b/QHotkey/qhotkey.h index 133ef25..479dff5 100644 --- a/QHotkey/qhotkey.h +++ b/QHotkey/qhotkey.h @@ -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 diff --git a/QHotkey/qhotkey_mac.cpp b/QHotkey/qhotkey_mac.cpp index ac123bf..a7768cd 100644 --- a/QHotkey/qhotkey_mac.cpp +++ b/QHotkey/qhotkey_mac.cpp @@ -23,6 +23,10 @@ class QHotkeyPrivateMac : public QHotkeyPrivate static QHash hotkeyRefs; }; NATIVE_INSTANCE(QHotkeyPrivateMac) +bool QHotkeyPrivate::isPlatformSupported() +{ + return true; +} bool QHotkeyPrivateMac::isHotkeyHandlerRegistered = false; QHash QHotkeyPrivateMac::hotkeyRefs; diff --git a/QHotkey/qhotkey_p.h b/QHotkey/qhotkey_p.h index 9e9e0ae..847f7db 100644 --- a/QHotkey/qhotkey_p.h +++ b/QHotkey/qhotkey_p.h @@ -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); diff --git a/QHotkey/qhotkey_win.cpp b/QHotkey/qhotkey_win.cpp index 6b458a5..2282ec8 100644 --- a/QHotkey/qhotkey_win.cpp +++ b/QHotkey/qhotkey_win.cpp @@ -22,6 +22,10 @@ class QHotkeyPrivateWin : public QHotkeyPrivate static QString formatWinError(DWORD winError); }; NATIVE_INSTANCE(QHotkeyPrivateWin) +bool QHotkeyPrivate::isPlatformSupported() +{ + return true; +} bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *message, long *result) { diff --git a/QHotkey/qhotkey_x11.cpp b/QHotkey/qhotkey_x11.cpp index a3e48ee..060b91a 100644 --- a/QHotkey/qhotkey_x11.cpp +++ b/QHotkey/qhotkey_x11.cpp @@ -46,6 +46,10 @@ class QHotkeyPrivateX11 : public QHotkeyPrivate }; }; NATIVE_INSTANCE(QHotkeyPrivateX11) +bool QHotkeyPrivate::isPlatformSupported() +{ + return QX11Info::isPlatformX11(); +} const QVector QHotkeyPrivateX11::specialModifiers = {0, Mod2Mask, LockMask, (Mod2Mask | LockMask)}; const quint32 QHotkeyPrivateX11::validModsMask = ShiftMask | ControlMask | Mod1Mask | Mod4Mask; From d249ffc5736880c95350de9e3c4b5fe3aee57042 Mon Sep 17 00:00:00 2001 From: Shatur95 Date: Mon, 6 Jan 2020 00:25:14 +0200 Subject: [PATCH 2/3] Remove extra semicolons --- QHotkey/qhotkey_mac.cpp | 6 +++--- QHotkey/qhotkey_win.cpp | 4 ++-- QHotkey/qhotkey_x11.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/QHotkey/qhotkey_mac.cpp b/QHotkey/qhotkey_mac.cpp index a7768cd..7e270f7 100644 --- a/QHotkey/qhotkey_mac.cpp +++ b/QHotkey/qhotkey_mac.cpp @@ -33,9 +33,9 @@ QHash 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; } diff --git a/QHotkey/qhotkey_win.cpp b/QHotkey/qhotkey_win.cpp index 2282ec8..c75fbf2 100644 --- a/QHotkey/qhotkey_win.cpp +++ b/QHotkey/qhotkey_win.cpp @@ -29,8 +29,8 @@ bool QHotkeyPrivate::isPlatformSupported() 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(message); if(msg->message == WM_HOTKEY) diff --git a/QHotkey/qhotkey_x11.cpp b/QHotkey/qhotkey_x11.cpp index 060b91a..63b9b7d 100644 --- a/QHotkey/qhotkey_x11.cpp +++ b/QHotkey/qhotkey_x11.cpp @@ -56,8 +56,8 @@ const quint32 QHotkeyPrivateX11::validModsMask = ShiftMask | ControlMask | Mod1M 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(message); if (genericEvent->response_type == XCB_KEY_PRESS) { From 6dd0423068f83b82395e60d96ceef964dca8e079 Mon Sep 17 00:00:00 2001 From: Shatur95 Date: Mon, 6 Jan 2020 14:49:23 +0200 Subject: [PATCH 3/3] Add newlines before new methods --- QHotkey/qhotkey_mac.cpp | 1 + QHotkey/qhotkey_win.cpp | 1 + QHotkey/qhotkey_x11.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/QHotkey/qhotkey_mac.cpp b/QHotkey/qhotkey_mac.cpp index 7e270f7..a410373 100644 --- a/QHotkey/qhotkey_mac.cpp +++ b/QHotkey/qhotkey_mac.cpp @@ -23,6 +23,7 @@ class QHotkeyPrivateMac : public QHotkeyPrivate static QHash hotkeyRefs; }; NATIVE_INSTANCE(QHotkeyPrivateMac) + bool QHotkeyPrivate::isPlatformSupported() { return true; diff --git a/QHotkey/qhotkey_win.cpp b/QHotkey/qhotkey_win.cpp index c75fbf2..ead6763 100644 --- a/QHotkey/qhotkey_win.cpp +++ b/QHotkey/qhotkey_win.cpp @@ -22,6 +22,7 @@ class QHotkeyPrivateWin : public QHotkeyPrivate static QString formatWinError(DWORD winError); }; NATIVE_INSTANCE(QHotkeyPrivateWin) + bool QHotkeyPrivate::isPlatformSupported() { return true; diff --git a/QHotkey/qhotkey_x11.cpp b/QHotkey/qhotkey_x11.cpp index 63b9b7d..43f8956 100644 --- a/QHotkey/qhotkey_x11.cpp +++ b/QHotkey/qhotkey_x11.cpp @@ -46,6 +46,7 @@ class QHotkeyPrivateX11 : public QHotkeyPrivate }; }; NATIVE_INSTANCE(QHotkeyPrivateX11) + bool QHotkeyPrivate::isPlatformSupported() { return QX11Info::isPlatformX11(); 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