Rabbit Remote Control
0.1.0-bate14
Toggle main menu visibility
Loading...
Searching...
No Matches
Src
Windows
DesktopShortcuts.h
1
// Author: Kang Lin <kl222@126.com>
2
3
#pragma once
4
5
#include <QObject>
6
#include <QAbstractNativeEventFilter>
7
#include <QHash>
8
9
#ifdef Q_OS_WIN
10
#include <windows.h>
11
#endif
12
13
class
CDesktopShortcutsManager :
public
QObject,
public
QAbstractNativeEventFilter
14
{
15
Q_OBJECT
16
17
public
:
18
explicit
CDesktopShortcutsManager(QObject *parent =
nullptr
);
19
~CDesktopShortcutsManager();
20
21
// 快捷键管理
22
bool
disableAllHotkeys();
23
bool
restoreAllHotkeys();
24
bool
isDisabled()
const
{
return
m_hotkeysDisabled; }
25
26
// 特定快捷键控制
27
bool
disableWindowsKey();
28
bool
enableWindowsKey();
29
bool
disableAltTab();
30
bool
enableAltTab();
31
bool
disableTaskManager();
32
bool
enableTaskManager();
33
34
// QAbstractNativeEventFilter 接口
35
bool
nativeEventFilter(
const
QByteArray &eventType,
void
*message, qintptr *result)
override
;
36
37
signals:
38
void
hotkeyPressed(
int
keyCode,
const
QString &keyName);
39
void
hotkeyBlocked(
int
keyCode,
const
QString &keyName);
40
void
statusChanged(
bool
disabled);
41
42
private
:
43
void
initializeKeys();
44
bool
setKeyboardHook();
45
bool
removeKeyboardHook();
46
static
LRESULT CALLBACK keyboardProc(
int
nCode, WPARAM wParam, LPARAM lParam);
47
48
private
:
49
bool
m_hotkeysDisabled =
false
;
50
bool
m_keyboardHooked =
false
;
51
52
#ifdef Q_OS_WIN
53
HHOOK m_keyboardHook =
nullptr
;
54
QHash<int, QString> m_keyNames;
55
56
// 存储原始注册表值
57
QHash<QString, QVariant> m_registryBackup;
58
#endif
59
};
Author: Kang Lin (kl222@126.com)
Copyright (c) Kang Lin Studios All Rights Reserved