diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index bf3983f31..085edb3e4 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -84,6 +84,7 @@ "ktg_hide_pinned_message": "Hide", "ktg_stickers_copy_title": "Copy name", "ktg_stickers_title_copied": "Sticker pack name copied to clipboard.", + "ktg_context_show_messages_from": "User messages", "ktg_settings_tray_icon": "Tray icon", "ktg_settings_tray_icon_default": "Default", "ktg_settings_tray_icon_blue": "Blue", diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 88a349001..bc4b724dd 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/peers/edit_participants_box.h" +#include "kotato/kotato_lang.h" +#include "core/application.h" #include "api/api_chat_participants.h" #include "boxes/peers/edit_participant_box.h" #include "boxes/peers/add_participants_box.h" @@ -20,6 +22,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mtproto/mtproto_config.h" #include "apiwrap.h" #include "lang/lang_keys.h" +#include "mainwindow.h" +#include "mainwidget.h" #include "dialogs/dialogs_indexed_list.h" #include "data/data_peer_values.h" #include "data/data_session.h" @@ -32,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/outline_segments.h" #include "ui/widgets/popup_menu.h" #include "info/profile/info_profile_values.h" +#include "window/window_controller.h" #include "window/window_session_controller.h" #include "history/history.h" #include "styles/style_menu_icons.h" @@ -1630,6 +1635,20 @@ base::unique_qptr ParticipantsBoxController::rowContextMenu( ? &st::menuIconProfile : &st::menuIconInfo)); } + if (const auto window = _navigation->parentController()) { + if (const auto mainwidget = window->widget()->sessionContent()) { + result->addAction( + ktr("ktg_context_show_messages_from"), + crl::guard(this, [=] { + mainwidget->searchMessages( + " ", + (_peer && !_peer->isUser()) + ? _peer->owner().history(_peer).get() + : Dialogs::Key(), + user); + }), &st::menuIconSearch); + } + } if (const auto by = _additional.restrictedBy(participant)) { result->addAction( (_role == Role::Kicked diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index cf2a9c3d8..cd0846670 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwidget.h" #include "main/main_domain.h" #include "main/main_session.h" +#include "main/main_account.h" #include "main/main_session_settings.h" #include "api/api_chat_filters.h" #include "apiwrap.h" @@ -2088,7 +2089,10 @@ void Widget::showMainMenu() { controller()->widget()->showMainMenu(); } -void Widget::searchMessages(QString query, Key inChat) { +void Widget::searchMessages( + QString query, + Key inChat, + UserData *from) { if (_childList) { const auto forum = controller()->shownForum().current(); const auto topic = inChat.topic(); @@ -2138,13 +2142,19 @@ void Widget::searchMessages(QString query, Key inChat) { cancelSearch(); setSearchInChat(inChat, nullptr, tags); } - setSearchQuery(query); + if (!query.trimmed().isEmpty()) { + setSearchQuery(query); + } applySearchUpdate(true); _searchTimer.cancel(); searchMessages(); session().local().saveRecentSearchHashtags(query); } + if (inChat && from) { + setSearchInChat(inChat, from); + applySearchUpdate(true); + } } void Widget::searchTopics() { diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index b183cb36f..903ddfba2 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -120,7 +120,7 @@ public: void scrollToEntry(const RowDescriptor &entry); - void searchMessages(QString query, Key inChat = {}); + void searchMessages(QString query, Key inChat = {}, UserData *from = nullptr); void searchTopics(); void searchMore(); diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 235614f8b..55ea6de2a 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -8,6 +8,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_inner_widget.h" #include "kotato/kotato_settings.h" +#include "kotato/kotato_lang.h" +#include "mainwidget.h" #include "chat_helpers/stickers_emoji_pack.h" #include "core/file_utilities.h" #include "core/click_handler_types.h" @@ -2162,6 +2164,17 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { Window::ToggleMessagePinned(controller, pinItemId, !isPinned); }), isPinned ? &st::menuIconUnpin : &st::menuIconPin); } + const auto peer = item->history()->peer; + if (peer->isChat() || peer->isMegagroup()) { + _menu->addAction(ktr("ktg_context_show_messages_from"), [=] { + controller->content()->searchMessages( + " ", + (peer && !peer->isUser()) + ? peer->owner().history(peer).get() + : Dialogs::Key(), + item->from()->asUser()); + }, &st::menuIconSearch); + } if (!item->isService() && peerIsChannel(itemId.peer) && !_peer->isMegagroup()) { diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index faaa1b2d2..3a5415a9c 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -731,9 +731,9 @@ void MainWidget::hideSingleUseKeyboard(FullMsgId replyToId) { _history->hideSingleUseKeyboard(replyToId); } -void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) { +void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat, UserData *from) { if (controller()->isPrimary()) { - _dialogs->searchMessages(query, inChat); + _dialogs->searchMessages(query, inChat, from); if (isOneColumn()) { _controller->clearSectionStack(); } else { @@ -753,7 +753,7 @@ void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) { const auto account = &session().account(); if (const auto window = Core::App().windowFor(account)) { if (const auto controller = window->sessionController()) { - controller->content()->searchMessages(query, inChat); + controller->content()->searchMessages(query, inChat, from); controller->widget()->activate(); } } diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 14e1ef2ab..ca6748c31 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -185,7 +185,7 @@ public: void sendBotCommand(Bot::SendCommandRequest request); void hideSingleUseKeyboard(FullMsgId replyToId); - void searchMessages(const QString &query, Dialogs::Key inChat); + void searchMessages(const QString &query, Dialogs::Key inChat, UserData *from = nullptr); void setChatBackground( const Data::WallPaper &background,