Mention user from context menu
This commit is contained in:
parent
22bce76f1d
commit
d6face04c9
13 changed files with 52 additions and 0 deletions
|
|
@ -2634,4 +2634,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ktg_forward_subtitle_group_all_media" = "as albums";
|
||||
"ktg_forward_subtitle_separate_messages" = "one by one";
|
||||
|
||||
"ktg_profile_mention_user" = "Mention user";
|
||||
|
||||
// Keys finished
|
||||
|
|
|
|||
|
|
@ -183,6 +183,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",
|
||||
|
||||
// This string should always be last for better work with Git.
|
||||
"dummy_last_string": ""
|
||||
|
|
|
|||
|
|
@ -183,6 +183,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",
|
||||
|
||||
// This string should always be last for better work with Git.
|
||||
"dummy_last_string": ""
|
||||
|
|
|
|||
|
|
@ -191,6 +191,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",
|
||||
|
||||
// This string should always be last for better work with Git.
|
||||
"dummy_last_string": ""
|
||||
|
|
|
|||
|
|
@ -183,6 +183,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",
|
||||
|
||||
// This string should always be last for better work with Git.
|
||||
"dummy_last_string": ""
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@
|
|||
"ktg_forward_subtitle_uncaptioned": "без подписей",
|
||||
"ktg_forward_subtitle_group_all_media": "альбомами",
|
||||
"ktg_forward_subtitle_separate_messages": "по одному",
|
||||
"ktg_profile_mention_user": "Упомянуть пользователя",
|
||||
|
||||
// This string should always be last for better work with Git.
|
||||
"dummy_last_string": ""
|
||||
|
|
|
|||
|
|
@ -183,6 +183,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",
|
||||
|
||||
// This string should always be last for better work with Git.
|
||||
"dummy_last_string": ""
|
||||
|
|
|
|||
|
|
@ -190,6 +190,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",
|
||||
|
||||
// This string should always be last for better work with Git.
|
||||
"dummy_last_string": ""
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "facades.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"
|
||||
|
|
@ -1426,6 +1427,17 @@ base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu(
|
|||
}
|
||||
return result;
|
||||
}
|
||||
if (const auto window = App::wnd()) {
|
||||
if (const auto mainwidget = window->sessionContent()) {
|
||||
if (const auto openedPeer = mainwidget->peer()) {
|
||||
if (openedPeer->canWrite()) {
|
||||
result->addAction(
|
||||
tr::ktg_profile_mention_user(tr::now),
|
||||
crl::guard(this, [=] { mainwidget->mentionUser(user); }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_additional.canAddOrEditAdmin(user)) {
|
||||
const auto isAdmin = _additional.isCreator(user)
|
||||
|| _additional.adminRights(user).has_value();
|
||||
|
|
|
|||
|
|
@ -5690,6 +5690,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<void()> hiddenCallback) {
|
||||
|
|
|
|||
|
|
@ -261,6 +261,8 @@ public:
|
|||
not_null<PhotoData*> photo,
|
||||
Api::SendOptions options);
|
||||
|
||||
void mentionUser(PeerData *peer);
|
||||
|
||||
void showInfoTooltip(
|
||||
const TextWithEntities &text,
|
||||
Fn<void()> hiddenCallback);
|
||||
|
|
|
|||
|
|
@ -2578,6 +2578,14 @@ void MainWidget::searchInChat(Dialogs::Key chat) {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWidget::mentionUser(PeerData *peer) {
|
||||
if (!_history->peer() || !_history->peer()->canWrite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
_history->mentionUser(peer);
|
||||
}
|
||||
|
||||
void MainWidget::openPeerByName(
|
||||
const QString &username,
|
||||
MsgId msgId,
|
||||
|
|
|
|||
|
|
@ -220,6 +220,8 @@ public:
|
|||
|
||||
void searchInChat(Dialogs::Key chat);
|
||||
|
||||
void mentionUser(PeerData *peer);
|
||||
|
||||
void ui_showPeerHistory(
|
||||
PeerId peer,
|
||||
const SectionShow ¶ms,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue