Added shortcuts to start recording of voice or round message.

Fixed #29633.
This commit is contained in:
23rd 2025-08-19 16:43:28 +03:00
parent fbc1d75e9a
commit 76e814944d
6 changed files with 44 additions and 0 deletions

View file

@ -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";

View file

@ -112,6 +112,8 @@ const auto CommandByName = base::flat_map<QString, Command>{
{ 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<QString, Command>{
{ 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<Command, QString> &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();
}

View file

@ -66,6 +66,9 @@ enum class Command {
SendSilentMessage,
ScheduleMessage,
RecordVoice,
RecordRound,
ReadChat,
ArchiveChat,

View file

@ -2105,6 +2105,18 @@ void HistoryWidget::setupShortcuts() {
std::make_shared<Scheduled>(_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

View file

@ -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<Shortcuts::Request*> 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() {

View file

@ -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() },