diff --git a/Telegram/Resources/icons/menu/mention.png b/Telegram/Resources/icons/menu/mention.png new file mode 100644 index 000000000..bf6e9f6c5 Binary files /dev/null and b/Telegram/Resources/icons/menu/mention.png differ diff --git a/Telegram/Resources/icons/menu/mention@2x.png b/Telegram/Resources/icons/menu/mention@2x.png new file mode 100644 index 000000000..f82cb39d7 Binary files /dev/null and b/Telegram/Resources/icons/menu/mention@2x.png differ diff --git a/Telegram/Resources/icons/menu/mention@3x.png b/Telegram/Resources/icons/menu/mention@3x.png new file mode 100644 index 000000000..0b0dcb6f5 Binary files /dev/null and b/Telegram/Resources/icons/menu/mention@3x.png differ diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index d31f33cef..c9ae3e3e2 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -144,6 +144,7 @@ "ktg_forward_subtitle_uncaptioned": "uncaptioned", "ktg_forward_subtitle_group_all_media": "as albums", "ktg_forward_subtitle_separate_messages": "one by one", + "ktg_profile_mention_user": "Mention user", "ktg_filters_exclude_not_owned": "Not owned", "ktg_filters_exclude_not_admin": "Not administrated", "ktg_filters_exclude_owned": "Owned", diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 538dc241a..af70af140 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1657,6 +1657,14 @@ base::unique_qptr ParticipantsBoxController::rowContextMenu( : Dialogs::Key(), user); }), &st::menuIconSearch); + if (const auto openedPeer = mainwidget->peer()) { + if (Data::CanSendTexts(openedPeer) && participant->isUser()) { + result->addAction( + ktr("ktg_profile_mention_user"), + crl::guard(this, [=] { mainwidget->mentionUser(user); }), + &st::menuIconMention); + } + } } } if (const auto by = _additional.restrictedBy(participant)) { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 2165a0b91..fc9a01a48 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -7480,6 +7480,25 @@ bool HistoryWidget::sendExistingPhoto( return true; } +void HistoryWidget::mentionUser(PeerData *peer) { + if (!peer || !peer->isUser()) { + return; + } + + const auto user = peer->asUser(); + QString replacement, entityTag; + if (user->username.isEmpty()) { + replacement = user->firstName; + if (replacement.isEmpty()) { + replacement = user->name; + } + entityTag = PrepareMentionTag(user); + } else { + replacement = '@' + user->username; + } + _field->insertTag(replacement, entityTag); +} + void HistoryWidget::showInfoTooltip( const TextWithEntities &text, Fn hiddenCallback) { diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 6647a32e9..e8e59f4c5 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -272,6 +272,8 @@ public: not_null photo, Api::SendOptions options); + void mentionUser(PeerData *peer); + void showInfoTooltip( const TextWithEntities &text, Fn hiddenCallback); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index acec22755..5f021978a 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2697,6 +2697,14 @@ int MainWidget::backgroundFromY() const { return -getMainSectionTop(); } +void MainWidget::mentionUser(PeerData *peer) { + if (!_history->peer() || !_history->peer()->canWrite()) { + return; + } + + _history->mentionUser(peer); +} + bool MainWidget::contentOverlapped(const QRect &globalRect) { return _history->contentOverlapped(globalRect) || _playerPlaylist->overlaps(globalRect); diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 263fa4f95..ddf084b2a 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -203,6 +203,8 @@ public: bool contentOverlapped(const QRect &globalRect); + void mentionUser(PeerData *peer); + void showChooseReportMessages( not_null peer, Ui::ReportReason reason, diff --git a/Telegram/SourceFiles/ui/menu_icons.style b/Telegram/SourceFiles/ui/menu_icons.style index f1c790ccb..961b8d049 100644 --- a/Telegram/SourceFiles/ui/menu_icons.style +++ b/Telegram/SourceFiles/ui/menu_icons.style @@ -79,6 +79,7 @@ menuIconPersonal: icon {{ "menu/personal", menuIconColor }}; menuIconPorn: icon {{ "menu/porn", menuIconColor }}; menuIconViolence: icon {{ "menu/violence", menuIconColor }}; menuIconHide: icon {{ "menu/hide", menuIconColor }}; +menuIconMention: icon {{ "menu/mention", menuSubmenuArrowFg }}; menuIconMuteFor: icon {{ "menu/mute_for", menuIconColor }}; menuIconSilent: icon {{ "menu/silent", menuIconColor }}; menuIconCustomize: icon {{ "menu/customize", menuIconColor }};