mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-02-28 00:50:43 +01:00
Update base win shortcut
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user