diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index ad6b8519f..404b82e71 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "info/profile/info_profile_actions.h" +#include "base/options.h" #include "data/data_peer_values.h" #include "data/data_session.h" #include "data/data_folder.h" @@ -71,6 +72,12 @@ namespace Info { namespace Profile { namespace { +base::options::toggle ShowPeerIdBelowAbout({ + .id = kOptionShowPeerIdBelowAbout, + .name = "Show Peer IDs in Profile", + .description = "Show peer IDs from API below their Bio / Description.", +}); + [[nodiscard]] rpl::producer UsernamesSubtext( not_null peer, rpl::producer fallback) { @@ -131,6 +138,27 @@ namespace { return result; } +[[nodiscard]] rpl::producer AboutWithIdValue( + not_null peer) { + + return AboutValue( + peer + ) | rpl::map([=](TextWithEntities &&value) { + if (!ShowPeerIdBelowAbout.value()) { + return std::move(value); + } + using namespace Ui::Text; + if (!value.empty()) { + value.append("\n"); + } + value.append(Italic(u"id: "_q)); + const auto raw = peer->id.value & PeerId::kChatTypeMask; + const auto id = QString::number(raw); + value.append(Link(Italic(id), "internal:copy:" + id)); + return std::move(value); + }); +} + template auto AddActionButton( not_null parent, @@ -406,8 +434,8 @@ object_ptr DetailsFiller::setupInfo() { ? tr::lng_info_about_label() : tr::lng_info_bio_label(); addTranslateToMenu( - addInfoLine(std::move(label), AboutValue(user)).text, - AboutValue(user)); + addInfoLine(std::move(label), AboutWithIdValue(user)).text, + AboutWithIdValue(user)); const auto usernameLine = addInfoOneLine( UsernamesSubtext(_peer, tr::lng_info_username_label()), @@ -1028,6 +1056,8 @@ object_ptr ActionsFiller::fill() { } // namespace +const char kOptionShowPeerIdBelowAbout[] = "show-peer-id-below-about"; + object_ptr SetupDetails( not_null controller, not_null parent, diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.h b/Telegram/SourceFiles/info/profile/info_profile_actions.h index 3dfae7358..fcbc351f5 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.h +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.h @@ -23,6 +23,8 @@ class Controller; namespace Info::Profile { +extern const char kOptionShowPeerIdBelowAbout[]; + object_ptr SetupDetails( not_null controller, not_null parent, diff --git a/Telegram/SourceFiles/info/profile/info_profile_values.cpp b/Telegram/SourceFiles/info/profile/info_profile_values.cpp index 198e73975..878366d15 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_values.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_values.cpp @@ -7,7 +7,6 @@ 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" @@ -38,12 +37,6 @@ 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, @@ -94,8 +87,6 @@ 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, @@ -218,16 +209,6 @@ 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 67c9238fb..b3a110fe4 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_values.h +++ b/Telegram/SourceFiles/info/profile/info_profile_values.h @@ -35,8 +35,6 @@ 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 6104cabb1..c6a9b5cde 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.cpp +++ b/Telegram/SourceFiles/settings/settings_experimental.cpp @@ -19,7 +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 "info/profile/info_profile_actions.h" #include "lang/lang_keys.h" #include "mainwindow.h" #include "media/player/media_player_instance.h"