Add id-s only when displayed in profile.
This commit is contained in:
parent
745ad45d47
commit
f306b11676
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "info/profile/info_profile_actions.h"
|
#include "info/profile/info_profile_actions.h"
|
||||||
|
|
||||||
|
#include "base/options.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
|
@ -71,6 +72,12 @@ namespace Info {
|
||||||
namespace Profile {
|
namespace Profile {
|
||||||
namespace {
|
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<TextWithEntities> UsernamesSubtext(
|
[[nodiscard]] rpl::producer<TextWithEntities> UsernamesSubtext(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
rpl::producer<QString> fallback) {
|
rpl::producer<QString> fallback) {
|
||||||
|
@ -131,6 +138,27 @@ namespace {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<TextWithEntities> AboutWithIdValue(
|
||||||
|
not_null<PeerData*> 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 <typename Text, typename ToggleOn, typename Callback>
|
template <typename Text, typename ToggleOn, typename Callback>
|
||||||
auto AddActionButton(
|
auto AddActionButton(
|
||||||
not_null<Ui::VerticalLayout*> parent,
|
not_null<Ui::VerticalLayout*> parent,
|
||||||
|
@ -406,8 +434,8 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
? tr::lng_info_about_label()
|
? tr::lng_info_about_label()
|
||||||
: tr::lng_info_bio_label();
|
: tr::lng_info_bio_label();
|
||||||
addTranslateToMenu(
|
addTranslateToMenu(
|
||||||
addInfoLine(std::move(label), AboutValue(user)).text,
|
addInfoLine(std::move(label), AboutWithIdValue(user)).text,
|
||||||
AboutValue(user));
|
AboutWithIdValue(user));
|
||||||
|
|
||||||
const auto usernameLine = addInfoOneLine(
|
const auto usernameLine = addInfoOneLine(
|
||||||
UsernamesSubtext(_peer, tr::lng_info_username_label()),
|
UsernamesSubtext(_peer, tr::lng_info_username_label()),
|
||||||
|
@ -1028,6 +1056,8 @@ object_ptr<Ui::RpWidget> ActionsFiller::fill() {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
const char kOptionShowPeerIdBelowAbout[] = "show-peer-id-below-about";
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> SetupDetails(
|
object_ptr<Ui::RpWidget> SetupDetails(
|
||||||
not_null<Controller*> controller,
|
not_null<Controller*> controller,
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
|
|
@ -23,6 +23,8 @@ class Controller;
|
||||||
|
|
||||||
namespace Info::Profile {
|
namespace Info::Profile {
|
||||||
|
|
||||||
|
extern const char kOptionShowPeerIdBelowAbout[];
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> SetupDetails(
|
object_ptr<Ui::RpWidget> SetupDetails(
|
||||||
not_null<Controller*> controller,
|
not_null<Controller*> controller,
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "info/profile/info_profile_values.h"
|
#include "info/profile/info_profile_values.h"
|
||||||
|
|
||||||
#include "base/options.h"
|
|
||||||
#include "info/profile/info_profile_badge.h"
|
#include "info/profile/info_profile_badge.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
|
@ -38,12 +37,6 @@ namespace {
|
||||||
|
|
||||||
using UpdateFlag = Data::PeerUpdate::Flag;
|
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) {
|
auto PlainAboutValue(not_null<PeerData*> peer) {
|
||||||
return peer->session().changes().peerFlagsValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
peer,
|
peer,
|
||||||
|
@ -94,8 +87,6 @@ void StripExternalLinks(TextWithEntities &text) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
const char kOptionShowPeerIdBelowAbout[] = "show-peer-id-below-about";
|
|
||||||
|
|
||||||
rpl::producer<QString> NameValue(not_null<PeerData*> peer) {
|
rpl::producer<QString> NameValue(not_null<PeerData*> peer) {
|
||||||
return peer->session().changes().peerFlagsValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
peer,
|
peer,
|
||||||
|
@ -218,16 +209,6 @@ TextWithEntities AboutWithEntities(
|
||||||
if (stripExternal) {
|
if (stripExternal) {
|
||||||
StripExternalLinks(result);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,6 @@ enum class SharedMediaType : signed char;
|
||||||
|
|
||||||
namespace Info::Profile {
|
namespace Info::Profile {
|
||||||
|
|
||||||
extern const char kOptionShowPeerIdBelowAbout[];
|
|
||||||
|
|
||||||
inline auto ToSingleLine() {
|
inline auto ToSingleLine() {
|
||||||
return rpl::map([](const QString &text) {
|
return rpl::map([](const QString &text) {
|
||||||
return TextUtilities::SingleLine(text);
|
return TextUtilities::SingleLine(text);
|
||||||
|
|
|
@ -19,7 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/launcher.h"
|
#include "core/launcher.h"
|
||||||
#include "chat_helpers/tabbed_panel.h"
|
#include "chat_helpers/tabbed_panel.h"
|
||||||
#include "dialogs/dialogs_widget.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 "lang/lang_keys.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "media/player/media_player_instance.h"
|
#include "media/player/media_player_instance.h"
|
||||||
|
|
Loading…
Reference in New Issue