From 241db5e405ba56dcd4507e2b783cee75f84a7ed6 Mon Sep 17 00:00:00 2001 From: c0re100 Date: Fri, 10 Jul 2020 06:06:31 +0800 Subject: [PATCH] Support forward multiple messages --- Telegram/Resources/langs/lang.strings | 1 + .../SourceFiles/history/history_inner_widget.cpp | 10 ++++++++++ Telegram/SourceFiles/history/history_widget.cpp | 12 ++++++++++++ Telegram/SourceFiles/history/history_widget.h | 1 + 4 files changed, 24 insertions(+) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 69f678470f..4c636d00fa 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2405,6 +2405,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_context_repeat_msg" = "Repeat This Message"; "lng_context_repeat_msg_no_fwd" = "Repeat This Message(!Forward)"; "lng_context_forward_msg_no_quote" = "Forward Message(W/O quote)"; +"lng_context_forward_selected_no_quote" = "Forward Selected(W/O quote)"; "lng_message_id" = "Message ID: "; "lng_admin_log_banned_send_stickers2" = "Send stickers"; diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index a120ae4200..8a1e1ec5e7 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -1644,6 +1644,11 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { _widget->forwardSelected(); }); } + if (selectedState.count > 0 && selectedState.canForwardCount == selectedState.count) { + _menu->addAction(tr::lng_context_forward_selected_no_quote(tr::now), [=] { + _widget->forwardNoQuoteSelected(); + }); + } if (selectedState.count > 0 && selectedState.canDeleteCount == selectedState.count) { _menu->addAction(tr::lng_context_delete_selected(tr::now), [=] { _widget->confirmDeleteSelected(); @@ -1806,6 +1811,11 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { _widget->forwardSelected(); }); } + if (selectedState.count > 0 && selectedState.count == selectedState.canForwardCount) { + _menu->addAction(tr::lng_context_forward_selected_no_quote(tr::now), [=] { + _widget->forwardNoQuoteSelected(); + }); + } if (selectedState.count > 0 && selectedState.count == selectedState.canDeleteCount) { _menu->addAction(tr::lng_context_delete_selected(tr::now), [=] { _widget->confirmDeleteSelected(); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 6957c4a970..69164099ab 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -6417,6 +6417,18 @@ void HistoryWidget::forwardSelected() { }); } +void HistoryWidget::forwardNoQuoteSelected() { + if (!_list) { + return; + } + const auto weak = Ui::MakeWeak(this); + Window::ShowForwardNoQuoteMessagesBox(controller(), getSelectedItems(), [=] { + if (const auto strong = weak.data()) { + strong->clearSelected(); + } + }); +} + void HistoryWidget::confirmDeleteSelected() { if (!_list) return; diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index baa297a82a..72849e236e 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -247,6 +247,7 @@ class HistoryWidget final : public Window::AbstractSectionWidget { QPixmap grabForShowAnimation(const Window::SectionSlideParams ¶ms); void forwardSelected(); + void forwardNoQuoteSelected(); void confirmDeleteSelected(); void clearSelected();