mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
fix: windows global hotkey Win/Meta and 1-9 doesn't work
This commit is contained in:
parent
beef6dd138
commit
5cc43a3dc8
|
@ -1,8 +1,3 @@
|
||||||
#ifdef __WIN32 // Q_OS_WIN32 isn't available at this point
|
|
||||||
#define _WIN32_WINNT 0x0430
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "hotkeywrapper.hh"
|
#include "hotkeywrapper.hh"
|
||||||
#include "gddebug.hh"
|
#include "gddebug.hh"
|
||||||
|
|
||||||
|
@ -12,6 +7,7 @@
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include "mainwindow.hh"
|
#include "mainwindow.hh"
|
||||||
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -332,13 +328,13 @@ bool HotkeyWrapper::winEvent( MSG * message, qintptr * result )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ref: https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
|
||||||
quint32 HotkeyWrapper::nativeKey( int key )
|
quint32 HotkeyWrapper::nativeKey( int key )
|
||||||
{
|
{
|
||||||
if ( key >= Qt::Key_0 && key <= Qt::Key_9 )
|
// Qt's 0-9 & A-Z overlaps with Windows's VK
|
||||||
return VK_NUMPAD0 + ( key - Qt::Key_0 );
|
if ( key >= Qt::Key_0 && key <= Qt::Key_9 || key >= Qt::Key_A && key <= Qt::Key_Z ) {
|
||||||
|
|
||||||
if ( key >= Qt::Key_A && key <= Qt::Key_Z )
|
|
||||||
return key;
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
switch ( key ) {
|
switch ( key ) {
|
||||||
case Qt::Key_Space:
|
case Qt::Key_Space:
|
||||||
|
@ -485,6 +481,8 @@ quint32 HotkeyWrapper::nativeKey( int key )
|
||||||
return 0x39;
|
return 0x39;
|
||||||
case Qt::Key_Underscore:
|
case Qt::Key_Underscore:
|
||||||
return VK_OEM_MINUS;
|
return VK_OEM_MINUS;
|
||||||
|
case Qt::Key_Meta:
|
||||||
|
return VK_LWIN;
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue