2018-11-16 12:15:14 +00: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 13:36:42 +00:00
|
|
|
ChatFirst,
|
|
|
|
ChatLast,
|
2019-03-11 19:01:41 +00:00
|
|
|
ChatSelf,
|
2018-12-29 13:39:17 +00:00
|
|
|
ChatPinned1,
|
|
|
|
ChatPinned2,
|
|
|
|
ChatPinned3,
|
|
|
|
ChatPinned4,
|
|
|
|
ChatPinned5,
|
2018-11-16 13:36:42 +00:00
|
|
|
|
2020-03-30 19:34:07 +00:00
|
|
|
ShowAllChats,
|
2020-03-27 17:51:09 +00:00
|
|
|
ShowFolder1,
|
|
|
|
ShowFolder2,
|
|
|
|
ShowFolder3,
|
|
|
|
ShowFolder4,
|
|
|
|
ShowFolder5,
|
|
|
|
ShowFolder6,
|
2020-03-30 19:34:07 +00:00
|
|
|
ShowFolderLast,
|
2020-03-27 17:51:09 +00:00
|
|
|
|
2020-03-28 23:04:20 +00:00
|
|
|
FolderNext,
|
|
|
|
FolderPrevious,
|
|
|
|
|
2020-01-05 05:14:52 +00:00
|
|
|
ShowArchive,
|
2020-10-07 18:06:22 +00:00
|
|
|
ShowContacts,
|
2020-01-05 05:14:52 +00:00
|
|
|
|
2020-01-18 14:39:00 +00:00
|
|
|
JustSendMessage,
|
2019-12-23 15:14:12 +00:00
|
|
|
SendSilentMessage,
|
|
|
|
ScheduleMessage,
|
|
|
|
|
2020-09-16 12:14:35 +00:00
|
|
|
ReadChat,
|
|
|
|
|
2018-11-16 13:36:42 +00:00
|
|
|
SupportReloadTemplates,
|
|
|
|
SupportToggleMuted,
|
|
|
|
SupportScrollToCurrent,
|
2018-12-30 12:50:23 +00:00
|
|
|
SupportHistoryBack,
|
|
|
|
SupportHistoryForward,
|
2018-11-16 12:15:14 +00:00
|
|
|
};
|
|
|
|
|
2020-03-27 17:51:09 +00:00
|
|
|
constexpr auto kShowFolder = {
|
2020-03-30 19:34:07 +00:00
|
|
|
Command::ShowAllChats,
|
2020-03-27 17:51:09 +00:00
|
|
|
Command::ShowFolder1,
|
|
|
|
Command::ShowFolder2,
|
|
|
|
Command::ShowFolder3,
|
|
|
|
Command::ShowFolder4,
|
|
|
|
Command::ShowFolder5,
|
|
|
|
Command::ShowFolder6,
|
2020-03-30 19:34:07 +00:00
|
|
|
Command::ShowFolderLast,
|
2020-03-27 17:51:09 +00:00
|
|
|
};
|
|
|
|
|
2018-11-16 15:12:39 +00:00
|
|
|
[[nodiscard]] FnMut<bool()> RequestHandler(Command command);
|
2018-11-16 12:15:14 +00:00
|
|
|
|
|
|
|
class Request {
|
|
|
|
public:
|
|
|
|
bool check(Command command, int priority = 0);
|
|
|
|
bool handle(FnMut<bool()> handler);
|
|
|
|
|
|
|
|
private:
|
2020-03-30 19:34:07 +00:00
|
|
|
explicit Request(std::vector<Command> commands);
|
2018-11-16 12:15:14 +00:00
|
|
|
|
2020-03-30 19:34:07 +00:00
|
|
|
std::vector<Command> _commands;
|
2018-11-16 12:15:14 +00:00
|
|
|
int _handlerPriority = -1;
|
|
|
|
FnMut<bool()> _handler;
|
|
|
|
|
2020-03-30 19:34:07 +00:00
|
|
|
friend FnMut<bool()> RequestHandler(std::vector<Command> commands);
|
2018-11-16 12:15:14 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
rpl::producer<not_null<Request*>> Requests();
|
|
|
|
|
|
|
|
void Start();
|
|
|
|
void Finish();
|
|
|
|
|
2018-11-16 15:12:39 +00:00
|
|
|
bool Launch(Command command);
|
2018-11-16 12:15:14 +00:00
|
|
|
bool HandleEvent(not_null<QShortcutEvent*> event);
|
|
|
|
|
|
|
|
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 08:48:31 +00: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 12:15:14 +00:00
|
|
|
|
|
|
|
} // namespace Shortcuts
|