Add "show-peer-id-below-about" option.

This commit is contained in:
John Preston 2023-10-29 10:12:48 +04:00
parent 597816db09
commit 625ae87eea
4 changed files with 38 additions and 0 deletions

View File

@ -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<Window::SessionController*> controller,
not_null<const Data::CloudTheme*> theme) {
@ -985,6 +996,10 @@ const std::vector<LocalUrlHandler> &InternalUrlHandlers() {
u"^url:(.+)$"_q,
OpenExternalLink
},
{
u"^copy:(.+)$"_q,
CopyPeerId
}
};
return Result;
}

View File

@ -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<PeerData*> 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<QString> NameValue(not_null<PeerData*> 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;
}

View File

@ -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);

View File

@ -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);