diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index f32e6077b9..a95a541cbf 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/widgets/buttons.h" #include "ui/widgets/box_content_divider.h" +#include "ui/widgets/popup_menu.h" #include "ui/boxes/report_box.h" #include "ui/boxes/confirm_box.h" #include "ui/layers/generic_box.h" @@ -386,8 +387,34 @@ object_ptr DetailsFiller::setupInfo() { _peer, Window::Show(controller), QString()); + const auto hook = [=](Ui::FlatLabel::ContextMenuRequest request) { + if (!request.link) { + return; + } + const auto text = request.link->copyToClipboardContextItemText(); + if (text.isEmpty()) { + return; + } + const auto link = request.link->copyToClipboardText(); + request.menu->addAction( + text, + [=] { QGuiApplication::clipboard()->setText(link); }); + const auto last = link.lastIndexOf('/'); + if (last < 0) { + return; + } + const auto mention = '@' + link.mid(last + 1); + if (mention.size() < 2) { + return; + } + request.menu->addAction( + tr::lng_context_copy_mention(tr::now), + [=] { QGuiApplication::clipboard()->setText(mention); }); + }; usernameLine.text->overrideLinkClickHandler(callback); usernameLine.subtext->overrideLinkClickHandler(callback); + usernameLine.text->setContextMenuHook(hook); + usernameLine.subtext->setContextMenuHook(hook); const auto usernameLabel = usernameLine.text; if (user->isBot()) { const auto copyUsername = Ui::CreateChild( diff --git a/Telegram/lib_ui b/Telegram/lib_ui index e6064719df..0937ac0ad0 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit e6064719dfb885910b73e0e90da8a66afa98f75a +Subproject commit 0937ac0ad0feaf3cbccf009e0e1f2a04cc0ef9f8