| 
									
										
										
										
											2018-11-16 16:15:14 +04:00
										 |  |  | /*
 | 
					
						
							|  |  |  | 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
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Shortcuts { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum class Command { | 
					
						
							|  |  |  | 	Close, | 
					
						
							|  |  |  | 	Lock, | 
					
						
							|  |  |  | 	Minimize, | 
					
						
							|  |  |  | 	Quit, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	MediaPlay, | 
					
						
							|  |  |  | 	MediaPause, | 
					
						
							|  |  |  | 	MediaPlayPause, | 
					
						
							|  |  |  | 	MediaStop, | 
					
						
							|  |  |  | 	MediaPrevious, | 
					
						
							|  |  |  | 	MediaNext, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Search, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ChatPrevious, | 
					
						
							|  |  |  | 	ChatNext, | 
					
						
							| 
									
										
										
										
											2018-11-16 17:36:42 +04:00
										 |  |  | 	ChatFirst, | 
					
						
							|  |  |  | 	ChatLast, | 
					
						
							| 
									
										
										
										
											2019-03-11 22:01:41 +03:00
										 |  |  | 	ChatSelf, | 
					
						
							| 
									
										
										
										
											2018-12-29 17:39:17 +04:00
										 |  |  | 	ChatPinned1, | 
					
						
							|  |  |  | 	ChatPinned2, | 
					
						
							|  |  |  | 	ChatPinned3, | 
					
						
							|  |  |  | 	ChatPinned4, | 
					
						
							|  |  |  | 	ChatPinned5, | 
					
						
							| 
									
										
										
										
											2023-01-03 09:59:42 +04:00
										 |  |  | 	ChatPinned6, | 
					
						
							|  |  |  | 	ChatPinned7, | 
					
						
							|  |  |  | 	ChatPinned8, | 
					
						
							| 
									
										
										
										
											2018-11-16 17:36:42 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-05 12:50:04 +04:00
										 |  |  | 	ShowAccount1, | 
					
						
							|  |  |  | 	ShowAccount2, | 
					
						
							|  |  |  | 	ShowAccount3, | 
					
						
							|  |  |  | 	ShowAccount4, | 
					
						
							|  |  |  | 	ShowAccount5, | 
					
						
							|  |  |  | 	ShowAccount6, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-30 23:34:07 +04:00
										 |  |  | 	ShowAllChats, | 
					
						
							| 
									
										
										
										
											2020-03-27 20:51:09 +03:00
										 |  |  | 	ShowFolder1, | 
					
						
							|  |  |  | 	ShowFolder2, | 
					
						
							|  |  |  | 	ShowFolder3, | 
					
						
							|  |  |  | 	ShowFolder4, | 
					
						
							|  |  |  | 	ShowFolder5, | 
					
						
							|  |  |  | 	ShowFolder6, | 
					
						
							| 
									
										
										
										
											2020-03-30 23:34:07 +04:00
										 |  |  | 	ShowFolderLast, | 
					
						
							| 
									
										
										
										
											2020-03-27 20:51:09 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-29 02:04:20 +03:00
										 |  |  | 	FolderNext, | 
					
						
							|  |  |  | 	FolderPrevious, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-05 08:14:52 +03:00
										 |  |  | 	ShowArchive, | 
					
						
							| 
									
										
										
										
											2020-10-07 21:06:22 +03:00
										 |  |  | 	ShowContacts, | 
					
						
							| 
									
										
										
										
											2020-01-05 08:14:52 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-18 17:39:00 +03:00
										 |  |  | 	JustSendMessage, | 
					
						
							| 
									
										
										
										
											2019-12-23 18:14:12 +03:00
										 |  |  | 	SendSilentMessage, | 
					
						
							|  |  |  | 	ScheduleMessage, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-16 15:14:35 +03:00
										 |  |  | 	ReadChat, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-12 04:14:05 +03:00
										 |  |  | 	MediaViewerFullscreen, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-16 17:36:42 +04:00
										 |  |  | 	SupportReloadTemplates, | 
					
						
							|  |  |  | 	SupportToggleMuted, | 
					
						
							|  |  |  | 	SupportScrollToCurrent, | 
					
						
							| 
									
										
										
										
											2018-12-30 16:50:23 +04:00
										 |  |  | 	SupportHistoryBack, | 
					
						
							|  |  |  | 	SupportHistoryForward, | 
					
						
							| 
									
										
										
										
											2018-11-16 16:15:14 +04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-14 02:16:03 +04:00
										 |  |  | [[maybe_unused]] constexpr auto kShowFolder = { | 
					
						
							| 
									
										
										
										
											2020-03-30 23:34:07 +04:00
										 |  |  | 	Command::ShowAllChats, | 
					
						
							| 
									
										
										
										
											2020-03-27 20:51:09 +03:00
										 |  |  | 	Command::ShowFolder1, | 
					
						
							|  |  |  | 	Command::ShowFolder2, | 
					
						
							|  |  |  | 	Command::ShowFolder3, | 
					
						
							|  |  |  | 	Command::ShowFolder4, | 
					
						
							|  |  |  | 	Command::ShowFolder5, | 
					
						
							|  |  |  | 	Command::ShowFolder6, | 
					
						
							| 
									
										
										
										
											2020-03-30 23:34:07 +04:00
										 |  |  | 	Command::ShowFolderLast, | 
					
						
							| 
									
										
										
										
											2020-03-27 20:51:09 +03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-05 12:50:04 +04:00
										 |  |  | [[maybe_unused]] constexpr auto kShowAccount = { | 
					
						
							|  |  |  | 	Command::ShowAccount1, | 
					
						
							|  |  |  | 	Command::ShowAccount2, | 
					
						
							|  |  |  | 	Command::ShowAccount3, | 
					
						
							|  |  |  | 	Command::ShowAccount4, | 
					
						
							|  |  |  | 	Command::ShowAccount5, | 
					
						
							|  |  |  | 	Command::ShowAccount6, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-16 19:12:39 +04:00
										 |  |  | [[nodiscard]] FnMut<bool()> RequestHandler(Command command); | 
					
						
							| 
									
										
										
										
											2018-11-16 16:15:14 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | class Request { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	bool check(Command command, int priority = 0); | 
					
						
							|  |  |  | 	bool handle(FnMut<bool()> handler); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2020-03-30 23:34:07 +04:00
										 |  |  | 	explicit Request(std::vector<Command> commands); | 
					
						
							| 
									
										
										
										
											2018-11-16 16:15:14 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-30 23:34:07 +04:00
										 |  |  | 	std::vector<Command> _commands; | 
					
						
							| 
									
										
										
										
											2018-11-16 16:15:14 +04:00
										 |  |  | 	int _handlerPriority = -1; | 
					
						
							|  |  |  | 	FnMut<bool()> _handler; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-30 23:34:07 +04:00
										 |  |  | 	friend FnMut<bool()> RequestHandler(std::vector<Command> commands); | 
					
						
							| 
									
										
										
										
											2018-11-16 16:15:14 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | rpl::producer<not_null<Request*>> Requests(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Start(); | 
					
						
							|  |  |  | void Finish(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-18 11:58:57 +04:00
										 |  |  | void Listen(not_null<QWidget*> widget); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-16 19:12:39 +04:00
										 |  |  | bool Launch(Command command); | 
					
						
							| 
									
										
										
										
											2023-01-18 11:58:57 +04:00
										 |  |  | bool HandleEvent(not_null<QObject*> object, not_null<QShortcutEvent*> event); | 
					
						
							| 
									
										
										
										
											2018-11-16 16:15:14 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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.
 | 
					
						
							| 
									
										
										
										
											2018-12-13 12:48:31 +04:00
										 |  |  | 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); | 
					
						
							| 
									
										
										
										
											2018-11-16 16:15:14 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace Shortcuts
 |