mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Set name / phone texts on-demand.
This commit is contained in:
parent
ceb7d5f238
commit
8bc807dc40
98 changed files with 426 additions and 260 deletions
Telegram/SourceFiles
api
apiwrap.cppboxes
add_contact_box.cppchoose_filter_box.cppdelete_messages_box.cpp
filters
mute_settings_box.cpppeer_list_box.cpppeers
add_bot_to_chat_box.cppadd_participants_box.cppedit_linked_chat_box.cppedit_participant_box.cppedit_participants_box.cppedit_peer_info_box.cppedit_peer_invite_link.cppedit_peer_requests_box.cppprepare_short_info_box.cpp
premium_limits_box.cppshare_box.cppurl_auth_box.cppcalls
calls_call.cppcalls_emoji_fingerprint.cppcalls_instance.cppcalls_panel.cppcalls_top_bar.cppcalls_userpic.cpp
group
chat_helpers
core
data
data_channel.cppdata_chat.cppdata_folder.cppdata_folder.hdata_peer.cppdata_peer.hdata_sponsored_messages.cppdata_user.cppdata_user.h
dialogs
history
admin_log
history.cpphistory.hhistory_inner_widget.cpphistory_inner_widget.hhistory_item.hhistory_item_components.cpphistory_item_components.hhistory_item_text.cpphistory_message.cpphistory_message.hhistory_service.cpphistory_widget.cppview
info/profile
inline_bots
media
overview
passport
payments
profile
settings
storage
window
|
@ -280,7 +280,7 @@ void ConfirmInviteBox::prepare() {
|
|||
auto name = new Ui::FlatLabel(this, st::confirmInviteUserName);
|
||||
name->resizeToWidth(st::confirmInviteUserPhotoSize + padding);
|
||||
name->setText(participant.user->firstName.isEmpty()
|
||||
? participant.user->name
|
||||
? participant.user->name()
|
||||
: participant.user->firstName);
|
||||
name->moveToLeft(left + (padding / 2), st::confirmInviteUserNameTop);
|
||||
left += _userWidth;
|
||||
|
|
|
@ -103,7 +103,7 @@ void SendExistingMedia(
|
|||
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
||||
}
|
||||
const auto messagePostAuthor = peer->isBroadcast()
|
||||
? session->user()->name
|
||||
? session->user()->name()
|
||||
: QString();
|
||||
|
||||
auto caption = TextWithEntities{
|
||||
|
@ -290,7 +290,7 @@ bool SendDice(MessageToSend &message) {
|
|||
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
||||
}
|
||||
const auto messagePostAuthor = peer->isBroadcast()
|
||||
? session->user()->name
|
||||
? session->user()->name()
|
||||
: QString();
|
||||
const auto replyTo = message.action.replyTo;
|
||||
|
||||
|
@ -423,7 +423,7 @@ void SendConfirmedFile(
|
|||
? PeerId()
|
||||
: session->userPeerId();
|
||||
const auto messagePostAuthor = peer->isBroadcast()
|
||||
? session->user()->name
|
||||
? session->user()->name()
|
||||
: QString();
|
||||
|
||||
const auto media = MTPMessageMedia([&] {
|
||||
|
|
|
@ -426,12 +426,12 @@ void RegenerateParticipants(not_null<State*> state, int small, int large) {
|
|||
const auto id = peer->id.value;
|
||||
const auto was = ranges::find(old, id, &Ui::WhoReadParticipant::id);
|
||||
if (was != end(old)) {
|
||||
was->name = peer->name;
|
||||
was->name = peer->name();
|
||||
now.push_back(std::move(*was));
|
||||
continue;
|
||||
}
|
||||
now.push_back({
|
||||
.name = peer->name,
|
||||
.name = peer->name(),
|
||||
.reaction = userpic.reaction,
|
||||
.userpicLarge = GenerateUserpic(userpic, large),
|
||||
.userpicKey = userpic.uniqueKey,
|
||||
|
|
|
@ -3199,7 +3199,7 @@ void ApiWrap::forwardMessages(
|
|||
? PeerId(0)
|
||||
: self->id;
|
||||
const auto messagePostAuthor = peer->isBroadcast()
|
||||
? self->name
|
||||
? self->name()
|
||||
: QString();
|
||||
history->addNewLocalMessage(
|
||||
newId.msg,
|
||||
|
@ -3282,7 +3282,7 @@ void ApiWrap::sendSharedContact(
|
|||
? PeerId()
|
||||
: _session->userPeerId();
|
||||
const auto messagePostAuthor = peer->isBroadcast()
|
||||
? _session->user()->name
|
||||
? _session->user()->name()
|
||||
: QString();
|
||||
const auto viaBotId = UserId();
|
||||
const auto item = history->addNewLocalMessage(
|
||||
|
@ -3545,7 +3545,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
|||
sendFlags |= MTPmessages_SendMessage::Flag::f_send_as;
|
||||
}
|
||||
const auto messagePostAuthor = peer->isBroadcast()
|
||||
? _session->user()->name
|
||||
? _session->user()->name()
|
||||
: QString();
|
||||
if (action.options.scheduled) {
|
||||
flags |= MessageFlag::IsOrWasScheduled;
|
||||
|
@ -3693,7 +3693,7 @@ void ApiWrap::sendInlineResult(
|
|||
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_send_as;
|
||||
}
|
||||
const auto messagePostAuthor = peer->isBroadcast()
|
||||
? _session->user()->name
|
||||
? _session->user()->name()
|
||||
: QString();
|
||||
|
||||
_session->data().registerMessageRandomId(randomId, newId);
|
||||
|
|
|
@ -1091,7 +1091,7 @@ void SetupChannelBox::save() {
|
|||
MTP_string(_sentUsername)
|
||||
)).done([=] {
|
||||
_channel->setName(
|
||||
TextUtilities::SingleLine(_channel->name),
|
||||
TextUtilities::SingleLine(_channel->name()),
|
||||
_sentUsername);
|
||||
closeBox();
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
|
@ -1239,7 +1239,7 @@ void SetupChannelBox::updateFail(UsernameResult result) {
|
|||
if ((result == UsernameResult::Ok)
|
||||
|| (_sentUsername == _channel->username)) {
|
||||
_channel->setName(
|
||||
TextUtilities::SingleLine(_channel->name),
|
||||
TextUtilities::SingleLine(_channel->name()),
|
||||
TextUtilities::SingleLine(_sentUsername));
|
||||
closeBox();
|
||||
} else if (result == UsernameResult::Invalid) {
|
||||
|
|
|
@ -69,7 +69,7 @@ void ChangeFilterById(
|
|||
MTP_flags(MTPmessages_UpdateDialogFilter::Flag::f_filter),
|
||||
MTP_int(filter.id()),
|
||||
filter.tl()
|
||||
)).done([=, chat = history->peer->name, filterName = filter.title()] {
|
||||
)).done([=, chat = history->peer->name(), name = filter.title()]{
|
||||
// Since only the primary window has dialogs list,
|
||||
// We can safely show toast there.
|
||||
if (const auto controller = Core::App().primaryWindow()) {
|
||||
|
@ -80,7 +80,7 @@ void ChangeFilterById(
|
|||
lt_chat,
|
||||
Ui::Text::Bold(chat),
|
||||
lt_folder,
|
||||
Ui::Text::Bold(filterName),
|
||||
Ui::Text::Bold(name),
|
||||
Ui::Text::WithEntities);
|
||||
Ui::Toast::Show(
|
||||
Window::Show(controller).toastParent(),
|
||||
|
|
|
@ -120,20 +120,29 @@ void DeleteMessagesBox::prepare() {
|
|||
: peer->isSelf()
|
||||
? tr::lng_sure_delete_saved_messages(tr::now)
|
||||
: peer->isUser()
|
||||
? tr::lng_sure_delete_history(tr::now, lt_contact, peer->name)
|
||||
? tr::lng_sure_delete_history(
|
||||
tr::now,
|
||||
lt_contact,
|
||||
peer->name())
|
||||
: tr::lng_sure_delete_group_history(
|
||||
tr::now,
|
||||
lt_group,
|
||||
peer->name);
|
||||
peer->name());
|
||||
details = Ui::Text::RichLangValue(details.text);
|
||||
deleteStyle = &st::attentionBoxButton;
|
||||
} else {
|
||||
details.text = peer->isSelf()
|
||||
? tr::lng_sure_delete_saved_messages(tr::now)
|
||||
: peer->isUser()
|
||||
? tr::lng_sure_delete_history(tr::now, lt_contact, peer->name)
|
||||
? tr::lng_sure_delete_history(
|
||||
tr::now,
|
||||
lt_contact,
|
||||
peer->name())
|
||||
: peer->isChat()
|
||||
? tr::lng_sure_delete_and_exit(tr::now, lt_group, peer->name)
|
||||
? tr::lng_sure_delete_and_exit(
|
||||
tr::now,
|
||||
lt_group,
|
||||
peer->name())
|
||||
: peer->isMegagroup()
|
||||
? tr::lng_sure_leave_group(tr::now)
|
||||
: tr::lng_sure_leave_channel(tr::now);
|
||||
|
@ -189,7 +198,7 @@ void DeleteMessagesBox::prepare() {
|
|||
tr::lng_delete_all_from_user(
|
||||
tr::now,
|
||||
lt_user,
|
||||
Ui::Text::Bold(_moderateFrom->name),
|
||||
Ui::Text::Bold(_moderateFrom->name()),
|
||||
Ui::Text::WithEntities),
|
||||
false,
|
||||
st::defaultBoxCheckbox);
|
||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "ui/effects/panel_animation.h"
|
||||
|
@ -82,6 +83,7 @@ private:
|
|||
struct PeerButton {
|
||||
not_null<History*> history;
|
||||
std::shared_ptr<Data::CloudImageView> userpic;
|
||||
Ui::Text::String name;
|
||||
Button button;
|
||||
};
|
||||
|
||||
|
@ -208,7 +210,7 @@ int FilterChatsPreview::resizeGetHeight(int newWidth) {
|
|||
for (const auto &[flag, button] : _removeFlag) {
|
||||
moveNextButton(button.get());
|
||||
}
|
||||
for (const auto &[history, userpic, button] : _removePeer) {
|
||||
for (const auto &[history, userpic, name, button] : _removePeer) {
|
||||
moveNextButton(button.get());
|
||||
}
|
||||
return top;
|
||||
|
@ -240,7 +242,7 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) {
|
|||
FilterChatsTypeName(flag));
|
||||
top += st.height;
|
||||
}
|
||||
for (auto &[history, userpic, button] : _removePeer) {
|
||||
for (auto &[history, userpic, name, button] : _removePeer) {
|
||||
const auto savedMessages = history->peer->isSelf();
|
||||
const auto repliesMessages = history->peer->isRepliesChat();
|
||||
if (savedMessages || repliesMessages) {
|
||||
|
@ -276,7 +278,13 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) {
|
|||
width(),
|
||||
st.photoSize);
|
||||
p.setPen(st::contactsNameFg);
|
||||
history->peer->nameText().drawLeftElided(
|
||||
if (name.isEmpty()) {
|
||||
name.setText(
|
||||
st::msgNameStyle,
|
||||
history->peer->name(),
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
name.drawLeftElided(
|
||||
p,
|
||||
nameLeft,
|
||||
top + nameTop,
|
||||
|
|
|
@ -46,7 +46,7 @@ void MuteSettingsBox::prepare() {
|
|||
icon->moveToLeft(st::boxPadding.left(), y);
|
||||
|
||||
object_ptr<Ui::FlatLabel> title(this, st::muteChatTitle);
|
||||
title->setText(_peer->name);
|
||||
title->setText(_peer->name());
|
||||
title->moveToLeft(
|
||||
st::boxPadding.left() + st::muteChatTitleLeft,
|
||||
y + (icon->height() / 2) - (title->height() / 2));
|
||||
|
|
|
@ -613,7 +613,7 @@ void PeerListRow::elementsPaint(
|
|||
}
|
||||
|
||||
QString PeerListRow::generateName() {
|
||||
return peer()->name;
|
||||
return peer()->name();
|
||||
}
|
||||
|
||||
QString PeerListRow::generateShortName() {
|
||||
|
|
|
@ -207,9 +207,15 @@ void AddBotToGroupBoxController::shareBotGame(not_null<PeerData*> chat) {
|
|||
});
|
||||
auto confirmText = [chat] {
|
||||
if (chat->isUser()) {
|
||||
return tr::lng_bot_sure_share_game(tr::now, lt_user, chat->name);
|
||||
return tr::lng_bot_sure_share_game(
|
||||
tr::now,
|
||||
lt_user,
|
||||
chat->name());
|
||||
}
|
||||
return tr::lng_bot_sure_share_game_group(tr::now, lt_group, chat->name);
|
||||
return tr::lng_bot_sure_share_game_group(
|
||||
tr::now,
|
||||
lt_group,
|
||||
chat->name());
|
||||
}();
|
||||
_controller->show(
|
||||
Ui::MakeConfirmBox({
|
||||
|
@ -320,7 +326,7 @@ void AddBotToGroupBoxController::addBotToGroup(not_null<PeerData*> chat) {
|
|||
});
|
||||
controller->show(
|
||||
Ui::MakeConfirmBox({
|
||||
tr::lng_bot_sure_invite(tr::now, lt_group, chat->name),
|
||||
tr::lng_bot_sure_invite(tr::now, lt_group, chat->name()),
|
||||
std::move(callback),
|
||||
}),
|
||||
Ui::LayerOption::KeepOther);
|
||||
|
|
|
@ -262,16 +262,16 @@ void AddParticipantsBoxController::inviteSelectedUsers(
|
|||
? tr::lng_participant_invite_sure(
|
||||
tr::now,
|
||||
lt_user,
|
||||
{ users.front()->name },
|
||||
{ users.front()->name()},
|
||||
lt_group,
|
||||
{ _peer->name },
|
||||
{ _peer->name()},
|
||||
Ui::Text::RichLangValue)
|
||||
: tr::lng_participant_invite_sure_many(
|
||||
tr::now,
|
||||
lt_count,
|
||||
int(users.size()),
|
||||
lt_group,
|
||||
{ _peer->name },
|
||||
{ _peer->name() },
|
||||
Ui::Text::RichLangValue);
|
||||
Ui::ConfirmBox(box, {
|
||||
.text = std::move(text),
|
||||
|
@ -834,7 +834,7 @@ void AddSpecialBoxController::kickUser(
|
|||
: tr::lng_profile_sure_kick_channel)(
|
||||
tr::now,
|
||||
lt_user,
|
||||
participant->name);
|
||||
participant->name());
|
||||
_editBox = showBox(Ui::MakeConfirmBox({ text, kickUserSure }));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -134,9 +134,9 @@ void Controller::choose(not_null<ChannelData*> chat) {
|
|||
auto text = tr::lng_manage_discussion_group_sure(
|
||||
tr::now,
|
||||
lt_group,
|
||||
Ui::Text::Bold(chat->name),
|
||||
Ui::Text::Bold(chat->name()),
|
||||
lt_channel,
|
||||
Ui::Text::Bold(_channel->name),
|
||||
Ui::Text::Bold(_channel->name()),
|
||||
Ui::Text::WithEntities);
|
||||
if (!_channel->isPublic()) {
|
||||
text.append(
|
||||
|
@ -170,9 +170,9 @@ void Controller::choose(not_null<ChatData*> chat) {
|
|||
auto text = tr::lng_manage_discussion_group_sure(
|
||||
tr::now,
|
||||
lt_group,
|
||||
Ui::Text::Bold(chat->name),
|
||||
Ui::Text::Bold(chat->name()),
|
||||
lt_channel,
|
||||
Ui::Text::Bold(_channel->name),
|
||||
Ui::Text::Bold(_channel->name()),
|
||||
Ui::Text::WithEntities);
|
||||
if (!_channel->isPublic()) {
|
||||
text.append("\n\n" + tr::lng_manage_linked_channel_private(tr::now));
|
||||
|
@ -212,13 +212,13 @@ object_ptr<Ui::RpWidget> SetupAbout(
|
|||
return tr::lng_manage_linked_channel_about(
|
||||
tr::now,
|
||||
lt_channel,
|
||||
Ui::Text::Bold(chat->name),
|
||||
Ui::Text::Bold(chat->name()),
|
||||
Ui::Text::WithEntities);
|
||||
} else if (chat != nullptr) {
|
||||
return tr::lng_manage_discussion_group_about_chosen(
|
||||
tr::now,
|
||||
lt_group,
|
||||
Ui::Text::Bold(chat->name),
|
||||
Ui::Text::Bold(chat->name()),
|
||||
Ui::Text::WithEntities);
|
||||
}
|
||||
return tr::lng_manage_discussion_group_about(
|
||||
|
@ -257,7 +257,7 @@ object_ptr<Ui::RpWidget> SetupCreateGroup(
|
|||
Box<GroupInfoBox>(
|
||||
navigation,
|
||||
GroupInfoBox::Type::Megagroup,
|
||||
channel->name + " Chat",
|
||||
channel->name() + " Chat",
|
||||
guarded),
|
||||
Ui::LayerOption::KeepOther);
|
||||
});
|
||||
|
|
|
@ -99,7 +99,7 @@ EditParticipantBox::Inner::Inner(
|
|||
_userPhoto->setPointerCursor(false);
|
||||
_userName.setText(
|
||||
st::rightsNameStyle,
|
||||
_user->name,
|
||||
_user->name(),
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ void EditAdminBox::prepare() {
|
|||
phrase(
|
||||
tr::now,
|
||||
lt_group,
|
||||
Ui::Text::Bold(peer()->name),
|
||||
Ui::Text::Bold(peer()->name()),
|
||||
Ui::Text::WithEntities),
|
||||
crl::guard(this, [=] { finishAddAdmin(); })
|
||||
}), Ui::LayerOption::KeepOther);
|
||||
|
@ -542,7 +542,7 @@ void EditAdminBox::transferOwnership() {
|
|||
.text = tr::lng_rights_transfer_about(
|
||||
tr::now,
|
||||
lt_group,
|
||||
Ui::Text::Bold(peer()->name),
|
||||
Ui::Text::Bold(peer()->name()),
|
||||
lt_user,
|
||||
Ui::Text::Bold(user()->shortName()),
|
||||
Ui::Text::RichLangValue),
|
||||
|
|
|
@ -1298,7 +1298,7 @@ void ParticipantsBoxController::rebuildChatAdmins(
|
|||
list.emplace_back(creator);
|
||||
}
|
||||
ranges::sort(list, [](not_null<UserData*> a, not_null<UserData*> b) {
|
||||
return (a->name.compare(b->name, Qt::CaseInsensitive) < 0);
|
||||
return (a->name().compare(b->name(), Qt::CaseInsensitive) < 0);
|
||||
});
|
||||
|
||||
const auto same = [&] {
|
||||
|
@ -1723,7 +1723,7 @@ void ParticipantsBoxController::kickParticipant(not_null<PeerData*> participant)
|
|||
: tr::lng_profile_sure_kick_channel)(
|
||||
tr::now,
|
||||
lt_user,
|
||||
user ? user->firstName : participant->name);
|
||||
user ? user->firstName : participant->name());
|
||||
_editBox = showBox(
|
||||
Ui::MakeConfirmBox({
|
||||
.text = text,
|
||||
|
@ -1967,7 +1967,7 @@ void ParticipantsBoxController::refreshCustomStatus(
|
|||
row->setCustomStatus(tr::lng_channel_admin_status_promoted_by(
|
||||
tr::now,
|
||||
lt_user,
|
||||
by->name));
|
||||
by->name()));
|
||||
} else {
|
||||
if (_additional.isCreator(user)) {
|
||||
row->setCustomStatus(
|
||||
|
@ -1984,7 +1984,7 @@ void ParticipantsBoxController::refreshCustomStatus(
|
|||
: tr::lng_channel_banned_status_restricted_by)(
|
||||
tr::now,
|
||||
lt_user,
|
||||
by ? by->name : "Unknown"));
|
||||
by ? by->name() : "Unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -473,7 +473,7 @@ object_ptr<Ui::RpWidget> Controller::createTitleEdit() {
|
|||
(_isGroup
|
||||
? tr::lng_dlg_new_group_name
|
||||
: tr::lng_dlg_new_channel_name)(),
|
||||
_peer->name),
|
||||
_peer->name()),
|
||||
st::editPeerTitleMargins);
|
||||
result->entity()->setMaxLength(Ui::EditPeer::kMaxGroupChannelTitle);
|
||||
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
|
@ -769,15 +769,13 @@ void Controller::fillLinkedChatButton() {
|
|||
auto label = isGroup
|
||||
? _linkedChatUpdates.events(
|
||||
) | rpl::map([](ChannelData *chat) {
|
||||
return chat ? chat->name : QString();
|
||||
return chat ? chat->name() : QString();
|
||||
}) | rpl::type_erased()
|
||||
: rpl::combine(
|
||||
tr::lng_manage_discussion_group_add(),
|
||||
_linkedChatUpdates.events()
|
||||
) | rpl::map([=](const QString &add, ChannelData *chat) {
|
||||
return chat
|
||||
? chat->name
|
||||
: add;
|
||||
return chat ? chat->name() : add;
|
||||
}) | rpl::type_erased();
|
||||
AddButtonWithText(
|
||||
_controls.buttonsLayout,
|
||||
|
@ -1388,14 +1386,14 @@ void Controller::saveUsername() {
|
|||
MTP_string(*_savingData.username)
|
||||
)).done([=] {
|
||||
channel->setName(
|
||||
TextUtilities::SingleLine(channel->name),
|
||||
TextUtilities::SingleLine(channel->name()),
|
||||
*_savingData.username);
|
||||
continueSave();
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
const auto &type = error.type();
|
||||
if (type == qstr("USERNAME_NOT_MODIFIED")) {
|
||||
channel->setName(
|
||||
TextUtilities::SingleLine(channel->name),
|
||||
TextUtilities::SingleLine(channel->name()),
|
||||
TextUtilities::SingleLine(*_savingData.username));
|
||||
continueSave();
|
||||
return;
|
||||
|
@ -1450,7 +1448,7 @@ void Controller::saveLinkedChat() {
|
|||
}
|
||||
|
||||
void Controller::saveTitle() {
|
||||
if (!_savingData.title || *_savingData.title == _peer->name) {
|
||||
if (!_savingData.title || *_savingData.title == _peer->name()) {
|
||||
return continueSave();
|
||||
}
|
||||
|
||||
|
|
|
@ -809,7 +809,7 @@ void Controller::processRequest(
|
|||
: tr::lng_group_requests_was_added)(
|
||||
tr::now,
|
||||
lt_user,
|
||||
Ui::Text::Bold(user->name),
|
||||
Ui::Text::Bold(user->name()),
|
||||
Ui::Text::WithEntities)
|
||||
});
|
||||
}
|
||||
|
@ -1164,7 +1164,7 @@ object_ptr<Ui::BoxContent> ShareInviteLinkBox(
|
|||
auto text = TextWithEntities();
|
||||
if (result.size() > 1) {
|
||||
text.append(
|
||||
Ui::Text::Bold(error.second->name)
|
||||
Ui::Text::Bold(error.second->name())
|
||||
).append("\n\n");
|
||||
}
|
||||
text.append(error.first);
|
||||
|
|
|
@ -388,7 +388,7 @@ void RequestsBoxController::processRequest(
|
|||
: tr::lng_group_requests_was_added)(
|
||||
tr::now,
|
||||
lt_user,
|
||||
Ui::Text::Bold(user->name),
|
||||
Ui::Text::Bold(user->name()),
|
||||
Ui::Text::WithEntities)
|
||||
});
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ void ProcessFullPhoto(
|
|||
const auto user = peer->asUser();
|
||||
const auto username = peer->userName();
|
||||
return PeerShortInfoFields{
|
||||
.name = peer->name,
|
||||
.name = peer->name(),
|
||||
.phone = user ? Ui::FormatPhone(user->phone()) : QString(),
|
||||
.link = ((user || username.isEmpty())
|
||||
? QString()
|
||||
|
|
|
@ -356,7 +356,7 @@ void PublicsController::rowRightActionClicked(not_null<PeerListRow*> row) {
|
|||
lt_link,
|
||||
peer->session().createInternalLink(peer->userName()),
|
||||
lt_group,
|
||||
peer->name);
|
||||
peer->name());
|
||||
const auto confirmText = tr::lng_channels_too_much_public_revoke(
|
||||
tr::now);
|
||||
const auto closeBox = _closeBox;
|
||||
|
@ -929,7 +929,7 @@ void AccountsLimitBox(
|
|||
&& account->session().premiumPossible();
|
||||
}) | ranges::views::transform([&](not_null<Main::Account*> account) {
|
||||
const auto user = account->session().user();
|
||||
return Args::Entry{ user->name, PaintUserpicCallback(user, false) };
|
||||
return Args::Entry{ user->name(), PaintUserpicCallback(user, false)};
|
||||
}) | ranges::views::take(defaultLimit) | ranges::to_vector;
|
||||
|
||||
const auto premiumPossible = !promotePossible.empty();
|
||||
|
|
|
@ -726,7 +726,7 @@ void ShareBox::Inner::updateChatName(
|
|||
? tr::lng_saved_messages(tr::now)
|
||||
: peer->isRepliesChat()
|
||||
? tr::lng_replies_messages(tr::now)
|
||||
: peer->name;
|
||||
: peer->name();
|
||||
chat->name.setText(_st.item.nameStyle, text, Ui::NameTextOptions());
|
||||
}
|
||||
|
||||
|
@ -1306,7 +1306,7 @@ void FastShareMessage(
|
|||
auto text = TextWithEntities();
|
||||
if (result.size() > 1) {
|
||||
text.append(
|
||||
Ui::Text::Bold(error.second->name)
|
||||
Ui::Text::Bold(error.second->name())
|
||||
).append("\n\n");
|
||||
}
|
||||
text.append(error.first);
|
||||
|
@ -1386,7 +1386,7 @@ void FastShareMessage(
|
|||
tr::lng_restricted_send_voice_messages(
|
||||
tr::now,
|
||||
lt_user,
|
||||
peer->name));
|
||||
peer->name()));
|
||||
}
|
||||
}
|
||||
finish();
|
||||
|
|
|
@ -277,7 +277,7 @@ not_null<Ui::RpWidget*> UrlAuthBox::setupContent(
|
|||
lt_domain,
|
||||
Ui::Text::Bold(domain),
|
||||
lt_user,
|
||||
Ui::Text::Bold(session->user()->name),
|
||||
Ui::Text::Bold(session->user()->name()),
|
||||
Ui::Text::WithEntities));
|
||||
const auto allow = bot
|
||||
? addCheckbox(tr::lng_url_auth_allow_messages(
|
||||
|
|
|
@ -1277,11 +1277,13 @@ void Call::setFailedQueued(const QString &error) {
|
|||
|
||||
void Call::handleRequestError(const QString &error) {
|
||||
const auto inform = (error == u"USER_PRIVACY_RESTRICTED"_q)
|
||||
? tr::lng_call_error_not_available(tr::now, lt_user, _user->name)
|
||||
? tr::lng_call_error_not_available(tr::now, lt_user, _user->name())
|
||||
: (error == u"PARTICIPANT_VERSION_OUTDATED"_q)
|
||||
? tr::lng_call_error_outdated(tr::now, lt_user, _user->name)
|
||||
? tr::lng_call_error_outdated(tr::now, lt_user, _user->name())
|
||||
: (error == u"CALL_PROTOCOL_LAYER_INVALID"_q)
|
||||
? Lang::Hard::CallErrorIncompatible().replace("{user}", _user->name)
|
||||
? Lang::Hard::CallErrorIncompatible().replace(
|
||||
"{user}",
|
||||
_user->name())
|
||||
: QString();
|
||||
if (!inform.isEmpty()) {
|
||||
Ui::show(Ui::MakeInformBox(inform));
|
||||
|
@ -1291,7 +1293,9 @@ void Call::handleRequestError(const QString &error) {
|
|||
|
||||
void Call::handleControllerError(const QString &error) {
|
||||
const auto inform = (error == u"ERROR_INCOMPATIBLE"_q)
|
||||
? Lang::Hard::CallErrorIncompatible().replace("{user}", _user->name)
|
||||
? Lang::Hard::CallErrorIncompatible().replace(
|
||||
"{user}",
|
||||
_user->name())
|
||||
: (error == u"ERROR_AUDIO_IO"_q)
|
||||
? tr::lng_call_error_audio_io(tr::now)
|
||||
: QString();
|
||||
|
|
|
@ -188,7 +188,7 @@ object_ptr<Ui::RpWidget> CreateFingerprintAndSignalBars(
|
|||
tr::lng_call_fingerprint_tooltip(
|
||||
tr::now,
|
||||
lt_user,
|
||||
call->user()->name));
|
||||
call->user()->name()));
|
||||
raw->setMouseTracking(true);
|
||||
raw->events(
|
||||
) | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||
|
|
|
@ -193,8 +193,10 @@ void Instance::startOutgoingCall(not_null<UserData*> user, bool video) {
|
|||
if (user->callsStatus() == UserData::CallsStatus::Private) {
|
||||
// Request full user once more to refresh the setting in case it was changed.
|
||||
user->session().api().requestFullPeer(user);
|
||||
Ui::show(Ui::MakeInformBox(
|
||||
tr::lng_call_error_not_available(tr::now, lt_user, user->name)));
|
||||
Ui::show(Ui::MakeInformBox(tr::lng_call_error_not_available(
|
||||
tr::now,
|
||||
lt_user,
|
||||
user->name())));
|
||||
return;
|
||||
}
|
||||
requestPermissionsOrFail(crl::guard(this, [=] {
|
||||
|
|
|
@ -124,7 +124,7 @@ void Panel::replaceCall(not_null<Call*> call) {
|
|||
void Panel::initWindow() {
|
||||
window()->setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
window()->setAttribute(Qt::WA_NoSystemBackground);
|
||||
window()->setTitle(_user->name);
|
||||
window()->setTitle(_user->name());
|
||||
window()->setTitleStyle(st::callTitle);
|
||||
|
||||
window()->events(
|
||||
|
@ -473,7 +473,10 @@ void Panel::reinitWithCall(Call *call) {
|
|||
case ErrorType::NoCamera:
|
||||
return tr::lng_call_error_no_camera(tr::now);
|
||||
case ErrorType::NotVideoCall:
|
||||
return tr::lng_call_error_camera_outdated(tr::now, lt_user, _user->name);
|
||||
return tr::lng_call_error_camera_outdated(
|
||||
tr::now,
|
||||
lt_user,
|
||||
_user->name());
|
||||
case ErrorType::NotStartedCall:
|
||||
return tr::lng_call_error_camera_not_started(tr::now);
|
||||
//case ErrorType::NoMicrophone:
|
||||
|
@ -490,7 +493,7 @@ void Panel::reinitWithCall(Call *call) {
|
|||
});
|
||||
}, _callLifetime);
|
||||
|
||||
_name->setText(_user->name);
|
||||
_name->setText(_user->name());
|
||||
updateStatusText(_call->state());
|
||||
|
||||
_answerHangupRedial->raise();
|
||||
|
@ -552,7 +555,7 @@ void Panel::initLayout() {
|
|||
// _user may change for the same Panel.
|
||||
return (_call != nullptr) && (update.peer == _user);
|
||||
}) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||
_name->setText(_call->user()->name);
|
||||
_name->setText(_call->user()->name());
|
||||
updateControlsGeometry();
|
||||
}, widget()->lifetime());
|
||||
|
||||
|
|
|
@ -644,14 +644,14 @@ void TopBar::updateInfoLabels() {
|
|||
void TopBar::setInfoLabels() {
|
||||
if (const auto call = _call.get()) {
|
||||
const auto user = call->user();
|
||||
const auto fullName = user->name;
|
||||
const auto fullName = user->name();
|
||||
const auto shortName = user->firstName;
|
||||
_fullInfoLabel->setText(fullName);
|
||||
_shortInfoLabel->setText(shortName);
|
||||
} else if (const auto group = _groupCall.get()) {
|
||||
const auto peer = group->peer();
|
||||
const auto real = peer->groupCall();
|
||||
const auto name = peer->name;
|
||||
const auto name = peer->name();
|
||||
const auto text = _isGroupConnecting.current()
|
||||
? tr::lng_group_call_connecting(tr::now)
|
||||
: (real && real->id() == group->id() && !real->title().isEmpty())
|
||||
|
|
|
@ -197,7 +197,7 @@ void Userpic::createCache(Image *image) {
|
|||
Painter p(&filled);
|
||||
Ui::EmptyUserpic(
|
||||
Data::PeerUserpicColor(_peer->id),
|
||||
_peer->name
|
||||
_peer->name()
|
||||
).paint(p, 0, 0, size, size);
|
||||
}
|
||||
//_userPhoto = Images::PixmapFast(Images::Round(
|
||||
|
|
|
@ -288,7 +288,7 @@ void ChooseJoinAsBox(
|
|||
}
|
||||
const auto name = !existing->title().isEmpty()
|
||||
? existing->title()
|
||||
: peer->name;
|
||||
: peer->name();
|
||||
return (peer->isBroadcast()
|
||||
? tr::lng_group_call_join_confirm_channel
|
||||
: tr::lng_group_call_join_confirm)(
|
||||
|
|
|
@ -238,7 +238,7 @@ object_ptr<Ui::BoxContent> PrepareInviteBox(
|
|||
finish();
|
||||
return;
|
||||
}
|
||||
const auto name = peer->name;
|
||||
const auto name = peer->name();
|
||||
const auto text = (nonMembers.size() == 1)
|
||||
? tr::lng_group_call_add_to_group_one(
|
||||
tr::now,
|
||||
|
|
|
@ -527,7 +527,7 @@ void FillMenu(
|
|||
if (const auto real = resolveReal()) {
|
||||
showBox(Box(
|
||||
EditGroupCallTitleBox,
|
||||
peer->name,
|
||||
peer->name(),
|
||||
real->title(),
|
||||
livestream,
|
||||
done));
|
||||
|
|
|
@ -1430,7 +1430,7 @@ void Panel::kickParticipant(not_null<PeerData*> participantPeer) {
|
|||
: tr::lng_group_call_remove_channel)(
|
||||
tr::now,
|
||||
lt_channel,
|
||||
participantPeer->name)
|
||||
participantPeer->name())
|
||||
: (_peer->isBroadcast()
|
||||
? tr::lng_profile_sure_kick_channel
|
||||
: tr::lng_profile_sure_kick)(
|
||||
|
@ -1668,7 +1668,7 @@ void Panel::setupEmptyRtmp() {
|
|||
(_call->rtmpInfo().url.isEmpty()
|
||||
? tr::lng_group_call_no_stream(
|
||||
lt_group,
|
||||
rpl::single(_peer->name))
|
||||
rpl::single(_peer->name()))
|
||||
: tr::lng_group_call_no_stream_admin()),
|
||||
_controlsBackgroundColor.color());
|
||||
_emptyRtmp->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
|
|
|
@ -156,7 +156,7 @@ object_ptr<ShareBox> ShareInviteLinkBox(
|
|||
auto text = TextWithEntities();
|
||||
if (result.size() > 1) {
|
||||
text.append(
|
||||
Ui::Text::Bold(error.second->name)
|
||||
Ui::Text::Bold(error.second->name())
|
||||
).append("\n\n");
|
||||
}
|
||||
text.append(error.first);
|
||||
|
|
|
@ -54,7 +54,7 @@ void Toasts::setupJoinAsChanged() {
|
|||
: tr::lng_group_call_join_as_changed)(
|
||||
tr::now,
|
||||
lt_name,
|
||||
Ui::Text::Bold(_call->joinAs()->name),
|
||||
Ui::Text::Bold(_call->joinAs()->name()),
|
||||
Ui::Text::WithEntities));
|
||||
}, _lifetime);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ void Toasts::setupTitleChanged() {
|
|||
}) | rpl::map([=] {
|
||||
const auto peer = _call->peer();
|
||||
return peer->groupCall()->title().isEmpty()
|
||||
? peer->name
|
||||
? peer->name()
|
||||
: peer->groupCall()->title();
|
||||
}) | rpl::start_with_next([=](const QString &title) {
|
||||
_panel->showToast((_call->peer()->isBroadcast()
|
||||
|
@ -90,7 +90,7 @@ void Toasts::setupAllowedToSpeak() {
|
|||
const auto real = _call->lookupReal();
|
||||
const auto name = (real && !real->title().isEmpty())
|
||||
? real->title()
|
||||
: _call->peer()->name;
|
||||
: _call->peer()->name();
|
||||
Ui::ShowMultilineToast({
|
||||
.text = tr::lng_group_call_can_speak(
|
||||
tr::now,
|
||||
|
|
|
@ -1230,9 +1230,9 @@ void Viewport::RendererGL::validateDatas() {
|
|||
const auto index = (j - begin(_tileData));
|
||||
_tileDataIndices[i] = index;
|
||||
const auto peer = tiles[i]->row()->peer();
|
||||
if (peer != j->peer
|
||||
|| peer->nameVersion != j->nameVersion
|
||||
|| width != j->nameRect.width()) {
|
||||
if ((j->peer != peer)
|
||||
|| (j->nameVersion != peer->nameVersion())
|
||||
|| (j->nameRect.width() != width)) {
|
||||
const auto nameTop = pausedBottom + index * nameHeight;
|
||||
j->nameRect = QRect(0, nameTop, width, nameHeight);
|
||||
requests.push_back({ .index = i, .updating = true });
|
||||
|
@ -1279,7 +1279,7 @@ void Viewport::RendererGL::validateDatas() {
|
|||
});
|
||||
}
|
||||
const auto nameTop = pausedBottom + index * nameHeight;
|
||||
_tileData[index].nameVersion = peer->nameVersion;
|
||||
_tileData[index].nameVersion = peer->nameVersion();
|
||||
_tileData[index].nameRect = QRect(
|
||||
0,
|
||||
nameTop,
|
||||
|
|
|
@ -937,7 +937,10 @@ void FieldAutocomplete::Inner::paintEvent(QPaintEvent *e) {
|
|||
auto firstwidth = st::mentionFont->width(first);
|
||||
auto secondwidth = st::mentionFont->width(second);
|
||||
auto unamewidth = firstwidth + secondwidth;
|
||||
auto namewidth = user->nameText().maxWidth();
|
||||
if (row.name.isEmpty()) {
|
||||
row.name.setText(st::msgNameStyle, user->name(), Ui::NameTextOptions());
|
||||
}
|
||||
auto namewidth = row.name.maxWidth();
|
||||
if (mentionwidth < unamewidth + namewidth) {
|
||||
namewidth = (mentionwidth * namewidth) / (namewidth + unamewidth);
|
||||
unamewidth = mentionwidth - namewidth;
|
||||
|
@ -956,7 +959,7 @@ void FieldAutocomplete::Inner::paintEvent(QPaintEvent *e) {
|
|||
user->paintUserpicLeft(p, row.userpic, st::mentionPadding.left(), i * st::mentionHeight + st::mentionPadding.top(), width(), st::mentionPhotoSize);
|
||||
|
||||
p.setPen(selected ? st::mentionNameFgOver : st::mentionNameFg);
|
||||
user->nameText().drawElided(p, 2 * st::mentionPadding.left() + st::mentionPhotoSize, i * st::mentionHeight + st::mentionTop, namewidth);
|
||||
row.name.drawElided(p, 2 * st::mentionPadding.left() + st::mentionPhotoSize, i * st::mentionHeight + st::mentionTop, namewidth);
|
||||
|
||||
p.setFont(st::mentionFont);
|
||||
p.setPen(selected ? st::mentionFgOverActive : st::mentionFgActive);
|
||||
|
|
|
@ -135,6 +135,7 @@ private:
|
|||
|
||||
struct MentionRow {
|
||||
not_null<UserData*> user;
|
||||
Ui::Text::String name;
|
||||
std::shared_ptr<Data::CloudImageView> userpic;
|
||||
};
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ void BotGameUrlClickHandler::onClick(ClickContext context) const {
|
|||
.text = tr::lng_allow_bot_pass(
|
||||
tr::now,
|
||||
lt_bot_name,
|
||||
_bot->name),
|
||||
_bot->name()),
|
||||
.confirmed = callback,
|
||||
.confirmText = tr::lng_allow_bot(),
|
||||
}));
|
||||
|
@ -238,7 +238,7 @@ auto MentionNameClickHandler::getTextEntity() const -> TextEntity {
|
|||
|
||||
QString MentionNameClickHandler::tooltip() const {
|
||||
if (const auto user = _session->data().userLoaded(_userId)) {
|
||||
const auto name = user->name;
|
||||
const auto name = user->name();
|
||||
if (name != _text) {
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -97,14 +97,20 @@ void ChannelData::setPhoto(const MTPChatPhoto &photo) {
|
|||
});
|
||||
}
|
||||
|
||||
void ChannelData::setName(const QString &newName, const QString &newUsername) {
|
||||
updateNameDelayed(newName.isEmpty() ? name : newName, QString(), newUsername);
|
||||
void ChannelData::setName(
|
||||
const QString &newName,
|
||||
const QString &newUsername) {
|
||||
updateNameDelayed(newName.isEmpty() ? name() : newName, {}, newUsername);
|
||||
}
|
||||
|
||||
void ChannelData::setAccessHash(uint64 accessHash) {
|
||||
access = accessHash;
|
||||
input = MTP_inputPeerChannel(MTP_long(peerToChannel(id).bare), MTP_long(accessHash));
|
||||
inputChannel = MTP_inputChannel(MTP_long(peerToChannel(id).bare), MTP_long(accessHash));
|
||||
input = MTP_inputPeerChannel(
|
||||
MTP_long(peerToChannel(id).bare),
|
||||
MTP_long(accessHash));
|
||||
inputChannel = MTP_inputChannel(
|
||||
MTP_long(peerToChannel(id).bare),
|
||||
MTP_long(accessHash));
|
||||
}
|
||||
|
||||
void ChannelData::setInviteLink(const QString &newInviteLink) {
|
||||
|
@ -377,7 +383,7 @@ void ChannelData::markForbidden() {
|
|||
: MTPDchannelForbidden::Flag::f_broadcast),
|
||||
MTP_long(peerToChannel(id).bare),
|
||||
MTP_long(access),
|
||||
MTP_string(name),
|
||||
MTP_string(name()),
|
||||
MTPint()));
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ bool ChatData::anyoneCanAddMembers() const {
|
|||
}
|
||||
|
||||
void ChatData::setName(const QString &newName) {
|
||||
updateNameDelayed(newName.isEmpty() ? name : newName, QString(), QString());
|
||||
updateNameDelayed(newName.isEmpty() ? name() : newName, {}, {});
|
||||
}
|
||||
|
||||
void ChatData::applyEditAdmin(not_null<UserData*> user, bool isAdmin) {
|
||||
|
|
|
@ -135,6 +135,10 @@ void Folder::unregisterOne(not_null<History*> history) {
|
|||
reorderLastHistories();
|
||||
}
|
||||
|
||||
int Folder::chatListNameVersion() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Folder::oneListMessageChanged(HistoryItem *from, HistoryItem *to) {
|
||||
if (!applyChatListMessage(to) && _chatListMessage == from) {
|
||||
computeChatListMessage();
|
||||
|
|
|
@ -81,6 +81,8 @@ private:
|
|||
bool applyChatListMessage(HistoryItem *item);
|
||||
void computeChatListMessage();
|
||||
|
||||
int chatListNameVersion() const override;
|
||||
|
||||
void reorderLastHistories();
|
||||
void updateChatListEntryPostponed();
|
||||
|
||||
|
|
|
@ -142,7 +142,6 @@ void PeerClickHandler::onClick(ClickContext context) const {
|
|||
PeerData::PeerData(not_null<Data::Session*> owner, PeerId id)
|
||||
: id(id)
|
||||
, _owner(owner) {
|
||||
_nameText.setText(st::msgNameStyle, QString(), Ui::NameTextOptions());
|
||||
}
|
||||
|
||||
Data::Session &PeerData::owner() const {
|
||||
|
@ -161,7 +160,7 @@ void PeerData::updateNameDelayed(
|
|||
const QString &newName,
|
||||
const QString &newNameOrPhone,
|
||||
const QString &newUsername) {
|
||||
if (name == newName && nameVersion > 1) {
|
||||
if (_name == newName && _nameVersion > 1) {
|
||||
if (isUser()) {
|
||||
if (asUser()->nameOrPhone == newNameOrPhone
|
||||
&& asUser()->username == newUsername) {
|
||||
|
@ -175,13 +174,12 @@ void PeerData::updateNameDelayed(
|
|||
return;
|
||||
}
|
||||
}
|
||||
name = newName;
|
||||
_nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
|
||||
_name = newName;
|
||||
_userpicEmpty = nullptr;
|
||||
|
||||
auto flags = UpdateFlag::None | UpdateFlag::None;
|
||||
auto oldFirstLetters = base::flat_set<QChar>();
|
||||
const auto nameUpdated = (nameVersion++ > 1);
|
||||
const auto nameUpdated = (_nameVersion++ > 1);
|
||||
if (nameUpdated) {
|
||||
oldFirstLetters = nameFirstLetters();
|
||||
flags |= UpdateFlag::Name;
|
||||
|
@ -216,7 +214,7 @@ not_null<Ui::EmptyUserpic*> PeerData::ensureEmptyUserpic() const {
|
|||
if (!_userpicEmpty) {
|
||||
_userpicEmpty = std::make_unique<Ui::EmptyUserpic>(
|
||||
Data::PeerUserpicColor(id),
|
||||
name);
|
||||
name());
|
||||
}
|
||||
return _userpicEmpty.get();
|
||||
}
|
||||
|
@ -564,14 +562,14 @@ void PeerData::fillNames() {
|
|||
}
|
||||
};
|
||||
|
||||
appendToIndex(name);
|
||||
appendToIndex(name());
|
||||
const auto appendTranslit = !toIndexList.isEmpty()
|
||||
&& cRussianLetters().match(toIndexList.front()).hasMatch();
|
||||
if (appendTranslit) {
|
||||
appendToIndex(translitRusEng(toIndexList.front()));
|
||||
}
|
||||
if (const auto user = asUser()) {
|
||||
if (user->nameOrPhone != name) {
|
||||
if (user->nameOrPhone != name()) {
|
||||
appendToIndex(user->nameOrPhone);
|
||||
}
|
||||
appendToIndex(user->username);
|
||||
|
@ -732,29 +730,33 @@ not_null<const PeerData*> PeerData::migrateToOrMe() const {
|
|||
return this;
|
||||
}
|
||||
|
||||
const Ui::Text::String &PeerData::topBarNameText() const {
|
||||
const QString &PeerData::topBarNameText() const {
|
||||
if (const auto to = migrateTo()) {
|
||||
return to->topBarNameText();
|
||||
} else if (const auto user = asUser()) {
|
||||
if (!user->phoneText.isEmpty()) {
|
||||
return user->phoneText;
|
||||
if (!user->nameOrPhone.isEmpty()) {
|
||||
return user->nameOrPhone;
|
||||
}
|
||||
}
|
||||
return _nameText;
|
||||
return _name;
|
||||
}
|
||||
|
||||
const Ui::Text::String &PeerData::nameText() const {
|
||||
int PeerData::nameVersion() const {
|
||||
return _nameVersion;
|
||||
}
|
||||
|
||||
const QString &PeerData::name() const {
|
||||
if (const auto to = migrateTo()) {
|
||||
return to->nameText();
|
||||
return to->name();
|
||||
}
|
||||
return _nameText;
|
||||
return _name;
|
||||
}
|
||||
|
||||
const QString &PeerData::shortName() const {
|
||||
if (const auto user = asUser()) {
|
||||
return user->firstName.isEmpty() ? user->lastName : user->firstName;
|
||||
}
|
||||
return name;
|
||||
return _name;
|
||||
}
|
||||
|
||||
QString PeerData::userName() const {
|
||||
|
@ -1138,7 +1140,7 @@ std::optional<QString> RestrictionError(
|
|||
: tr::lng_restricted_send_video_messages)(
|
||||
tr::now,
|
||||
lt_user,
|
||||
user->name);
|
||||
user->name());
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
|
|
|
@ -241,9 +241,10 @@ public:
|
|||
return (_lastFullUpdate != 0);
|
||||
}
|
||||
|
||||
[[nodiscard]] const Ui::Text::String &nameText() const;
|
||||
[[nodiscard]] int nameVersion() const;
|
||||
[[nodiscard]] const QString &name() const;
|
||||
[[nodiscard]] const QString &shortName() const;
|
||||
[[nodiscard]] const Ui::Text::String &topBarNameText() const;
|
||||
[[nodiscard]] const QString &topBarNameText() const;
|
||||
[[nodiscard]] QString userName() const;
|
||||
|
||||
[[nodiscard]] const base::flat_set<QString> &nameWords() const {
|
||||
|
@ -409,11 +410,8 @@ public:
|
|||
[[nodiscard]] const QString &themeEmoji() const;
|
||||
|
||||
const PeerId id;
|
||||
QString name;
|
||||
MTPinputPeer input = MTP_inputPeerEmpty();
|
||||
|
||||
int nameVersion = 1;
|
||||
|
||||
protected:
|
||||
void updateNameDelayed(
|
||||
const QString &newName,
|
||||
|
@ -440,7 +438,6 @@ private:
|
|||
bool _userpicHasVideo = false;
|
||||
|
||||
mutable std::unique_ptr<Ui::EmptyUserpic> _userpicEmpty;
|
||||
Ui::Text::String _nameText;
|
||||
|
||||
Data::PeerNotifySettings _notify;
|
||||
|
||||
|
@ -450,6 +447,9 @@ private:
|
|||
|
||||
crl::time _lastFullUpdate = 0;
|
||||
|
||||
QString _name;
|
||||
int _nameVersion = 1;
|
||||
|
||||
TimeId _ttlPeriod = 0;
|
||||
|
||||
Settings _settings = PeerSettings(PeerSetting::Unknown);
|
||||
|
|
|
@ -155,7 +155,7 @@ void SponsoredMessages::append(
|
|||
const auto channel = peer->asChannel();
|
||||
return SponsoredFrom{
|
||||
.peer = peer,
|
||||
.title = peer->name,
|
||||
.title = peer->name(),
|
||||
.isBroadcast = (channel && channel->isBroadcast()),
|
||||
.isMegagroup = (channel && channel->isMegagroup()),
|
||||
.isChannel = (channel != nullptr),
|
||||
|
|
|
@ -165,13 +165,7 @@ void UserData::setBotInfo(const MTPBotInfo &info) {
|
|||
}
|
||||
|
||||
void UserData::setNameOrPhone(const QString &newNameOrPhone) {
|
||||
if (nameOrPhone != newNameOrPhone) {
|
||||
nameOrPhone = newNameOrPhone;
|
||||
phoneText.setText(
|
||||
st::msgNameStyle,
|
||||
nameOrPhone,
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
nameOrPhone = newNameOrPhone;
|
||||
}
|
||||
|
||||
void UserData::madeAction(TimeId when) {
|
||||
|
|
|
@ -123,7 +123,6 @@ public:
|
|||
QString username;
|
||||
[[nodiscard]] const QString &phone() const;
|
||||
QString nameOrPhone;
|
||||
Ui::Text::String phoneText;
|
||||
TimeId onlineTill = 0;
|
||||
|
||||
enum class ContactStatus : char {
|
||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mainwidget.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history.h"
|
||||
#include "styles/style_dialogs.h" // st::dialogsTextWidthMin
|
||||
|
@ -163,6 +164,18 @@ void Entry::notifyUnreadStateChange(const UnreadState &wasState) {
|
|||
}
|
||||
}
|
||||
|
||||
const Ui::Text::String &Entry::chatListNameText() const {
|
||||
const auto version = chatListNameVersion();
|
||||
if (_chatListNameVersion < version) {
|
||||
_chatListNameVersion = version;
|
||||
_chatListNameText.setText(
|
||||
st::msgNameStyle,
|
||||
chatListName(),
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
return _chatListNameText;
|
||||
}
|
||||
|
||||
void Entry::setChatListExistence(bool exists) {
|
||||
if (exists && _sortKeyInChatList) {
|
||||
owner().refreshChatListEntry(this);
|
||||
|
|
|
@ -187,6 +187,8 @@ public:
|
|||
return _timeId;
|
||||
}
|
||||
|
||||
[[nodiscard]] const Ui::Text::String &chatListNameText() const;
|
||||
|
||||
protected:
|
||||
void notifyUnreadStateChange(const UnreadState &wasState);
|
||||
auto unreadStateChangeNotifier(bool required) {
|
||||
|
@ -208,6 +210,8 @@ private:
|
|||
void pinnedIndexChanged(FilterId filterId, int was, int now);
|
||||
[[nodiscard]] uint64 computeSortPosition(FilterId filterId) const;
|
||||
|
||||
[[nodiscard]] virtual int chatListNameVersion() const = 0;
|
||||
|
||||
void setChatListExistence(bool exists);
|
||||
not_null<Row*> mainChatListLink(FilterId filterId) const;
|
||||
Row *maybeMainChatListLink(FilterId filterId) const;
|
||||
|
@ -217,6 +221,8 @@ private:
|
|||
uint64 _sortKeyInChatList = 0;
|
||||
uint64 _sortKeyByDate = 0;
|
||||
base::flat_map<FilterId, int> _pinnedIndex;
|
||||
mutable Ui::Text::String _chatListNameText;
|
||||
mutable int _chatListNameVersion = 0;
|
||||
TimeId _timeId = 0;
|
||||
bool _isTopPromoted = false;
|
||||
const bool _isFolder = false;
|
||||
|
|
|
@ -121,6 +121,7 @@ struct InnerWidget::PeerSearchResult {
|
|||
PeerSearchResult(not_null<PeerData*> peer) : peer(peer) {
|
||||
}
|
||||
not_null<PeerData*> peer;
|
||||
mutable Ui::Text::String name;
|
||||
BasicRow row;
|
||||
};
|
||||
|
||||
|
@ -781,6 +782,13 @@ void InnerWidget::paintPeerSearchResult(
|
|||
auto namewidth = fullWidth - nameleft - st::dialogsPadding.x();
|
||||
QRect rectForName(nameleft, st::dialogsPadding.y() + st::dialogsNameTop, namewidth, st::msgNameFont->height);
|
||||
|
||||
if (result->name.isEmpty()) {
|
||||
result->name.setText(
|
||||
st::msgNameStyle,
|
||||
peer->name(),
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
|
||||
// draw chat icon
|
||||
if (auto chatTypeIcon = Ui::ChatTypeIcon(peer, active, selected)) {
|
||||
chatTypeIcon->paint(p, rectForName.topLeft(), fullWidth);
|
||||
|
@ -806,7 +814,7 @@ void InnerWidget::paintPeerSearchResult(
|
|||
peer,
|
||||
p,
|
||||
rectForName,
|
||||
peer->nameText().maxWidth(),
|
||||
result->name.maxWidth(),
|
||||
fullWidth,
|
||||
badgeStyle);
|
||||
rectForName.setWidth(rectForName.width() - badgeWidth);
|
||||
|
@ -833,7 +841,7 @@ void InnerWidget::paintPeerSearchResult(
|
|||
}
|
||||
|
||||
p.setPen(active ? st::dialogsTextFgActive : st::dialogsNameFg);
|
||||
peer->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
result->name.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
}
|
||||
|
||||
void InnerWidget::paintSearchInChat(Painter &p) const {
|
||||
|
@ -2427,7 +2435,7 @@ void InnerWidget::refreshSearchInChatLabel() {
|
|||
} else if (peer->isRepliesChat()) {
|
||||
return tr::lng_replies_messages(tr::now);
|
||||
}
|
||||
return peer->name;
|
||||
return peer->name();
|
||||
}
|
||||
return QString();
|
||||
}();
|
||||
|
@ -2437,7 +2445,7 @@ void InnerWidget::refreshSearchInChatLabel() {
|
|||
dialog,
|
||||
Ui::DialogTextOptions());
|
||||
}
|
||||
const auto from = _searchFromPeer ? _searchFromPeer->name : QString();
|
||||
const auto from = _searchFromPeer ? _searchFromPeer->name() : QString();
|
||||
if (!from.isEmpty()) {
|
||||
const auto fromUserText = tr::lng_dlg_search_from(
|
||||
tr::now,
|
||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_folder.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwidget.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
|
@ -41,7 +42,7 @@ namespace {
|
|||
list.size() - (throwAwayLastName ? 1 : 0)
|
||||
);
|
||||
const auto wrapName = [](not_null<History*> history) {
|
||||
const auto name = history->peer->name;
|
||||
const auto name = history->peer->name();
|
||||
return TextWithEntities{
|
||||
.text = name,
|
||||
.entities = (history->unreadCount() > 0)
|
||||
|
@ -343,4 +344,15 @@ FakeRow::FakeRow(Key searchInChat, not_null<HistoryItem*> item)
|
|||
, _item(item) {
|
||||
}
|
||||
|
||||
const Ui::Text::String &FakeRow::name() const {
|
||||
if (_name.isEmpty()) {
|
||||
const auto from = _searchInChat
|
||||
? _item->displayFrom()
|
||||
: nullptr;
|
||||
const auto peer = from ? from : _item->history()->peer.get();
|
||||
_name.setText(st::msgNameStyle, peer->name(), Ui::NameTextOptions());
|
||||
}
|
||||
return _name;
|
||||
}
|
||||
|
||||
} // namespace Dialogs
|
||||
|
|
|
@ -158,6 +158,7 @@ public:
|
|||
[[nodiscard]] Ui::MessageView &itemView() const {
|
||||
return _itemView;
|
||||
}
|
||||
[[nodiscard]] const Ui::Text::String &name() const;
|
||||
|
||||
private:
|
||||
friend class Ui::RowPainter;
|
||||
|
@ -165,6 +166,7 @@ private:
|
|||
Key _searchInChat;
|
||||
not_null<HistoryItem*> _item;
|
||||
mutable Ui::MessageView _itemView;
|
||||
mutable Ui::Text::String _name;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -311,6 +311,7 @@ void paintRow(
|
|||
VideoUserpic *videoUserpic,
|
||||
FilterId filterId,
|
||||
PeerData *from,
|
||||
const Ui::Text::String &fromName,
|
||||
const HiddenSenderInfo *hiddenSenderInfo,
|
||||
HistoryItem *item,
|
||||
const Data::Draft *draft,
|
||||
|
@ -590,7 +591,7 @@ void paintRow(
|
|||
from,
|
||||
p,
|
||||
rectForName,
|
||||
from->nameText().maxWidth(),
|
||||
fromName.maxWidth(),
|
||||
fullWidth,
|
||||
badgeStyle);
|
||||
rectForName.setWidth(rectForName.width() - badgeWidth);
|
||||
|
@ -600,14 +601,14 @@ void paintRow(
|
|||
: selected
|
||||
? st::dialogsNameFgOver
|
||||
: st::dialogsNameFg);
|
||||
from->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
fromName.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
} else if (hiddenSenderInfo) {
|
||||
p.setPen(active
|
||||
? st::dialogsNameFgActive
|
||||
: selected
|
||||
? st::dialogsNameFgOver
|
||||
: st::dialogsNameFg);
|
||||
hiddenSenderInfo->nameText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
hiddenSenderInfo->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
} else {
|
||||
p.setPen(active
|
||||
? st::dialogsNameFgActive
|
||||
|
@ -958,6 +959,7 @@ void RowPainter::paint(
|
|||
videoUserpic,
|
||||
filterId,
|
||||
from,
|
||||
entry->chatListNameText(),
|
||||
nullptr,
|
||||
item,
|
||||
cloudDraft,
|
||||
|
@ -1092,6 +1094,7 @@ void RowPainter::paint(
|
|||
nullptr,
|
||||
FilterId(),
|
||||
from,
|
||||
row->name(),
|
||||
hiddenSenderInfo,
|
||||
item,
|
||||
cloudDraft,
|
||||
|
|
|
@ -18,10 +18,10 @@ class BasicRow;
|
|||
|
||||
namespace Dialogs::Ui {
|
||||
|
||||
class VideoUserpic;
|
||||
|
||||
using namespace ::Ui;
|
||||
|
||||
class VideoUserpic;
|
||||
|
||||
const style::icon *ChatTypeIcon(
|
||||
not_null<PeerData*> peer,
|
||||
bool active,
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/effects/ripple_animation.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/data_channel.h"
|
||||
|
@ -62,6 +63,7 @@ private:
|
|||
|
||||
const not_null<UserData*> _user;
|
||||
std::shared_ptr<Data::CloudImageView> _userpic;
|
||||
Ui::Text::String _name;
|
||||
QString _statusText;
|
||||
bool _statusOnline = false;
|
||||
|
||||
|
@ -113,11 +115,14 @@ void UserCheckbox::paintEvent(QPaintEvent *e) {
|
|||
auto userpicTop = 0;
|
||||
_user->paintUserpicLeft(p, _userpic, userpicLeft, userpicTop, width(), st::contactsPhotoSize);
|
||||
|
||||
if (_name.isEmpty()) {
|
||||
_name.setText(st::msgNameStyle, _user->name(), Ui::NameTextOptions());
|
||||
}
|
||||
auto nameLeft = userpicLeft + st::contactsPhotoSize + st::contactsPadding.left();
|
||||
auto nameTop = userpicTop + st::contactsNameTop;
|
||||
auto nameWidth = width() - nameLeft - st::contactsPadding.right();
|
||||
p.setPen(st::contactsNameFg);
|
||||
_user->nameText().drawLeftElided(p, nameLeft, nameTop, nameWidth, width());
|
||||
_name.drawLeftElided(p, nameLeft, nameTop, nameWidth, width());
|
||||
|
||||
auto statusLeft = nameLeft;
|
||||
auto statusTop = userpicTop + st::contactsStatusTop;
|
||||
|
|
|
@ -1429,7 +1429,7 @@ void InnerWidget::suggestRestrictParticipant(
|
|||
: tr::lng_profile_sure_kick)(
|
||||
tr::now,
|
||||
lt_user,
|
||||
participant->name);
|
||||
participant->name());
|
||||
auto weakBox = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
const auto sure = crl::guard(this, [=] {
|
||||
restrictParticipant(
|
||||
|
|
|
@ -456,7 +456,7 @@ auto GenerateParticipantString(
|
|||
PeerId participantId) {
|
||||
// User name in "User name (@username)" format with entities.
|
||||
const auto peer = session->data().peer(participantId);
|
||||
auto name = TextWithEntities { peer->name };
|
||||
auto name = TextWithEntities { peer->name()};
|
||||
if (const auto user = peer->asUser()) {
|
||||
auto entityData = QString::number(user->id.value)
|
||||
+ '.'
|
||||
|
@ -706,7 +706,7 @@ void GenerateItems(
|
|||
return callback(OwnedItem(delegate, item), sentDate);
|
||||
};
|
||||
|
||||
const auto fromName = from->name;
|
||||
const auto fromName = from->name();
|
||||
const auto fromLink = from->createOpenLink();
|
||||
const auto fromLinkText = Ui::Text::Link(fromName, QString());
|
||||
|
||||
|
@ -1120,7 +1120,7 @@ void GenerateItems(
|
|||
lt_from,
|
||||
fromLinkText,
|
||||
lt_chat,
|
||||
Ui::Text::Link(now->name, QString()),
|
||||
Ui::Text::Link(now->name(), QString()),
|
||||
Ui::Text::WithEntities);
|
||||
const auto chatLink = std::make_shared<LambdaClickHandler>([=] {
|
||||
Ui::showPeerHistory(now, ShowAtUnreadMsgId);
|
||||
|
@ -1237,7 +1237,7 @@ void GenerateItems(
|
|||
data.vparticipant());
|
||||
const auto participantPeerLink = participantPeer->createOpenLink();
|
||||
const auto participantPeerLinkText = Ui::Text::Link(
|
||||
participantPeer->name,
|
||||
participantPeer->name(),
|
||||
QString());
|
||||
const auto text = (broadcast
|
||||
? tr::lng_admin_log_muted_participant_channel
|
||||
|
@ -1256,7 +1256,7 @@ void GenerateItems(
|
|||
data.vparticipant());
|
||||
const auto participantPeerLink = participantPeer->createOpenLink();
|
||||
const auto participantPeerLinkText = Ui::Text::Link(
|
||||
participantPeer->name,
|
||||
participantPeer->name(),
|
||||
QString());
|
||||
const auto text = (broadcast
|
||||
? tr::lng_admin_log_unmuted_participant_channel
|
||||
|
@ -1360,7 +1360,7 @@ void GenerateItems(
|
|||
data.vparticipant());
|
||||
const auto participantPeerLink = participantPeer->createOpenLink();
|
||||
const auto participantPeerLinkText = Ui::Text::Link(
|
||||
participantPeer->name,
|
||||
participantPeer->name(),
|
||||
QString());
|
||||
const auto volume = data.vparticipant().match([&](
|
||||
const MTPDgroupCallParticipant &data) {
|
||||
|
@ -1433,7 +1433,7 @@ void GenerateItems(
|
|||
lt_link,
|
||||
linkText,
|
||||
lt_user,
|
||||
Ui::Text::Link(user->name, QString()),
|
||||
Ui::Text::Link(user->name(), QString()),
|
||||
Ui::Text::WithEntities),
|
||||
data.vinvite(),
|
||||
user->createOpenLink());
|
||||
|
|
|
@ -72,7 +72,7 @@ History::History(not_null<Data::Session*> owner, PeerId peerId)
|
|||
, cloudDraftTextCache(st::dialogsTextWidthMin)
|
||||
, _delegateMixin(HistoryInner::DelegateMixin())
|
||||
, _mute(owner->notifySettings().isMuted(peer))
|
||||
, _chatListNameSortKey(owner->nameSortKey(peer->name))
|
||||
, _chatListNameSortKey(owner->nameSortKey(peer->name()))
|
||||
, _sendActionPainter(this) {
|
||||
if (const auto user = peer->asUser()) {
|
||||
if (user->isBot()) {
|
||||
|
@ -1823,6 +1823,10 @@ void History::setFolderPointer(Data::Folder *folder) {
|
|||
session().changes().historyUpdated(this, UpdateFlag::Folder);
|
||||
}
|
||||
|
||||
int History::chatListNameVersion() const {
|
||||
return peer->nameVersion();
|
||||
}
|
||||
|
||||
void History::applyPinnedUpdate(const MTPDupdateDialogPinned &data) {
|
||||
const auto folderId = data.vfolder_id().value_or_empty();
|
||||
if (!folderKnown()) {
|
||||
|
@ -2034,7 +2038,7 @@ bool History::chatListMessageKnown() const {
|
|||
}
|
||||
|
||||
const QString &History::chatListName() const {
|
||||
return peer->name;
|
||||
return peer->name();
|
||||
}
|
||||
|
||||
const QString &History::chatListNameSortKey() const {
|
||||
|
@ -2042,7 +2046,7 @@ const QString &History::chatListNameSortKey() const {
|
|||
}
|
||||
|
||||
void History::refreshChatListNameSortKey() {
|
||||
_chatListNameSortKey = owner().nameSortKey(peer->name);
|
||||
_chatListNameSortKey = owner().nameSortKey(peer->name());
|
||||
}
|
||||
|
||||
const base::flat_set<QString> &History::chatListNameWords() const {
|
||||
|
|
|
@ -597,6 +597,8 @@ private:
|
|||
|
||||
void setFolderPointer(Data::Folder *folder);
|
||||
|
||||
int chatListNameVersion() const override;
|
||||
|
||||
const std::unique_ptr<HistoryMainElementDelegateMixin> _delegateMixin;
|
||||
|
||||
Flags _flags = 0;
|
||||
|
|
|
@ -2607,7 +2607,7 @@ TextForMimeData HistoryInner::getSelectedText() const {
|
|||
not_null<HistoryItem*> item,
|
||||
TextForMimeData &&unwrapped) {
|
||||
const auto i = texts.emplace(item->position(), Part{
|
||||
.name = item->author()->name,
|
||||
.name = item->author()->name(),
|
||||
.time = ItemDateTime(item).toString(timeFormat),
|
||||
.unwrapped = std::move(unwrapped),
|
||||
}).first;
|
||||
|
|
|
@ -53,6 +53,7 @@ class PathShiftGradient;
|
|||
} // namespace Ui
|
||||
|
||||
namespace Dialogs::Ui {
|
||||
using namespace ::Ui;
|
||||
class VideoUserpic;
|
||||
} // namespace Dialogs::Ui
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ enum class Context : char;
|
|||
class ElementDelegate;
|
||||
} // namespace HistoryView
|
||||
|
||||
struct HiddenSenderInfo;
|
||||
class HiddenSenderInfo;
|
||||
class History;
|
||||
|
||||
[[nodiscard]] MessageFlags FlagsFromMTP(
|
||||
|
|
|
@ -102,7 +102,6 @@ HiddenSenderInfo::HiddenSenderInfo(const QString &name, bool external)
|
|||
: name)) {
|
||||
Expects(!name.isEmpty());
|
||||
|
||||
nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
|
||||
const auto parts = name.trimmed().split(' ', Qt::SkipEmptyParts);
|
||||
firstName = parts[0];
|
||||
for (const auto &part : parts.mid(1)) {
|
||||
|
@ -113,6 +112,13 @@ HiddenSenderInfo::HiddenSenderInfo(const QString &name, bool external)
|
|||
}
|
||||
}
|
||||
|
||||
const Ui::Text::String &HiddenSenderInfo::nameText() const {
|
||||
if (_nameText.isEmpty()) {
|
||||
_nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
|
||||
}
|
||||
return _nameText;
|
||||
}
|
||||
|
||||
ClickHandlerPtr HiddenSenderInfo::ForwardClickHandler() {
|
||||
static const auto hidden = std::make_shared<LambdaClickHandler>([](
|
||||
ClickContext context) {
|
||||
|
@ -153,7 +159,9 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const {
|
|||
&& originalSender->isChannel()
|
||||
&& !originalSender->isMegagroup();
|
||||
const auto name = TextWithEntities{
|
||||
.text = originalSender ? originalSender->name : hiddenSenderInfo->name
|
||||
.text = (originalSender
|
||||
? originalSender->name()
|
||||
: hiddenSenderInfo->name)
|
||||
};
|
||||
if (!originalAuthor.isEmpty()) {
|
||||
phrase = tr::lng_forwarded_signed(
|
||||
|
@ -342,13 +350,13 @@ QString HistoryMessageReply::replyToFromName(
|
|||
if (const auto user = replyToVia ? peer->asUser() : nullptr) {
|
||||
return user->firstName;
|
||||
}
|
||||
return peer->name;
|
||||
return peer->name();
|
||||
}
|
||||
|
||||
bool HistoryMessageReply::isNameUpdated(
|
||||
not_null<HistoryMessage*> holder) const {
|
||||
if (const auto from = replyToFrom(holder)) {
|
||||
if (from->nameVersion > replyToVersion) {
|
||||
if (replyToVersion < from->nameVersion()) {
|
||||
updateName(holder);
|
||||
return true;
|
||||
}
|
||||
|
@ -361,9 +369,9 @@ void HistoryMessageReply::updateName(
|
|||
if (const auto name = replyToFromName(holder); !name.isEmpty()) {
|
||||
replyToName.setText(st::fwdTextStyle, name, Ui::NameTextOptions());
|
||||
if (const auto from = replyToFrom(holder)) {
|
||||
replyToVersion = from->nameVersion;
|
||||
replyToVersion = from->nameVersion();
|
||||
} else {
|
||||
replyToVersion = replyToMsg->author()->nameVersion;
|
||||
replyToVersion = replyToMsg->author()->nameVersion();
|
||||
}
|
||||
bool hasPreview = replyToMsg->media() ? replyToMsg->media()->hasReplyPreview() : false;
|
||||
int32 previewSkip = hasPreview ? (st::msgReplyBarSize.height() + st::msgReplyBarSkip - st::msgReplyBarSize.width() - st::msgReplyBarPos.x()) : 0;
|
||||
|
|
|
@ -70,19 +70,20 @@ struct HistoryMessageEdited : public RuntimeComponent<HistoryMessageEdited, Hist
|
|||
TimeId date = 0;
|
||||
};
|
||||
|
||||
struct HiddenSenderInfo {
|
||||
class HiddenSenderInfo {
|
||||
public:
|
||||
HiddenSenderInfo(const QString &name, bool external);
|
||||
|
||||
QString name;
|
||||
QString firstName;
|
||||
QString lastName;
|
||||
PeerId colorPeerId = 0;
|
||||
Ui::Text::String nameText;
|
||||
Ui::EmptyUserpic emptyUserpic;
|
||||
mutable Data::CloudImage customUserpic;
|
||||
|
||||
[[nodiscard]] static ClickHandlerPtr ForwardClickHandler();
|
||||
|
||||
[[nodiscard]] const Ui::Text::String &nameText() const;
|
||||
[[nodiscard]] bool paintCustomUserpic(
|
||||
Painter &p,
|
||||
int x,
|
||||
|
@ -96,6 +97,10 @@ struct HiddenSenderInfo {
|
|||
inline bool operator!=(const HiddenSenderInfo &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
private:
|
||||
mutable Ui::Text::String _nameText;
|
||||
|
||||
};
|
||||
|
||||
struct HistoryMessageForwarded : public RuntimeComponent<HistoryMessageForwarded, HistoryItem> {
|
||||
|
|
|
@ -19,7 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
TextForMimeData WrapAsReply(
|
||||
TextForMimeData &&text,
|
||||
not_null<HistoryItem*> to) {
|
||||
const auto name = to->author()->name;
|
||||
const auto name = to->author()->name();
|
||||
auto result = TextForMimeData();
|
||||
result.reserve(
|
||||
tr::lng_in_reply_to(tr::now).size()
|
||||
|
|
|
@ -1022,8 +1022,6 @@ void HistoryMessage::createComponents(CreateConfig &&config) {
|
|||
} else {
|
||||
_flags &= ~MessageFlag::HasReplyMarkup;
|
||||
}
|
||||
const auto from = displayFrom();
|
||||
_fromNameVersion = from ? from->nameVersion : 1;
|
||||
}
|
||||
|
||||
bool HistoryMessage::checkRepliesPts(
|
||||
|
@ -1914,7 +1912,7 @@ QString HistoryMessage::notificationHeader() const {
|
|||
if (out() && isFromScheduled() && !_history->peer->isSelf()) {
|
||||
return tr::lng_from_you(tr::now);
|
||||
} else if (!_history->peer->isUser() && !isPost()) {
|
||||
return from()->name;
|
||||
return from()->name();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
|
@ -275,8 +275,6 @@ private:
|
|||
[[nodiscard]] bool checkRepliesPts(
|
||||
const HistoryMessageRepliesData &data) const;
|
||||
|
||||
mutable int _fromNameVersion = 0;
|
||||
|
||||
friend class HistoryView::Element;
|
||||
friend class HistoryView::Message;
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
|||
lt_from,
|
||||
fromLinkText(), // Link 1.
|
||||
lt_user,
|
||||
Ui::Text::Link(u->name, 2), // Link 2.
|
||||
Ui::Text::Link(u->name(), 2), // Link 2.
|
||||
Ui::Text::WithEntities);
|
||||
}
|
||||
} else if (users.isEmpty()) {
|
||||
|
@ -146,7 +146,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
|||
auto user = history()->owner().user(users[i].v);
|
||||
result.links.push_back(user->createOpenLink());
|
||||
|
||||
auto linkText = Ui::Text::Link(user->name, 2 + i);
|
||||
auto linkText = Ui::Text::Link(user->name(), 2 + i);
|
||||
if (i == 0) {
|
||||
result.text = linkText;
|
||||
} else if (i + 1 == l) {
|
||||
|
@ -256,7 +256,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
|||
lt_from,
|
||||
fromLinkText(), // Link 1.
|
||||
lt_user,
|
||||
Ui::Text::Link(user->name, 2), // Link 2.
|
||||
Ui::Text::Link(user->name(), 2), // Link 2.
|
||||
Ui::Text::WithEntities);
|
||||
}
|
||||
return result;
|
||||
|
@ -367,7 +367,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
|||
result.text = tr::lng_action_secure_values_sent(
|
||||
tr::now,
|
||||
lt_user,
|
||||
Ui::Text::Link(history()->peer->name, QString()), // Link 1.
|
||||
Ui::Text::Link(history()->peer->name(), QString()), // Link 1.
|
||||
lt_documents,
|
||||
{ .text = documents.join(", ") },
|
||||
Ui::Text::WithEntities);
|
||||
|
@ -415,14 +415,14 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
|||
lt_distance,
|
||||
{ .text = distance },
|
||||
lt_user,
|
||||
Ui::Text::Link(toPeer->name, QString()), // Link 1.
|
||||
Ui::Text::Link(toPeer->name(), QString()), // Link 1.
|
||||
Ui::Text::WithEntities);
|
||||
} else if (toId == selfId) {
|
||||
result.links.push_back(fromPeer->createOpenLink());
|
||||
return tr::lng_action_proximity_reached_you(
|
||||
tr::now,
|
||||
lt_from,
|
||||
Ui::Text::Link(fromPeer->name, QString()), // Link 1.
|
||||
Ui::Text::Link(fromPeer->name(), QString()), // Link 1.
|
||||
lt_distance,
|
||||
{ .text = distance },
|
||||
Ui::Text::WithEntities);
|
||||
|
@ -432,11 +432,11 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
|||
return tr::lng_action_proximity_reached(
|
||||
tr::now,
|
||||
lt_from,
|
||||
Ui::Text::Link(fromPeer->name, 1), // Link 1.
|
||||
Ui::Text::Link(fromPeer->name(), 1), // Link 1.
|
||||
lt_distance,
|
||||
{ .text = distance },
|
||||
lt_user,
|
||||
Ui::Text::Link(toPeer->name, 2), // Link 2.
|
||||
Ui::Text::Link(toPeer->name(), 2), // Link 2.
|
||||
Ui::Text::WithEntities);
|
||||
}
|
||||
}();
|
||||
|
@ -629,7 +629,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
|||
: tr::lng_action_gift_received)(
|
||||
tr::now,
|
||||
lt_user,
|
||||
Ui::Text::Link(peer->name, 1), // Link 1.
|
||||
Ui::Text::Link(peer->name(), 1), // Link 1.
|
||||
lt_cost,
|
||||
{ Ui::FillAmountAndCurrency(amount, currency) },
|
||||
Ui::Text::WithEntities);
|
||||
|
@ -854,7 +854,7 @@ HistoryService::PreparedText HistoryService::prepareInvitedToCallText(
|
|||
lt_from,
|
||||
fromLinkText(), // Link 1.
|
||||
lt_user,
|
||||
Ui::Text::Link(user->name, ++linkIndex), // Link N.
|
||||
Ui::Text::Link(user->name(), ++linkIndex), // Link N.
|
||||
lt_chat,
|
||||
chatText,
|
||||
Ui::Text::WithEntities);
|
||||
|
@ -873,7 +873,7 @@ HistoryService::PreparedText HistoryService::prepareInvitedToCallText(
|
|||
auto user = owner->user(users[i].v);
|
||||
result.links.push_back(user->createOpenLink());
|
||||
|
||||
auto linkText = Ui::Text::Link(user->name, ++linkIndex);
|
||||
auto linkText = Ui::Text::Link(user->name(), ++linkIndex);
|
||||
if (i == 0) {
|
||||
result.text = linkText;
|
||||
} else if (i + 1 == l) {
|
||||
|
@ -1098,7 +1098,7 @@ HistoryService::PreparedText HistoryService::preparePaymentSentText() {
|
|||
lt_amount,
|
||||
{ .text = payment->amount },
|
||||
lt_user,
|
||||
{ .text = history()->peer->name },
|
||||
{ .text = history()->peer->name() },
|
||||
Ui::Text::WithEntities);
|
||||
}
|
||||
} else {
|
||||
|
@ -1109,7 +1109,7 @@ HistoryService::PreparedText HistoryService::preparePaymentSentText() {
|
|||
lt_amount,
|
||||
{ .text = payment->amount },
|
||||
lt_user,
|
||||
{ .text = history()->peer->name },
|
||||
{ .text = history()->peer->name() },
|
||||
lt_invoice,
|
||||
invoiceTitle,
|
||||
Ui::Text::WithEntities);
|
||||
|
@ -1256,7 +1256,7 @@ ItemPreview HistoryService::toPreview(ToPreviewOptions options) const {
|
|||
|
||||
TextWithEntities HistoryService::inReplyText() const {
|
||||
auto result = HistoryService::notificationText();
|
||||
const auto &name = author()->name;
|
||||
const auto &name = author()->name();
|
||||
TextUtilities::Trim(result);
|
||||
if (result.text.startsWith(name)) {
|
||||
result = Ui::Text::Mid(result, name.size());
|
||||
|
@ -1272,7 +1272,7 @@ std::unique_ptr<HistoryView::Element> HistoryService::createView(
|
|||
}
|
||||
|
||||
TextWithEntities HistoryService::fromLinkText() const {
|
||||
return Ui::Text::Link(_from->name, 1);
|
||||
return Ui::Text::Link(_from->name(), 1);
|
||||
}
|
||||
|
||||
ClickHandlerPtr HistoryService::fromLink() const {
|
||||
|
@ -1628,7 +1628,7 @@ HistoryService::PreparedText GenerateJoinedText(
|
|||
: tr::lng_action_add_you)(
|
||||
tr::now,
|
||||
lt_from,
|
||||
Ui::Text::Link(inviter->name, QString()),
|
||||
Ui::Text::Link(inviter->name(), QString()),
|
||||
Ui::Text::WithEntities);
|
||||
return result;
|
||||
} else if (history->peer->isMegagroup()) {
|
||||
|
@ -1643,7 +1643,7 @@ HistoryService::PreparedText GenerateJoinedText(
|
|||
result.text = tr::lng_action_user_joined(
|
||||
tr::now,
|
||||
lt_from,
|
||||
Ui::Text::Link(self->name, QString()),
|
||||
Ui::Text::Link(self->name(), QString()),
|
||||
Ui::Text::WithEntities);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1365,7 +1365,7 @@ void HistoryWidget::insertMention(UserData *user) {
|
|||
if (user->username.isEmpty()) {
|
||||
replacement = user->firstName;
|
||||
if (replacement.isEmpty()) {
|
||||
replacement = user->name;
|
||||
replacement = user->name();
|
||||
}
|
||||
entityTag = PrepareMentionTag(user);
|
||||
} else {
|
||||
|
@ -7522,9 +7522,9 @@ void HistoryWidget::updateForwardingTexts() {
|
|||
if (!insertedPeers.contains(from)) {
|
||||
insertedPeers.emplace(from);
|
||||
names.push_back(from->shortName());
|
||||
fullname = from->name;
|
||||
fullname = from->name();
|
||||
}
|
||||
version += from->nameVersion;
|
||||
version += from->nameVersion();
|
||||
} else if (const auto info = item->hiddenSenderInfo()) {
|
||||
if (!insertedNames.contains(info->name)) {
|
||||
insertedNames.emplace(info->name);
|
||||
|
@ -7588,7 +7588,7 @@ void HistoryWidget::checkForwardingInfo() {
|
|||
if (keepNames) {
|
||||
for (const auto item : _toForward.items) {
|
||||
if (const auto from = item->senderOriginal()) {
|
||||
version += from->nameVersion;
|
||||
version += from->nameVersion();
|
||||
} else if (const auto info = item->hiddenSenderInfo()) {
|
||||
++version;
|
||||
} else {
|
||||
|
@ -7617,9 +7617,11 @@ void HistoryWidget::updateReplyToName() {
|
|||
}();
|
||||
_replyToName.setText(
|
||||
st::msgNameStyle,
|
||||
from->name,
|
||||
from->name(),
|
||||
Ui::NameTextOptions());
|
||||
_replyToNameVersion = (_replyEditMsg ? _replyEditMsg : _kbReplyTo)->author()->nameVersion;
|
||||
_replyToNameVersion = (_replyEditMsg
|
||||
? _replyEditMsg
|
||||
: _kbReplyTo)->author()->nameVersion();
|
||||
}
|
||||
|
||||
void HistoryWidget::updateField() {
|
||||
|
@ -7639,7 +7641,10 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
|
|||
auto hasForward = readyToForward();
|
||||
auto drawMsgText = (_editMsgId || _replyToId) ? _replyEditMsg : _kbReplyTo;
|
||||
if (_editMsgId || _replyToId || (!hasForward && _kbReplyTo)) {
|
||||
if (!_editMsgId && drawMsgText && drawMsgText->author()->nameVersion > _replyToNameVersion) {
|
||||
if (!_editMsgId
|
||||
&& drawMsgText
|
||||
&& (_replyToNameVersion
|
||||
< drawMsgText->author()->nameVersion())) {
|
||||
updateReplyToName();
|
||||
}
|
||||
backy -= st::historyReplyHeight;
|
||||
|
|
|
@ -709,12 +709,12 @@ void FieldHeader::paintEditOrReplyToMessage(Painter &p) {
|
|||
const auto user = _shownMessage->displayFrom()
|
||||
? _shownMessage->displayFrom()
|
||||
: _shownMessage->author().get();
|
||||
if (user->nameVersion > _shownMessageNameVersion) {
|
||||
if (_shownMessageNameVersion < user->nameVersion()) {
|
||||
_shownMessageName.setText(
|
||||
st::msgNameStyle,
|
||||
user->name,
|
||||
user->name(),
|
||||
Ui::NameTextOptions());
|
||||
_shownMessageNameVersion = user->nameVersion;
|
||||
_shownMessageNameVersion = user->nameVersion();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1476,7 +1476,7 @@ void ComposeControls::initAutocomplete() {
|
|||
const auto insertMention = [=](not_null<UserData*> user) {
|
||||
if (user->username.isEmpty()) {
|
||||
_field->insertTag(
|
||||
user->firstName.isEmpty() ? user->name : user->firstName,
|
||||
user->firstName.isEmpty() ? user->name() : user->firstName,
|
||||
PrepareMentionTag(user));
|
||||
} else {
|
||||
_field->insertTag('@' + user->username);
|
||||
|
|
|
@ -467,7 +467,7 @@ void ContactStatus::setupShareHandler(not_null<UserData*> user) {
|
|||
Ui::Text::WithEntities(
|
||||
Ui::FormatPhone(user->session().user()->phone())),
|
||||
lt_user,
|
||||
Ui::Text::Bold(user->name),
|
||||
Ui::Text::Bold(user->name()),
|
||||
Ui::Text::WithEntities),
|
||||
.confirmed = share,
|
||||
.confirmText = tr::lng_box_ok(),
|
||||
|
|
|
@ -1964,11 +1964,11 @@ TextForMimeData ListWidget::getSelectedText() const {
|
|||
TextForMimeData &&unwrapped) {
|
||||
auto time = ItemDateTime(item).toString(timeFormat);
|
||||
auto part = TextForMimeData();
|
||||
auto size = item->author()->name.size()
|
||||
auto size = item->author()->name().size()
|
||||
+ time.size()
|
||||
+ unwrapped.expanded.size();
|
||||
part.reserve(size);
|
||||
part.append(item->author()->name).append(time);
|
||||
part.append(item->author()->name()).append(time);
|
||||
part.append(std::move(unwrapped));
|
||||
texts.emplace_back(std::move(item), std::move(part));
|
||||
fullSize += size;
|
||||
|
|
|
@ -539,9 +539,10 @@ QSize Message::performCountOptimalSize() {
|
|||
// They will be added in resizeGetHeight() anyway.
|
||||
if (displayFromName()) {
|
||||
const auto from = item->displayFrom();
|
||||
validateFromNameText(from);
|
||||
const auto &name = from
|
||||
? from->nameText()
|
||||
: item->hiddenSenderInfo()->nameText;
|
||||
? _fromName
|
||||
: item->hiddenSenderInfo()->nameText();
|
||||
auto namew = st::msgPadding.left()
|
||||
+ name.maxWidth()
|
||||
+ st::msgPadding.right();
|
||||
|
@ -746,7 +747,7 @@ void Message::draw(Painter &p, const PaintContext &context) const {
|
|||
if (bubble) {
|
||||
if (displayFromName()
|
||||
&& item->displayFrom()
|
||||
&& item->displayFrom()->nameVersion > item->_fromNameVersion) {
|
||||
&& (_fromNameVersion < item->displayFrom()->nameVersion())) {
|
||||
fromNameUpdated(g.width());
|
||||
}
|
||||
|
||||
|
@ -1095,14 +1096,15 @@ void Message::paintFromName(
|
|||
: item->isSponsored()
|
||||
? st->boxTextFgGood()
|
||||
: stm->msgServiceFg);
|
||||
return &from->nameText();
|
||||
validateFromNameText(from);
|
||||
return &_fromName;
|
||||
} else if (const auto info = item->hiddenSenderInfo()) {
|
||||
p.setPen(!service
|
||||
? FromNameFg(context, info->colorPeerId)
|
||||
: item->isSponsored()
|
||||
? st->boxTextFgGood()
|
||||
: stm->msgServiceFg);
|
||||
return &info->nameText;
|
||||
return &info->nameText();
|
||||
} else {
|
||||
Unexpected("Corrupt sender information in message.");
|
||||
}
|
||||
|
@ -1698,9 +1700,10 @@ bool Message::getStateFromName(
|
|||
const auto from = item->displayFrom();
|
||||
const auto nameText = [&]() -> const Ui::Text::String * {
|
||||
if (from) {
|
||||
return &from->nameText();
|
||||
validateFromNameText(from);
|
||||
return &_fromName;
|
||||
} else if (const auto info = item->hiddenSenderInfo()) {
|
||||
return &info->nameText;
|
||||
return &info->nameText();
|
||||
} else {
|
||||
Unexpected("Corrupt forwarded information in message.");
|
||||
}
|
||||
|
@ -2203,6 +2206,17 @@ void Message::refreshReactions() {
|
|||
}
|
||||
}
|
||||
|
||||
void Message::validateFromNameText(PeerData *from) const {
|
||||
const auto version = from ? from->nameVersion() : 0;
|
||||
if (_fromNameVersion < version) {
|
||||
_fromNameVersion = version;
|
||||
_fromName.setText(
|
||||
st::msgNameStyle,
|
||||
from->name(),
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
}
|
||||
|
||||
void Message::itemDataChanged() {
|
||||
const auto wasInfo = _bottomInfo.currentSize();
|
||||
const auto wasReactions = _reactions
|
||||
|
@ -2738,14 +2752,14 @@ void Message::fromNameUpdated(int width) const {
|
|||
width -= st::msgPadding.right() + replyWidth;
|
||||
}
|
||||
const auto from = item->displayFrom();
|
||||
item->_fromNameVersion = from ? from->nameVersion : 1;
|
||||
validateFromNameText(from);
|
||||
if (const auto via = item->Get<HistoryMessageVia>()) {
|
||||
if (!displayForwardedFrom()) {
|
||||
const auto nameText = [&]() -> const Ui::Text::String * {
|
||||
if (from) {
|
||||
return &from->nameText();
|
||||
} else if (const auto info = item->hiddenSenderInfo()) {
|
||||
return &info->nameText;
|
||||
return &_fromName;
|
||||
} else if (const auto info = item->hiddenSenderInfo()) {
|
||||
return &info->nameText();
|
||||
} else {
|
||||
Unexpected("Corrupted forwarded information in message.");
|
||||
}
|
||||
|
|
|
@ -243,6 +243,7 @@ private:
|
|||
|
||||
void refreshRightBadge();
|
||||
void refreshReactions();
|
||||
void validateFromNameText(PeerData *from) const;
|
||||
|
||||
mutable ClickHandlerPtr _rightActionLink;
|
||||
mutable ClickHandlerPtr _fastReplyLink;
|
||||
|
@ -250,7 +251,9 @@ private:
|
|||
std::unique_ptr<Reactions::InlineList> _reactions;
|
||||
mutable std::unique_ptr<CommentsButton> _comments;
|
||||
|
||||
mutable Ui::Text::String _fromName;
|
||||
Ui::Text::String _rightBadge;
|
||||
mutable int _fromNameVersion = 0;
|
||||
int _bubbleWidthLimit = 0;
|
||||
|
||||
BottomInfo _bottomInfo;
|
||||
|
|
|
@ -105,7 +105,9 @@ rpl::producer<Ui::MessageBarContent> RootViewContent(
|
|||
const auto sender = (item && item->discussionPostOriginalSender())
|
||||
? item->discussionPostOriginalSender()
|
||||
: history->peer.get();
|
||||
content.title = sender->name.isEmpty() ? "Message" : sender->name;
|
||||
content.title = sender->name().isEmpty()
|
||||
? "Message"
|
||||
: sender->name();
|
||||
return std::move(content);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ rpl::producer<Ui::RequestsBarContent> RequestsBarContentByPeer(
|
|||
if (count == 1 && !state->users.empty()) {
|
||||
const auto user = state->users.front();
|
||||
state->current.nameShort = user->shortName();
|
||||
state->current.nameFull = user->name;
|
||||
state->current.nameFull = user->name();
|
||||
} else {
|
||||
state->current.nameShort
|
||||
= state->current.nameFull
|
||||
|
|
|
@ -519,7 +519,13 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
|||
}
|
||||
} else if (const auto history = _activeChat.key.history()) {
|
||||
const auto peer = history->peer;
|
||||
const auto &text = peer->topBarNameText();
|
||||
if (_titleNameVersion < peer->nameVersion()) {
|
||||
_titleNameVersion = peer->nameVersion();
|
||||
_title.setText(
|
||||
st::msgNameStyle,
|
||||
peer->topBarNameText(),
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
const auto badgeStyle = Ui::PeerBadgeStyle{
|
||||
&st::dialogsVerifiedIcon,
|
||||
&st::dialogsPremiumIcon,
|
||||
|
@ -533,13 +539,13 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
|||
nametop,
|
||||
availableWidth,
|
||||
st::msgNameStyle.font->height),
|
||||
text.maxWidth(),
|
||||
_title.maxWidth(),
|
||||
width(),
|
||||
badgeStyle);
|
||||
const auto namewidth = availableWidth - badgeWidth;
|
||||
|
||||
p.setPen(st::dialogsNameFg);
|
||||
peer->topBarNameText().drawElided(
|
||||
_title.drawElided(
|
||||
p,
|
||||
nameleft,
|
||||
nametop,
|
||||
|
@ -692,6 +698,7 @@ void TopBarWidget::setActiveChat(
|
|||
update();
|
||||
|
||||
if (peerChanged) {
|
||||
_titleNameVersion = 0;
|
||||
_emojiInteractionSeen = nullptr;
|
||||
_activeChatLifetime.destroy();
|
||||
if (const auto history = _activeChat.key.history()) {
|
||||
|
|
|
@ -159,6 +159,9 @@ private:
|
|||
std::unique_ptr<EmojiInteractionSeenAnimation> _emojiInteractionSeen;
|
||||
rpl::lifetime _activeChatLifetime;
|
||||
|
||||
Ui::Text::String _title;
|
||||
int _titleNameVersion = 0;
|
||||
|
||||
int _selectedCount = 0;
|
||||
bool _canDelete = false;
|
||||
bool _canForward = false;
|
||||
|
|
|
@ -78,7 +78,7 @@ rpl::producer<TextWithEntities> NameValue(not_null<PeerData*> peer) {
|
|||
peer,
|
||||
UpdateFlag::Name
|
||||
) | rpl::map([=] {
|
||||
return peer->name;
|
||||
return peer->name();
|
||||
}) | Ui::Text::ToWithEntities();
|
||||
}
|
||||
|
||||
|
|
|
@ -744,7 +744,7 @@ void AttachWebView::confirmOpen(
|
|||
.text = tr::lng_allow_bot_webview(
|
||||
tr::now,
|
||||
lt_bot_name,
|
||||
Ui::Text::Bold(_bot->name),
|
||||
Ui::Text::Bold(_bot->name()),
|
||||
Ui::Text::RichLangValue),
|
||||
.confirmed = callback,
|
||||
.confirmText = tr::lng_box_ok(),
|
||||
|
@ -828,7 +828,7 @@ void AttachWebView::show(
|
|||
&AttachWebViewBot::user);
|
||||
const auto name = (attached != end(_attachBots))
|
||||
? attached->name
|
||||
: _bot->name;
|
||||
: _bot->name();
|
||||
const auto hasSettings = (attached != end(_attachBots))
|
||||
&& !attached->inactive
|
||||
&& attached->hasSettings;
|
||||
|
|
|
@ -1015,7 +1015,7 @@ void Widget::handleSongChange() {
|
|||
if (document->isVoiceMessage() || document->isVideoMessage()) {
|
||||
if (const auto item = document->owner().message(current.contextId())) {
|
||||
const auto name = (!item->out() || item->isPost())
|
||||
? item->fromOriginal()->name
|
||||
? item->fromOriginal()->name()
|
||||
: tr::lng_from_you(tr::now);
|
||||
const auto date = [item] {
|
||||
const auto parsed = ItemDateTime(item);
|
||||
|
|
|
@ -2233,12 +2233,14 @@ void OverlayWidget::refreshFromLabel() {
|
|||
_fromName = info->name;
|
||||
} else {
|
||||
Assert(_from != nullptr);
|
||||
const auto from = _from->migrateTo() ? _from->migrateTo() : _from;
|
||||
_fromName = from->name;
|
||||
const auto from = _from->migrateTo()
|
||||
? _from->migrateTo()
|
||||
: _from;
|
||||
_fromName = from->name();
|
||||
}
|
||||
} else {
|
||||
_from = _user;
|
||||
_fromName = _user ? _user->name : QString();
|
||||
_fromName = _user ? _user->name() : QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -663,8 +663,8 @@ void Voice::paint(Painter &p, const QRect &clip, TextSelection selection, const
|
|||
}
|
||||
}
|
||||
const auto showPause = updateStatusText();
|
||||
const auto nameVersion = parent()->fromOriginal()->nameVersion;
|
||||
if (nameVersion > _nameVersion) {
|
||||
const auto nameVersion = parent()->fromOriginal()->nameVersion();
|
||||
if (_nameVersion < nameVersion) {
|
||||
updateName();
|
||||
}
|
||||
const auto radial = isRadialAnimation();
|
||||
|
@ -879,18 +879,31 @@ const style::RoundCheckbox &Voice::checkboxStyle() const {
|
|||
}
|
||||
|
||||
void Voice::updateName() {
|
||||
auto version = 0;
|
||||
if (const auto forwarded = parent()->Get<HistoryMessageForwarded>()) {
|
||||
if (parent()->fromOriginal()->isChannel()) {
|
||||
_name.setText(st::semiboldTextStyle, tr::lng_forwarded_channel(tr::now, lt_channel, parent()->fromOriginal()->name), Ui::NameTextOptions());
|
||||
_name.setText(
|
||||
st::semiboldTextStyle,
|
||||
tr::lng_forwarded_channel(
|
||||
tr::now,
|
||||
lt_channel,
|
||||
parent()->fromOriginal()->name()),
|
||||
Ui::NameTextOptions());
|
||||
} else {
|
||||
_name.setText(st::semiboldTextStyle, tr::lng_forwarded(tr::now, lt_user, parent()->fromOriginal()->name), Ui::NameTextOptions());
|
||||
_name.setText(
|
||||
st::semiboldTextStyle,
|
||||
tr::lng_forwarded(
|
||||
tr::now,
|
||||
lt_user,
|
||||
parent()->fromOriginal()->name()),
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
} else {
|
||||
_name.setText(st::semiboldTextStyle, parent()->from()->name, Ui::NameTextOptions());
|
||||
_name.setText(
|
||||
st::semiboldTextStyle,
|
||||
parent()->from()->name(),
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
version = parent()->fromOriginal()->nameVersion;
|
||||
_nameVersion = version;
|
||||
_nameVersion = parent()->fromOriginal()->nameVersion();
|
||||
}
|
||||
|
||||
int Voice::duration() const {
|
||||
|
|
|
@ -85,7 +85,7 @@ not_null<Ui::RpWidget*> PanelForm::setupContent() {
|
|||
inner,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
inner,
|
||||
tr::lng_passport_request1(tr::now, lt_bot, bot->name),
|
||||
tr::lng_passport_request1(tr::now, lt_bot, bot->name()),
|
||||
st::passportPasswordLabelBold)),
|
||||
st::passportFormAbout1Padding)->entity();
|
||||
|
||||
|
@ -154,7 +154,7 @@ not_null<Ui::RpWidget*> PanelForm::setupContent() {
|
|||
lt_policy,
|
||||
tr::lng_passport_policy(
|
||||
lt_bot,
|
||||
rpl::single(bot->name)
|
||||
rpl::single(bot->name())
|
||||
) | Ui::Text::ToLink(policyUrl),
|
||||
lt_bot,
|
||||
rpl::single('@' + bot->username) | Ui::Text::ToWithEntities(),
|
||||
|
|
|
@ -38,7 +38,7 @@ PanelAskPassword::PanelAskPassword(
|
|||
tr::lng_passport_request1(
|
||||
tr::now,
|
||||
lt_bot,
|
||||
_controller->bot()->name),
|
||||
_controller->bot()->name()),
|
||||
st::passportPasswordLabelBold)
|
||||
, _about2(
|
||||
this,
|
||||
|
@ -179,7 +179,7 @@ void PanelNoPassword::setupContent() {
|
|||
tr::lng_passport_request1(
|
||||
tr::now,
|
||||
lt_bot,
|
||||
_controller->bot()->name),
|
||||
_controller->bot()->name()),
|
||||
st::passportPasswordLabelBold)),
|
||||
st::passportPasswordAbout1Padding)->entity();
|
||||
|
||||
|
|
|
@ -316,7 +316,7 @@ void CheckoutProcess::handleFormUpdate(const FormUpdate &update) {
|
|||
}, [&](const BotTrustRequired &data) {
|
||||
UnregisterPaymentStart(this);
|
||||
_submitState = SubmitState::Validated;
|
||||
_panel->showWarning(data.bot->name, data.provider->name);
|
||||
_panel->showWarning(data.bot->name(), data.provider->name());
|
||||
if (const auto box = _enterPasswordBox.data()) {
|
||||
box->closeBox();
|
||||
}
|
||||
|
|
|
@ -418,13 +418,13 @@ void Form::processDetails(const MTPDpayments_paymentForm &data) {
|
|||
}
|
||||
if (const auto botId = _details.botId) {
|
||||
if (const auto bot = _session->data().userLoaded(botId)) {
|
||||
_invoice.cover.seller = bot->name;
|
||||
_invoice.cover.seller = bot->name();
|
||||
_details.termsBotUsername = bot->username;
|
||||
}
|
||||
}
|
||||
if (const auto providerId = _details.providerId) {
|
||||
if (const auto bot = _session->data().userLoaded(providerId)) {
|
||||
_invoice.provider = bot->name;
|
||||
_invoice.provider = bot->name();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ void Form::processDetails(const MTPDpayments_paymentReceipt &data) {
|
|||
}
|
||||
if (_details.botId) {
|
||||
if (const auto bot = _session->data().userLoaded(_details.botId)) {
|
||||
_invoice.cover.seller = bot->name;
|
||||
_invoice.cover.seller = bot->name();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ void PeerListWidget::paintItem(Painter &p, int x, int y, Item *item, bool select
|
|||
if (item->name.isEmpty()) {
|
||||
item->name.setText(
|
||||
st::msgNameStyle,
|
||||
item->peer->name,
|
||||
item->peer->name(),
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
int nameLeft = x + _st.namePosition.x();
|
||||
|
|
|
@ -599,11 +599,11 @@ void SetupAccountsWrap(
|
|||
const auto user = session->user();
|
||||
|
||||
auto text = rpl::single(
|
||||
user->name
|
||||
user->name()
|
||||
) | rpl::then(session->changes().realtimeNameUpdates(
|
||||
user
|
||||
) | rpl::map([=] {
|
||||
return user->name;
|
||||
return user->name();
|
||||
}));
|
||||
auto result = object_ptr<Ui::SettingsButton>(
|
||||
parent,
|
||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "settings/settings_common.h"
|
||||
|
||||
namespace Dialogs::Ui {
|
||||
using namespace ::Ui;
|
||||
struct UnreadBadgeStyle;
|
||||
} // namespace Dialogs::Ui
|
||||
|
||||
|
|
|
@ -770,7 +770,7 @@ QPointer<Ui::RpWidget> Premium::createPinnedToTop(
|
|||
lt_count,
|
||||
rpl::single(float64(gift.months)),
|
||||
lt_user,
|
||||
rpl::single(Ui::Text::Bold(peer->name)),
|
||||
rpl::single(Ui::Text::Bold(peer->name())),
|
||||
Ui::Text::RichLangValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ struct ForwardedTooltip {
|
|||
const auto phrase = tr::lng_forwarded(
|
||||
tr::now,
|
||||
lt_user,
|
||||
view->history()->session().user()->name);
|
||||
view->history()->session().user()->name());
|
||||
const auto kReplacementPosition = QChar(0x0001);
|
||||
const auto possiblePosition = tr::lng_forwarded(
|
||||
tr::now,
|
||||
|
|
|
@ -128,7 +128,7 @@ uint32 peerSize(not_null<PeerData*> peer) {
|
|||
+ sizeof(qint32) // contact
|
||||
+ sizeof(qint32); // botInfoVersion
|
||||
} else if (const auto chat = peer->asChat()) {
|
||||
result += stringSize(chat->name)
|
||||
result += stringSize(chat->name())
|
||||
+ sizeof(qint32) // count
|
||||
+ sizeof(qint32) // date
|
||||
+ sizeof(qint32) // version
|
||||
|
@ -137,7 +137,7 @@ uint32 peerSize(not_null<PeerData*> peer) {
|
|||
+ sizeof(quint32) // flags
|
||||
+ stringSize(chat->inviteLink());
|
||||
} else if (const auto channel = peer->asChannel()) {
|
||||
result += stringSize(channel->name)
|
||||
result += stringSize(channel->name())
|
||||
+ sizeof(quint64) // access
|
||||
+ sizeof(qint32) // date
|
||||
+ sizeof(qint32) // version
|
||||
|
@ -175,7 +175,7 @@ void writePeer(QDataStream &stream, not_null<PeerData*> peer) {
|
|||
auto field1 = qint32(uint32(chat->creator.bare & 0xFFFFFFFFULL));
|
||||
auto field2 = qint32(uint32(chat->creator.bare >> 32) << 8);
|
||||
stream
|
||||
<< chat->name
|
||||
<< chat->name()
|
||||
<< qint32(chat->count)
|
||||
<< qint32(chat->date)
|
||||
<< qint32(chat->version())
|
||||
|
@ -185,7 +185,7 @@ void writePeer(QDataStream &stream, not_null<PeerData*> peer) {
|
|||
<< chat->inviteLink();
|
||||
} else if (const auto channel = peer->asChannel()) {
|
||||
stream
|
||||
<< channel->name
|
||||
<< channel->name()
|
||||
<< quint64(channel->access)
|
||||
<< qint32(channel->date)
|
||||
<< qint32(0) // legacy - version
|
||||
|
|
|
@ -874,7 +874,7 @@ QString Manager::addTargetAccountName(
|
|||
? (title
|
||||
+ accountNameSeparator()
|
||||
+ (session->user()->username.isEmpty()
|
||||
? session->user()->name
|
||||
? session->user()->name()
|
||||
: session->user()->username))
|
||||
: title;
|
||||
}
|
||||
|
@ -994,10 +994,10 @@ void NativeManager::doShowNotification(NotificationFields &&fields) {
|
|||
? AppName.utf16()
|
||||
: (scheduled && peer->isSelf())
|
||||
? tr::lng_notification_reminder(tr::now)
|
||||
: peer->name;
|
||||
: peer->name();
|
||||
const auto fullTitle = addTargetAccountName(title, &peer->session());
|
||||
const auto subtitle = reactionFrom
|
||||
? (reactionFrom != peer ? reactionFrom->name : QString())
|
||||
? (reactionFrom != peer ? reactionFrom->name() : QString())
|
||||
: options.hideNameAndPhoto
|
||||
? QString()
|
||||
: item->notificationHeader();
|
||||
|
|
|
@ -86,7 +86,7 @@ Manager::QueuedNotification::QueuedNotification(NotificationFields &&fields)
|
|||
, author(!fields.reactionFrom
|
||||
? fields.item->notificationHeader()
|
||||
: (fields.reactionFrom != peer)
|
||||
? fields.reactionFrom->name
|
||||
? fields.reactionFrom->name()
|
||||
: QString())
|
||||
, item((fields.forwardedCount < 2) ? fields.item.get() : nullptr)
|
||||
, forwardedCount(fields.forwardedCount)
|
||||
|
@ -922,7 +922,7 @@ void Notification::updateNotifyDisplay() {
|
|||
? qsl("Telegram Desktop")
|
||||
: reminder
|
||||
? tr::lng_notification_reminder(tr::now)
|
||||
: _history->peer->nameText().toString();
|
||||
: _history->peer->name();
|
||||
const auto fullTitle = manager()->addTargetAccountName(
|
||||
title,
|
||||
&_history->session());
|
||||
|
|
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/wrap/vertical_layout_reorder.h"
|
||||
#include "ui/text/format_values.h" // Ui::FormatPhone
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/special_buttons.h"
|
||||
#include "ui/empty_userpic.h"
|
||||
#include "dialogs/ui/dialogs_layout.h"
|
||||
|
@ -765,7 +766,14 @@ void MainMenu::paintEvent(QPaintEvent *e) {
|
|||
|
||||
p.setFont(st::semiboldFont);
|
||||
p.setPen(st::windowBoldFg);
|
||||
_controller->session().user()->nameText().drawLeftElided(
|
||||
const auto user = _controller->session().user();
|
||||
if (_nameVersion < user->nameVersion()) {
|
||||
_name.setText(
|
||||
st::msgNameStyle,
|
||||
user->name(),
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
_name.drawLeftElided(
|
||||
p,
|
||||
st::mainMenuCoverNameLeft,
|
||||
st::mainMenuCoverNameTop,
|
||||
|
|
|
@ -66,6 +66,8 @@ private:
|
|||
|
||||
const not_null<SessionController*> _controller;
|
||||
object_ptr<Ui::UserpicButton> _userpicButton;
|
||||
Ui::Text::String _name;
|
||||
int _nameVersion = 0;
|
||||
object_ptr<ToggleAccountsButton> _toggleAccounts;
|
||||
object_ptr<ResetScaleButton> _resetScaleButton = { nullptr };
|
||||
object_ptr<Ui::ScrollArea> _scroll;
|
||||
|
|
|
@ -950,7 +950,7 @@ void PeerMenuDeleteContact(
|
|||
const auto text = tr::lng_sure_delete_contact(
|
||||
tr::now,
|
||||
lt_contact,
|
||||
user->name);
|
||||
user->name());
|
||||
const auto deleteSure = [=](Fn<void()> &&close) {
|
||||
close();
|
||||
user->session().api().request(MTPcontacts_DeleteContacts(
|
||||
|
@ -992,8 +992,8 @@ void PeerMenuShareContactBox(
|
|||
return;
|
||||
}
|
||||
auto recipient = peer->isUser()
|
||||
? peer->name
|
||||
: '\xAB' + peer->name + '\xBB';
|
||||
? peer->name()
|
||||
: '\xAB' + peer->name() + '\xBB';
|
||||
navigation->parentController()->show(
|
||||
Ui::MakeConfirmBox({
|
||||
.text = tr::lng_forward_share_contact(
|
||||
|
@ -1084,7 +1084,7 @@ void PeerMenuBlockUserBox(
|
|||
: v::get<bool>(suggestReport);
|
||||
|
||||
const auto user = peer->asUser();
|
||||
const auto name = user ? user->shortName() : peer->name;
|
||||
const auto name = user ? user->shortName() : peer->name();
|
||||
if (user) {
|
||||
box->addRow(object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
|
@ -1130,7 +1130,7 @@ void PeerMenuBlockUserBox(
|
|||
tr::lng_delete_all_from_user(
|
||||
tr::now,
|
||||
lt_user,
|
||||
Ui::Text::Bold(peer->name),
|
||||
Ui::Text::Bold(peer->name()),
|
||||
Ui::Text::WithEntities),
|
||||
true,
|
||||
st::defaultBoxCheckbox))
|
||||
|
|
Loading…
Add table
Reference in a new issue