mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-14 15:33:38 +00:00
Added new shortcut to toggle web page preview in messages field.
This commit is contained in:
@@ -739,6 +739,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_shortcuts_silent_send" = "Silent send";
|
||||
"lng_shortcuts_schedule" = "Schedule";
|
||||
"lng_shortcuts_ai_compose_apply" = "Apply AI style to text";
|
||||
"lng_shortcuts_toggle_link_preview" = "Toggle link preview";
|
||||
"lng_shortcuts_read_chat" = "Mark chat as read";
|
||||
"lng_shortcuts_archive_chat" = "Archive chat";
|
||||
"lng_shortcuts_media_fullscreen" = "Toggle video fullscreen";
|
||||
|
||||
@@ -133,6 +133,7 @@ const auto CommandByName = base::flat_map<QString, Command>{
|
||||
{ u"message_silently"_q , Command::SendSilentMessage },
|
||||
{ u"message_scheduled"_q , Command::ScheduleMessage },
|
||||
{ u"ai_compose_apply"_q , Command::ComposeAiApplyInPlace },
|
||||
{ u"toggle_webpage_preview"_q , Command::ToggleWebPagePreview },
|
||||
{ u"media_viewer_video_fullscreen"_q , Command::MediaViewerFullscreen },
|
||||
{ u"show_scheduled"_q , Command::ShowScheduled },
|
||||
{ u"archive_chat"_q , Command::ArchiveChat },
|
||||
@@ -157,6 +158,7 @@ const base::flat_map<Command, QString> &CommandNames() {
|
||||
Command::SendSilentMessage,
|
||||
Command::ScheduleMessage,
|
||||
Command::ComposeAiApplyInPlace,
|
||||
Command::ToggleWebPagePreview,
|
||||
Command::MediaViewerFullscreen,
|
||||
Command::ShowScheduled,
|
||||
Command::ArchiveChat,
|
||||
|
||||
@@ -69,6 +69,7 @@ enum class Command {
|
||||
SendSilentMessage,
|
||||
ScheduleMessage,
|
||||
ComposeAiApplyInPlace,
|
||||
ToggleWebPagePreview,
|
||||
|
||||
RecordVoice,
|
||||
RecordRound,
|
||||
|
||||
@@ -2312,6 +2312,17 @@ void HistoryWidget::setupShortcuts() {
|
||||
triggerAiApplyInPlace();
|
||||
return true;
|
||||
});
|
||||
_preview
|
||||
&& (_previewDrawPreview || _preview->draft().removed)
|
||||
&& request->check(Command::ToggleWebPagePreview, 1)
|
||||
&& request->handle([=] {
|
||||
if (_previewDrawPreview) {
|
||||
_preview->apply({ .removed = true });
|
||||
} else {
|
||||
_preview->apply({}, true);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (showRecordButton()
|
||||
&& _canSendMessages
|
||||
&& _joinChannel->isHidden()
|
||||
|
||||
@@ -3353,6 +3353,18 @@ void ComposeControls::initVoiceRecordBar() {
|
||||
triggerAiApplyInPlace();
|
||||
return true;
|
||||
});
|
||||
_preview
|
||||
&& (_previewShown || _preview->draft().removed)
|
||||
&& request->check(Command::ToggleWebPagePreview, 1)
|
||||
&& request->handle([=] {
|
||||
if (_previewShown) {
|
||||
_preview->apply({ .removed = true });
|
||||
} else {
|
||||
_preview->apply({}, true);
|
||||
}
|
||||
saveDraftWithTextNow();
|
||||
return true;
|
||||
});
|
||||
}, _voiceRecordBar->lifetime());
|
||||
}
|
||||
|
||||
@@ -4316,6 +4328,7 @@ void ComposeControls::tryProcessKeyInput(not_null<QKeyEvent*> e) {
|
||||
void ComposeControls::initWebpageProcess() {
|
||||
if (!_history) {
|
||||
_preview = nullptr;
|
||||
_previewShown = false;
|
||||
_header->previewUnregister();
|
||||
return;
|
||||
}
|
||||
@@ -4324,6 +4337,11 @@ void ComposeControls::initWebpageProcess() {
|
||||
_history,
|
||||
_field);
|
||||
|
||||
_preview->parsedValue(
|
||||
) | rpl::on_next([=](Controls::WebpageParsed parsed) {
|
||||
_previewShown = !!parsed;
|
||||
}, _historyLifetime);
|
||||
|
||||
_preview->repaintRequests(
|
||||
) | rpl::on_next(crl::guard(_header.get(), [=] {
|
||||
_header->update();
|
||||
|
||||
@@ -547,6 +547,7 @@ private:
|
||||
bool _canAddMedia = false;
|
||||
|
||||
std::unique_ptr<Controls::WebpageProcessor> _preview;
|
||||
bool _previewShown = false;
|
||||
|
||||
rpl::lifetime _historyLifetime;
|
||||
rpl::lifetime _uploaderSubscriptions;
|
||||
|
||||
@@ -182,6 +182,7 @@ void WebpageResolver::request(const QString &link, bool force) {
|
||||
void WebpageResolver::cancel(const QString &link) {
|
||||
if (_requestLink == link) {
|
||||
_api.request(base::take(_requestId)).cancel();
|
||||
_requestLink = QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ struct Labeled {
|
||||
{ C::ScheduleMessage, tr::lng_shortcuts_schedule() },
|
||||
separator,
|
||||
{ C::ComposeAiApplyInPlace, tr::lng_shortcuts_ai_compose_apply() },
|
||||
{ C::ToggleWebPagePreview, tr::lng_shortcuts_toggle_link_preview() },
|
||||
separator,
|
||||
{ C::RecordVoice, tr::lng_shortcuts_record_voice_message() },
|
||||
{ C::RecordRound, tr::lng_shortcuts_record_round_message() },
|
||||
|
||||
Reference in New Issue
Block a user