Update base win shortcut

This commit is contained in:
Ximi1970
2023-12-06 19:31:43 +01:00
parent 90efee069b
commit a474b38aff

View File

@@ -4,6 +4,7 @@
/*
* System includes
*/
#include "windows.h"
/*
* Qt includes
@@ -17,9 +18,19 @@
bool NativeEventFilterWin::nativeEventFilter( const QByteArray& eventType, void* message, long* result )
{
Q_UNUSED( eventType )
Q_UNUSED( message )
Q_UNUSED( result )
MSG* msg = reinterpret_cast< MSG* >( message );
if( msg->message == WM_HOTKEY )
{
if( msg->wParam == 100 )
{
activated();
return true;
}
}
return false;
}
@@ -41,7 +52,14 @@ bool NativeEventFilterWin::connectShortcut( QKeySequence key_seq )
*/
bool NativeEventFilterWin::connectShortcut( Qt::Key key_code, Qt::KeyboardModifiers key_modifiers )
{
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerhotkey
// Set windows callback
RegisterHotKey( (HWND)MainWindow::winId(), // Set the system identifier of the widget window that will handle the HotKey
100, // Set identifier HotKey
MOD_ALT | MOD_SHIFT, // Set modifiers
'D' ); // We define hotkeys for HotKey
return true;
}
@@ -53,6 +71,7 @@ bool NativeEventFilterWin::connectShortcut( Qt::Key key_code, Qt::KeyboardModifi
bool NativeEventFilterWin::disconnectShortcut()
{
// Remove windows callback
UnregisterHotKey( (HWND)MainWindow::winId(), 100 );
return true;
}