diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index e8121204da..d029a9a780 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -644,6 +644,17 @@ bool OpenExternalLink( context); } +bool CopyPeerId( + Window::SessionController *controller, + const Match &match, + const QVariant &context) { + TextUtilities::SetClipboardText(TextForMimeData{ match->captured(1) }); + if (controller) { + controller->showToast(tr::lng_text_copied(tr::now)); + } + return true; +} + void ExportTestChatTheme( not_null controller, not_null theme) { @@ -985,6 +996,10 @@ const std::vector &InternalUrlHandlers() { u"^url:(.+)$"_q, OpenExternalLink }, + { + u"^copy:(.+)$"_q, + CopyPeerId + } }; return Result; } diff --git a/Telegram/SourceFiles/info/profile/info_profile_values.cpp b/Telegram/SourceFiles/info/profile/info_profile_values.cpp index 878366d155..198e739756 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_values.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_values.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "info/profile/info_profile_values.h" +#include "base/options.h" #include "info/profile/info_profile_badge.h" #include "core/application.h" #include "core/click_handler_types.h" @@ -37,6 +38,12 @@ namespace { using UpdateFlag = Data::PeerUpdate::Flag; +base::options::toggle ShowPeerIdBelowAbout({ + .id = kOptionShowPeerIdBelowAbout, + .name = "Show Peer IDs in Profile", + .description = "Show peer IDs from API below their Bio / Description.", +}); + auto PlainAboutValue(not_null peer) { return peer->session().changes().peerFlagsValue( peer, @@ -87,6 +94,8 @@ void StripExternalLinks(TextWithEntities &text) { } // namespace +const char kOptionShowPeerIdBelowAbout[] = "show-peer-id-below-about"; + rpl::producer NameValue(not_null peer) { return peer->session().changes().peerFlagsValue( peer, @@ -209,6 +218,16 @@ TextWithEntities AboutWithEntities( if (stripExternal) { StripExternalLinks(result); } + if (ShowPeerIdBelowAbout.value()) { + using namespace Ui::Text; + if (!result.empty()) { + result.append("\n"); + } + result.append(Italic(u"id: "_q)); + const auto raw = peer->id.value & PeerId::kChatTypeMask; + const auto id = QString::number(raw); + result.append(Link(Italic(id), "internal:copy:" + id)); + } return result; } diff --git a/Telegram/SourceFiles/info/profile/info_profile_values.h b/Telegram/SourceFiles/info/profile/info_profile_values.h index b3a110fe41..67c9238fb2 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_values.h +++ b/Telegram/SourceFiles/info/profile/info_profile_values.h @@ -35,6 +35,8 @@ enum class SharedMediaType : signed char; namespace Info::Profile { +extern const char kOptionShowPeerIdBelowAbout[]; + inline auto ToSingleLine() { return rpl::map([](const QString &text) { return TextUtilities::SingleLine(text); diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp b/Telegram/SourceFiles/settings/settings_experimental.cpp index 97447adf13..6104cabb13 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.cpp +++ b/Telegram/SourceFiles/settings/settings_experimental.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/launcher.h" #include "chat_helpers/tabbed_panel.h" #include "dialogs/dialogs_widget.h" +#include "info/profile/info_profile_values.h" #include "lang/lang_keys.h" #include "mainwindow.h" #include "media/player/media_player_instance.h" @@ -141,6 +142,7 @@ void SetupExperimental( addToggle(Dialogs::kOptionForumHideChatsList); addToggle(Core::kOptionFractionalScalingEnabled); addToggle(Window::kOptionViewProfileInChatsListContextMenu); + addToggle(Info::Profile::kOptionShowPeerIdBelowAbout); addToggle(Ui::GL::kOptionAllowLinuxNvidiaOpenGL); addToggle(Ui::kOptionUseSmallMsgBubbleRadius); addToggle(Media::Player::kOptionDisableAutoplayNext);