Skip to content

Commit 9583eaf

Browse files
ShaturSkycoder42
authored andcommitted
Add isPlatformSupported() (#28)
* Add isPlatformSupported() * Remove extra semicolons * Add newlines before new methods
1 parent 96a0710 commit 9583eaf

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

QHotkey/qhotkey.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ void QHotkey::addGlobalMapping(const QKeySequence &shortcut, const QHotkey::Nati
1616
Q_ARG(QHotkey::NativeShortcut, nativeShortcut));
1717
}
1818

19+
bool QHotkey::isPlatformSupported()
20+
{
21+
return QHotkeyPrivate::isPlatformSupported();
22+
}
23+
1924
QHotkey::QHotkey(QObject *parent) :
2025
QObject(parent),
2126
_keyCode(Qt::Key_unknown),

QHotkey/qhotkey.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class QHOTKEY_SHARED_EXPORT QHotkey : public QObject
5757
//! Adds a global mapping of a key sequence to a replacement native shortcut
5858
static void addGlobalMapping(const QKeySequence &shortcut, const NativeShortcut &nativeShortcut);
5959

60+
//! Checks if global shortcuts are supported by the current platform
61+
static bool isPlatformSupported();
62+
6063
//! Default Constructor
6164
explicit QHotkey(QObject *parent = nullptr);
6265
//! Constructs a hotkey with a shortcut and optionally registers it

QHotkey/qhotkey_mac.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@ class QHotkeyPrivateMac : public QHotkeyPrivate
2424
};
2525
NATIVE_INSTANCE(QHotkeyPrivateMac)
2626

27+
bool QHotkeyPrivate::isPlatformSupported()
28+
{
29+
return true;
30+
}
31+
2732
bool QHotkeyPrivateMac::isHotkeyHandlerRegistered = false;
2833
QHash<QHotkey::NativeShortcut, EventHotKeyRef> QHotkeyPrivateMac::hotkeyRefs;
2934

3035
bool QHotkeyPrivateMac::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
3136
{
32-
Q_UNUSED(eventType);
33-
Q_UNUSED(message);
34-
Q_UNUSED(result);
37+
Q_UNUSED(eventType)
38+
Q_UNUSED(message)
39+
Q_UNUSED(result)
3540
return false;
3641
}
3742

QHotkey/qhotkey_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class QHOTKEY_SHARED_EXPORT QHotkeyPrivate : public QObject, public QAbstractNat
1616
~QHotkeyPrivate();
1717

1818
static QHotkeyPrivate *instance();
19+
static bool isPlatformSupported();
1920

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

QHotkey/qhotkey_win.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ class QHotkeyPrivateWin : public QHotkeyPrivate
2323
};
2424
NATIVE_INSTANCE(QHotkeyPrivateWin)
2525

26+
bool QHotkeyPrivate::isPlatformSupported()
27+
{
28+
return true;
29+
}
30+
2631
bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
2732
{
28-
Q_UNUSED(eventType);
29-
Q_UNUSED(result);
33+
Q_UNUSED(eventType)
34+
Q_UNUSED(result)
3035

3136
MSG* msg = static_cast<MSG*>(message);
3237
if(msg->message == WM_HOTKEY)

QHotkey/qhotkey_x11.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ class QHotkeyPrivateX11 : public QHotkeyPrivate
4747
};
4848
NATIVE_INSTANCE(QHotkeyPrivateX11)
4949

50+
bool QHotkeyPrivate::isPlatformSupported()
51+
{
52+
return QX11Info::isPlatformX11();
53+
}
54+
5055
const QVector<quint32> QHotkeyPrivateX11::specialModifiers = {0, Mod2Mask, LockMask, (Mod2Mask | LockMask)};
5156
const quint32 QHotkeyPrivateX11::validModsMask = ShiftMask | ControlMask | Mod1Mask | Mod4Mask;
5257

5358
bool QHotkeyPrivateX11::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
5459
{
55-
Q_UNUSED(eventType);
56-
Q_UNUSED(result);
60+
Q_UNUSED(eventType)
61+
Q_UNUSED(result)
5762

5863
xcb_generic_event_t *genericEvent = static_cast<xcb_generic_event_t *>(message);
5964
if (genericEvent->response_type == XCB_KEY_PRESS) {

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