From 0384edf191fb4a2803f736ed2a9f55184d864e9d Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 8 Jun 2026 15:41:07 +0300 Subject: [PATCH] Allowed dragging profile id as plain number. --- .../info/profile/info_profile_actions.cpp | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index fcc56c2f3f..2334f2abb8 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -116,6 +116,7 @@ namespace Profile { namespace { constexpr auto kDay = Data::WorkingInterval::kDay; +constexpr auto kPeerIdLinkIndex = uint16(1); class DraggableUrlClickHandler final : public UrlClickHandler { public: @@ -231,7 +232,7 @@ base::options::toggle ShowChannelJoinedBelowAbout({ const auto raw = peer->id.value & PeerId::kChatTypeMask; value.append(Link( Italic(Lang::FormatCountDecimal(raw)), - "internal:~peer_id~:copy:" + QString::number(raw))); + kPeerIdLinkIndex)); } if (ShowChannelJoinedBelowAbout.value()) { if (const auto channel = peer->asChannel()) { @@ -261,6 +262,24 @@ base::options::toggle ShowChannelJoinedBelowAbout({ }); } +void SetupAboutPeerIdDrag( + not_null label, + not_null peer) { + if (!ShowPeerIdBelowAbout.value()) { + return; + } + const auto id = QString::number(peer->id.value & PeerId::kChatTypeMask); + AboutValue( + peer + ) | rpl::on_next([=] { + label->setLink( + kPeerIdLinkIndex, + std::make_shared( + u"internal:~peer_id~:copy:"_q + id, + id)); + }, label->lifetime()); +} + [[nodiscard]] bool AreNonTrivialHours(const Data::WorkingHours &hours) { if (!hours) { return false; @@ -1634,9 +1653,11 @@ Section DetailsFiller::makeInfo() { auto label = user->isBot() ? tr::lng_info_about_label() : tr::lng_info_bio_label(); - addTranslateToMenu( - addInfoLine(std::move(label), AboutWithAdvancedValue(user)).text, + const auto about = addInfoLine( + std::move(label), AboutWithAdvancedValue(user)); + addTranslateToMenu(about.text, AboutWithAdvancedValue(user)); + SetupAboutPeerIdDrag(about.text, user); const auto usernameLine = addInfoOneLine( UsernamesSubtext(_peer, tr::lng_info_username_label()), @@ -1801,6 +1822,7 @@ Section DetailsFiller::makeInfo() { : AboutWithAdvancedValue(_peer)); if (!_topic) { addTranslateToMenu(about.text, AboutWithAdvancedValue(_peer)); + SetupAboutPeerIdDrag(about.text, _peer); } } raw->toggleOn(tracker.atLeastOneShownValue());