mirror of
https://github.com/Skycoder42/QHotkey.git
synced 2026-11-19 12:49:58 +03:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d214ac41e | ||
|
|
83910c8eca |
+7
-1
@@ -279,7 +279,13 @@ bool QHotkeyPrivate::removeShortcutInvoked(QHotkey *hotkey)
|
||||
|
||||
QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
return {this->nativeKeycode(keycode), this->nativeModifiers(modifiers)};
|
||||
bool ok1, ok2 = false;
|
||||
auto k = nativeKeycode(keycode, ok1);
|
||||
auto m = nativeModifiers(modifiers, ok2);
|
||||
if(ok1 && ok2)
|
||||
return {k, m};
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
|
||||
+16
-7
@@ -13,8 +13,8 @@ public:
|
||||
|
||||
protected:
|
||||
// QHotkeyPrivate interface
|
||||
quint32 nativeKeycode(Qt::Key keycode) Q_DECL_OVERRIDE;
|
||||
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
|
||||
quint32 nativeKeycode(Qt::Key keycode, bool &ok) Q_DECL_OVERRIDE;
|
||||
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) Q_DECL_OVERRIDE;
|
||||
bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||
bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||
|
||||
@@ -35,9 +35,10 @@ bool QHotkeyPrivateMac::nativeEventFilter(const QByteArray &eventType, void *mes
|
||||
return false;
|
||||
}
|
||||
|
||||
quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode)
|
||||
quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode, bool &ok)
|
||||
{
|
||||
// Constants found in NSEvent.h from AppKit.framework
|
||||
ok = true;
|
||||
switch (keycode) {
|
||||
case Qt::Key_Return:
|
||||
return kVK_Return;
|
||||
@@ -120,7 +121,8 @@ quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode)
|
||||
case Qt::Key_Up:
|
||||
return kVK_UpArrow;
|
||||
default:
|
||||
;
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
|
||||
UTF16Char ch = keycode;
|
||||
@@ -157,11 +159,17 @@ quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode)
|
||||
long idx = keyToChar[k] & kUCKeyOutputGetIndexMask;
|
||||
if (stateRec && idx < stateRec->keyStateRecordCount) {
|
||||
UCKeyStateRecord* rec = reinterpret_cast<UCKeyStateRecord*>(data + stateRec->keyStateRecordOffsets[idx]);
|
||||
if (rec->stateZeroCharData == ch) return k;
|
||||
if (rec->stateZeroCharData == ch) {
|
||||
ok = true;
|
||||
return k;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) {
|
||||
if (keyToChar[k] == ch) return k;
|
||||
if (keyToChar[k] == ch) {
|
||||
ok = true;
|
||||
return k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,7 +177,7 @@ quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
quint32 QHotkeyPrivateMac::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
||||
quint32 QHotkeyPrivateMac::nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok)
|
||||
{
|
||||
quint32 nMods = 0;
|
||||
if (modifiers & Qt::ShiftModifier)
|
||||
@@ -182,6 +190,7 @@ quint32 QHotkeyPrivateMac::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
||||
nMods |= controlKey;
|
||||
if (modifiers & Qt::KeypadModifier)
|
||||
nMods |= kEventKeyModifierNumLockMask;
|
||||
ok = true;
|
||||
return nMods;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -25,8 +25,8 @@ public:
|
||||
protected:
|
||||
void activateShortcut(QHotkey::NativeShortcut shortcut);
|
||||
|
||||
virtual quint32 nativeKeycode(Qt::Key keycode) = 0;//platform implement
|
||||
virtual quint32 nativeModifiers(Qt::KeyboardModifiers modifiers) = 0;//platform implement
|
||||
virtual quint32 nativeKeycode(Qt::Key keycode, bool &ok) = 0;//platform implement
|
||||
virtual quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) = 0;//platform implement
|
||||
|
||||
virtual bool registerShortcut(QHotkey::NativeShortcut shortcut) = 0;//platform implement
|
||||
virtual bool unregisterShortcut(QHotkey::NativeShortcut shortcut) = 0;//platform implement
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
|
||||
protected:
|
||||
// QHotkeyPrivate interface
|
||||
quint32 nativeKeycode(Qt::Key keycode) Q_DECL_OVERRIDE;
|
||||
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
|
||||
quint32 nativeKeycode(Qt::Key keycode, bool &ok) Q_DECL_OVERRIDE;
|
||||
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) Q_DECL_OVERRIDE;
|
||||
bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||
bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||
|
||||
@@ -35,8 +35,9 @@ bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *mes
|
||||
return false;
|
||||
}
|
||||
|
||||
quint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode)
|
||||
quint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode, bool &ok)
|
||||
{
|
||||
ok = true;
|
||||
if(keycode <= 0xFFFF) {//Try to obtain the key from it's "character"
|
||||
const SHORT vKey = VkKeyScanW(keycode);
|
||||
if(vKey > -1)
|
||||
@@ -201,11 +202,12 @@ quint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode)
|
||||
return VK_OEM_FJ_TOUROKU;
|
||||
|
||||
default:
|
||||
ok = false;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
quint32 QHotkeyPrivateWin::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
||||
quint32 QHotkeyPrivateWin::nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok)
|
||||
{
|
||||
quint32 nMods = 0;
|
||||
if (modifiers & Qt::ShiftModifier)
|
||||
@@ -216,6 +218,7 @@ quint32 QHotkeyPrivateWin::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
||||
nMods |= MOD_ALT;
|
||||
if (modifiers & Qt::MetaModifier)
|
||||
nMods |= MOD_WIN;
|
||||
ok = true;
|
||||
return nMods;
|
||||
}
|
||||
|
||||
|
||||
+11
-7
@@ -14,8 +14,8 @@ public:
|
||||
|
||||
protected:
|
||||
// QHotkeyPrivate interface
|
||||
quint32 nativeKeycode(Qt::Key keycode) Q_DECL_OVERRIDE;
|
||||
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
|
||||
quint32 nativeKeycode(Qt::Key keycode, bool &ok) Q_DECL_OVERRIDE;
|
||||
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) Q_DECL_OVERRIDE;
|
||||
bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||
bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||
|
||||
@@ -58,7 +58,7 @@ bool QHotkeyPrivateX11::nativeEventFilter(const QByteArray &eventType, void *mes
|
||||
return false;
|
||||
}
|
||||
|
||||
quint32 QHotkeyPrivateX11::nativeKeycode(Qt::Key keycode)
|
||||
quint32 QHotkeyPrivateX11::nativeKeycode(Qt::Key keycode, bool &ok)
|
||||
{
|
||||
KeySym keysym = XStringToKeysym(QKeySequence(keycode).toString(QKeySequence::NativeText).toLatin1().constData());
|
||||
if (keysym == NoSymbol) {
|
||||
@@ -70,13 +70,16 @@ quint32 QHotkeyPrivateX11::nativeKeycode(Qt::Key keycode)
|
||||
}
|
||||
|
||||
Display *display = QX11Info::display();
|
||||
if(display)
|
||||
return XKeysymToKeycode(QX11Info::display(), keysym);
|
||||
else
|
||||
if(display) {
|
||||
auto res = XKeysymToKeycode(QX11Info::display(), keysym);
|
||||
if(res != 0)
|
||||
ok = true;
|
||||
return res;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
quint32 QHotkeyPrivateX11::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
||||
quint32 QHotkeyPrivateX11::nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok)
|
||||
{
|
||||
quint32 nMods = 0;
|
||||
if (modifiers & Qt::ShiftModifier)
|
||||
@@ -87,6 +90,7 @@ quint32 QHotkeyPrivateX11::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
||||
nMods |= Mod1Mask;
|
||||
if (modifiers & Qt::MetaModifier)
|
||||
nMods |= Mod4Mask;
|
||||
ok = true;
|
||||
return nMods;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
{
|
||||
"name": "de.skycoder42.qhotkey",
|
||||
"description": "A global shortcut/hotkey for Desktop Qt-Applications",
|
||||
"author": {
|
||||
"name": "Skycoder",
|
||||
"email": "skycoder42.de@gmx.de"
|
||||
},
|
||||
"repository": {
|
||||
"type": "GITHUB",
|
||||
"url": "https://github.com/Skycoder42/QHotkey.git"
|
||||
},
|
||||
"version": {
|
||||
"label": "1.1.4",
|
||||
"revision": "",
|
||||
"fingerprint": ""
|
||||
},
|
||||
"dependencies": [
|
||||
],
|
||||
"license": "BSD_3_CLAUSE",
|
||||
"pri_filename": "qhotkey.pri",
|
||||
"webpage": "https://github.com/Skycoder42/QHotkey"
|
||||
"author": {
|
||||
"email": "skycoder42.de@gmx.de",
|
||||
"name": "Skycoder"
|
||||
},
|
||||
"dependencies": [
|
||||
],
|
||||
"description": "A global shortcut/hotkey for Desktop Qt-Applications",
|
||||
"license": "BSD_3_CLAUSE",
|
||||
"name": "de.skycoder42.qhotkey",
|
||||
"pri_filename": "qhotkey.pri",
|
||||
"repository": {
|
||||
"type": "GITHUB",
|
||||
"url": "https://github.com/Skycoder42/QHotkey.git"
|
||||
},
|
||||
"version": {
|
||||
"fingerprint": "",
|
||||
"label": "1.2.0",
|
||||
"revision": ""
|
||||
},
|
||||
"webpage": "https://github.com/Skycoder42/QHotkey"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"dependencies": [
|
||||
],
|
||||
"license": {
|
||||
"file": "LICENSE",
|
||||
"name": "BSD_3_CLAUSE"
|
||||
},
|
||||
"prcFile": "",
|
||||
"priFile": "qhotkey.pri",
|
||||
"priIncludes": [
|
||||
],
|
||||
"publishers": {
|
||||
"qpm": {
|
||||
"author": {
|
||||
"email": "skycoder42.de@gmx.de",
|
||||
"name": "Skycoder"
|
||||
},
|
||||
"description": "A global shortcut/hotkey for Desktop Qt-Applications",
|
||||
"name": "de.skycoder42.qhotkey",
|
||||
"repository": {
|
||||
"type": "GITHUB",
|
||||
"url": "https://github.com/Skycoder42/QHotkey.git"
|
||||
},
|
||||
"webpage": "https://github.com/Skycoder42/QHotkey"
|
||||
}
|
||||
},
|
||||
"source": false
|
||||
}
|
||||
Reference in New Issue
Block a user