diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index db20a2dded..87a9b0017f 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -694,6 +694,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_shortcuts_media_fullscreen" = "Toggle video fullscreen"; "lng_shortcuts_show_chat_menu" = "Show chat menu"; "lng_shortcuts_show_chat_preview" = "Show chat preview"; +"lng_shortcuts_record_voice_message" = "Record Voice Message"; +"lng_shortcuts_record_round_message" = "Record Round Message"; "lng_settings_chat_reactions_title" = "Quick Reaction"; "lng_settings_chat_reactions_subtitle" = "Choose your favorite reaction"; diff --git a/Telegram/SourceFiles/core/shortcuts.cpp b/Telegram/SourceFiles/core/shortcuts.cpp index fe26109b7c..061120af0d 100644 --- a/Telegram/SourceFiles/core/shortcuts.cpp +++ b/Telegram/SourceFiles/core/shortcuts.cpp @@ -112,6 +112,8 @@ const auto CommandByName = base::flat_map{ { u"show_chat_menu"_q , Command::ShowChatMenu }, { u"show_chat_preview"_q , Command::ShowChatPreview }, + { u"record_voice"_q , Command::RecordVoice }, + // Shortcuts that have no default values. { u"message"_q , Command::JustSendMessage }, { u"message_silently"_q , Command::SendSilentMessage }, @@ -119,6 +121,7 @@ const auto CommandByName = base::flat_map{ { u"media_viewer_video_fullscreen"_q , Command::MediaViewerFullscreen }, { u"show_scheduled"_q , Command::ShowScheduled }, { u"archive_chat"_q , Command::ArchiveChat }, + { u"record_round"_q , Command::RecordRound }, // }; @@ -140,6 +143,7 @@ const base::flat_map &CommandNames() { Command::MediaViewerFullscreen, Command::ShowScheduled, Command::ArchiveChat, + Command::RecordRound, }; class Manager { @@ -509,6 +513,8 @@ void Manager::fillDefaults() { set(u"ctrl+\\"_q, Command::ShowChatMenu); set(u"ctrl+]"_q, Command::ShowChatPreview); + set(u"ctrl+r"_q, Command::RecordVoice); + _defaults = keysCurrents(); } diff --git a/Telegram/SourceFiles/core/shortcuts.h b/Telegram/SourceFiles/core/shortcuts.h index 7be77d4eca..ee832915b0 100644 --- a/Telegram/SourceFiles/core/shortcuts.h +++ b/Telegram/SourceFiles/core/shortcuts.h @@ -66,6 +66,9 @@ enum class Command { SendSilentMessage, ScheduleMessage, + RecordVoice, + RecordRound, + ReadChat, ArchiveChat, diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index cb534111fd..a0cdec1702 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -2105,6 +2105,18 @@ void HistoryWidget::setupShortcuts() { std::make_shared(_history)); return true; }); + if (showRecordButton()) { + const auto isVoice = request->check(Command::RecordVoice, 1); + const auto isRound = !isVoice + && request->check(Command::RecordRound, 1); + (isVoice || isRound) && request->handle([=] { + if (_voiceRecordBar) { + _voiceRecordBar->startRecordingAndLock(isRound); + return true; + } + return false; + }); + } if (session().supportMode()) { request->check( Command::SupportToggleMuted diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 7bd49e3177..6caddd9ba6 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "chat_helpers/field_autocomplete.h" #include "core/application.h" #include "core/core_settings.h" +#include "core/shortcuts.h" #include "core/ui_integration.h" #include "data/notify/data_notify_settings.h" #include "data/data_changes.h" @@ -2604,6 +2605,23 @@ void ComposeControls::initVoiceRecordBar() { ) | rpl::start_with_next([=] { updateSendButtonType(); }, _wrap->lifetime()); + + Shortcuts::Requests( + ) | rpl::filter([=] { + return Ui::AppInFocus(); + }) | rpl::start_with_next([=](not_null request) { + using Command = Shortcuts::Command; + const auto isVoice = request->check(Command::RecordVoice, 1); + const auto isRound = !isVoice + && request->check(Command::RecordRound, 1); + (isVoice || isRound) && request->handle([=] { + if (_voiceRecordBar) { + _voiceRecordBar->startRecordingAndLock(isRound); + return true; + } + return false; + }); + }, _voiceRecordBar->lifetime()); } void ComposeControls::updateWrappingVisibility() { diff --git a/Telegram/SourceFiles/settings/settings_shortcuts.cpp b/Telegram/SourceFiles/settings/settings_shortcuts.cpp index ecd2f7914c..d65f96b4cd 100644 --- a/Telegram/SourceFiles/settings/settings_shortcuts.cpp +++ b/Telegram/SourceFiles/settings/settings_shortcuts.cpp @@ -104,6 +104,9 @@ struct Labeled { { C::SendSilentMessage, tr::lng_shortcuts_silent_send() }, { C::ScheduleMessage, tr::lng_shortcuts_schedule() }, separator, + { C::RecordVoice, tr::lng_shortcuts_record_voice_message() }, + { C::RecordRound, tr::lng_shortcuts_record_round_message() }, + separator, { C::MediaViewerFullscreen, tr::lng_shortcuts_media_fullscreen() }, separator, { C::MediaPlay, tr::lng_shortcuts_media_play() },