2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Implement a special context menu for sender userpic.

This commit is contained in:
John Preston
2024-11-04 16:54:01 +04:00
parent 93c01e5f1e
commit 5f037462ed
14 changed files with 137 additions and 16 deletions

View File

@@ -2727,6 +2727,53 @@ bool FillVideoChatMenu(
return has || manager;
}
void FillSenderUserpicMenu(
not_null<SessionController*> controller,
not_null<PeerData*> peer,
Ui::InputField *fieldForMention,
Dialogs::Key searchInEntry,
const PeerMenuCallback &addAction) {
const auto group = (peer->isChat() || peer->isMegagroup());
const auto channel = peer->isChannel();
const auto viewProfileText = group
? tr::lng_context_view_group(tr::now)
: channel
? tr::lng_context_view_channel(tr::now)
: tr::lng_context_view_profile(tr::now);
addAction(viewProfileText, [=] {
controller->showPeerInfo(peer, Window::SectionShow::Way::Forward);
}, channel ? &st::menuIconInfo : &st::menuIconProfile);
const auto showHistoryText = group
? tr::lng_context_open_group(tr::now)
: channel
? tr::lng_context_open_channel(tr::now)
: tr::lng_profile_send_message(tr::now);
addAction(showHistoryText, [=] {
controller->showPeerHistory(peer, Window::SectionShow::Way::Forward);
}, channel ? &st::menuIconChannel : &st::menuIconChatBubble);
const auto username = peer->username();
const auto mention = !username.isEmpty() || peer->isUser();
if (const auto guard = mention ? fieldForMention : nullptr) {
addAction(tr::lng_context_mention(tr::now), crl::guard(guard, [=] {
if (!username.isEmpty()) {
fieldForMention->insertTag('@' + username);
} else {
fieldForMention->insertTag(
peer->shortName(),
PrepareMentionTag(peer->asUser()));
}
}), &st::menuIconUsername);
}
if (searchInEntry) {
addAction(tr::lng_context_search_from(tr::now), [=] {
controller->searchInChat(searchInEntry, peer);
}, &st::menuIconSearch);
}
}
bool IsUnreadThread(not_null<Data::Thread*> thread) {
return thread->chatListBadgesState().unread;
}