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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user