From f5e016d8f69a943e533e6c1fe7c5a961cb0d4883 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Sun, 11 Sep 2022 03:26:20 +0300 Subject: [PATCH] [Improvement] Shortcut to save draft --- Telegram/SourceFiles/core/shortcuts.cpp | 5 +++++ Telegram/SourceFiles/core/shortcuts.h | 2 ++ Telegram/SourceFiles/history/history_widget.cpp | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/Telegram/SourceFiles/core/shortcuts.cpp b/Telegram/SourceFiles/core/shortcuts.cpp index 7bc864ddc..be3dc7eec 100644 --- a/Telegram/SourceFiles/core/shortcuts.cpp +++ b/Telegram/SourceFiles/core/shortcuts.cpp @@ -106,6 +106,8 @@ const auto CommandByName = base::flat_map{ { u"message_scheduled"_q , Command::ScheduleMessage }, { u"media_viewer_video_fullscreen"_q , Command::MediaViewerFullscreen }, // + + { qsl("save_draft") , Command::SaveDraft }, }; const auto CommandNames = base::flat_map{ @@ -152,6 +154,8 @@ const auto CommandNames = base::flat_map{ { Command::ShowContacts , u"show_contacts"_q }, { Command::ReadChat , u"read_chat"_q }, + + { Command::SaveDraft , u"save_draft"_q }, }; class Manager { @@ -423,6 +427,7 @@ void Manager::fillDefaults() { set(u"ctrl+j"_q, Command::ShowContacts); set(u"ctrl+r"_q, Command::ReadChat); + set(u"ctrl+s"_q, Command::SaveDraft); } void Manager::writeDefaultFile() { diff --git a/Telegram/SourceFiles/core/shortcuts.h b/Telegram/SourceFiles/core/shortcuts.h index b562517d5..5ea469fa1 100644 --- a/Telegram/SourceFiles/core/shortcuts.h +++ b/Telegram/SourceFiles/core/shortcuts.h @@ -73,6 +73,8 @@ enum class Command { SupportScrollToCurrent, SupportHistoryBack, SupportHistoryForward, + + SaveDraft, }; [[maybe_unused]] constexpr auto kShowFolder = { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index d9e2978a3..1287980e6 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1965,6 +1965,10 @@ void HistoryWidget::setupShortcuts() { return true; }); } + request->check(Command::SaveDraft, 1) && request->handle([=] { + saveCloudDraft(); + return true; + }); }, lifetime()); }