-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Expand file tree
/
Copy pathshortcuts.h
More file actions
181 lines (140 loc) · 3.44 KB
/
Copy pathshortcuts.h
File metadata and controls
181 lines (140 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
class QKeyEvent;
class QShortcutEvent;
namespace Shortcuts {
enum class Command {
Close,
Lock,
Minimize,
Quit,
ReopenClosedWindow,
CloseOtherWindows,
MediaPlay,
MediaPause,
MediaPlayPause,
MediaStop,
MediaPrevious,
MediaNext,
Search,
ChatPrevious,
ChatNext,
ChatFirst,
ChatLast,
ChatSelf,
ChatPinned1,
ChatPinned2,
ChatPinned3,
ChatPinned4,
ChatPinned5,
ChatPinned6,
ChatPinned7,
ChatPinned8,
ShowAccount1,
ShowAccount2,
ShowAccount3,
ShowAccount4,
ShowAccount5,
ShowAccount6,
ShowAllChats,
ShowFolder1,
ShowFolder2,
ShowFolder3,
ShowFolder4,
ShowFolder5,
ShowFolder6,
ShowFolderLast,
FolderNext,
FolderPrevious,
ShowScheduled,
ShowArchive,
ShowContacts,
JustSendMessage,
SendSilentMessage,
ScheduleMessage,
ComposeAiApplyInPlace,
ShowRichEditor,
ToggleWebPagePreview,
RecordVoice,
RecordRound,
ReadChat,
ArchiveChat,
MediaViewerFullscreen,
ShowChatMenu,
ShowChatPreview,
ShowAdminLog,
SupportReloadTemplates,
SupportToggleMuted,
SupportScrollToCurrent,
SupportHistoryBack,
SupportHistoryForward,
};
[[maybe_unused]] constexpr auto kShowFolder = {
Command::ShowAllChats,
Command::ShowFolder1,
Command::ShowFolder2,
Command::ShowFolder3,
Command::ShowFolder4,
Command::ShowFolder5,
Command::ShowFolder6,
Command::ShowFolderLast,
};
[[maybe_unused]] constexpr auto kShowAccount = {
Command::ShowAccount1,
Command::ShowAccount2,
Command::ShowAccount3,
Command::ShowAccount4,
Command::ShowAccount5,
Command::ShowAccount6,
};
[[nodiscard]] FnMut<bool()> RequestHandler(Command command);
class Request {
public:
bool check(Command command, int priority = 0);
bool handle(FnMut<bool()> handler);
private:
explicit Request(std::vector<Command> commands);
std::vector<Command> _commands;
int _handlerPriority = -1;
FnMut<bool()> _handler;
friend FnMut<bool()> RequestHandler(std::vector<Command> commands);
};
[[nodiscard]] rpl::producer<not_null<Request*>> Requests();
void Start();
void Finish();
void Listen(not_null<QWidget*> widget);
bool Launch(Command command);
bool HandleEvent(not_null<QObject*> object, not_null<QShortcutEvent*> event);
bool HandlePossibleChatSwitch(not_null<QKeyEvent*> event);
struct ChatSwitchRequest {
Qt::Key action = Qt::Key_Tab; // Key_Tab, Key_Backtab or Key_Escape.
bool started = false;
};
[[nodiscard]] rpl::producer<ChatSwitchRequest> ChatSwitchRequests();
[[nodiscard]] const QStringList &Errors();
// Media shortcuts are not enabled by default, because other
// applications also use them. They are enabled only when
// the in-app player is active and disabled back after.
void ToggleMediaShortcuts(bool toggled);
// Support shortcuts are not enabled by default, because they
// have some conflicts with default input shortcuts, like Ctrl+Delete.
void ToggleSupportShortcuts(bool toggled);
void Pause();
void Unpause();
[[nodiscard]] auto KeysDefaults()
-> base::flat_map<QKeySequence, base::flat_set<Command>>;
[[nodiscard]] auto KeysCurrents()
-> base::flat_map<QKeySequence, base::flat_set<Command>>;
void Change(
QKeySequence was,
QKeySequence now,
Command command,
std::optional<Command> restore = {});
void ResetToDefaults();
[[nodiscard]] bool AllowWithoutModifiers(int key);
} // namespace Shortcuts