mirror of https://github.com/procxx/kepka.git
Show phone number only in the chat top bar.
This commit is contained in:
parent
aca3ec0ab8
commit
e9677779b8
|
@ -593,10 +593,13 @@ void FieldAutocompleteInner::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
}
|
||||
if (!_mrows->isEmpty()) {
|
||||
UserData *user = _mrows->at(i);
|
||||
QString first = (!filterIsEmpty && user->username.startsWith(filter, Qt::CaseInsensitive)) ? ('@' + user->username.mid(0, filterSize)) : QString();
|
||||
QString second = first.isEmpty() ? (user->username.isEmpty() ? QString() : ('@' + user->username)) : user->username.mid(filterSize);
|
||||
int32 firstwidth = st::mentionFont->width(first), secondwidth = st::mentionFont->width(second), unamewidth = firstwidth + secondwidth, namewidth = user->nameText.maxWidth();
|
||||
const auto user = _mrows->at(i);
|
||||
auto first = (!filterIsEmpty && user->username.startsWith(filter, Qt::CaseInsensitive)) ? ('@' + user->username.mid(0, filterSize)) : QString();
|
||||
auto second = first.isEmpty() ? (user->username.isEmpty() ? QString() : ('@' + user->username)) : user->username.mid(filterSize);
|
||||
auto firstwidth = st::mentionFont->width(first);
|
||||
auto secondwidth = st::mentionFont->width(second);
|
||||
auto unamewidth = firstwidth + secondwidth;
|
||||
auto namewidth = user->nameText().maxWidth();
|
||||
if (mentionwidth < unamewidth + namewidth) {
|
||||
namewidth = (mentionwidth * namewidth) / (namewidth + unamewidth);
|
||||
unamewidth = mentionwidth - namewidth;
|
||||
|
@ -615,7 +618,7 @@ void FieldAutocompleteInner::paintEvent(QPaintEvent *e) {
|
|||
user->paintUserpicLeft(p, 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);
|
||||
user->nameText().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);
|
||||
|
|
|
@ -100,7 +100,7 @@ PeerData::PeerData(not_null<Data::Session*> owner, PeerId id)
|
|||
: id(id)
|
||||
, _owner(owner)
|
||||
, _userpicEmpty(createEmptyUserpic()) {
|
||||
nameText.setText(st::msgNameStyle, QString(), Ui::NameTextOptions());
|
||||
_nameText.setText(st::msgNameStyle, QString(), Ui::NameTextOptions());
|
||||
}
|
||||
|
||||
Data::Session &PeerData::owner() const {
|
||||
|
@ -134,7 +134,7 @@ void PeerData::updateNameDelayed(
|
|||
}
|
||||
}
|
||||
name = newName;
|
||||
nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
|
||||
_nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
|
||||
refreshEmptyUserpic();
|
||||
Notify::PeerUpdate update(this);
|
||||
if (nameVersion++ > 1) {
|
||||
|
@ -592,12 +592,22 @@ not_null<const PeerData*> PeerData::migrateToOrMe() const {
|
|||
return this;
|
||||
}
|
||||
|
||||
const Text &PeerData::dialogName() const {
|
||||
return migrateTo()
|
||||
? migrateTo()->dialogName()
|
||||
: (isUser() && !asUser()->phoneText.isEmpty())
|
||||
? asUser()->phoneText
|
||||
: nameText;
|
||||
const Text &PeerData::topBarNameText() const {
|
||||
if (const auto to = migrateTo()) {
|
||||
return to->topBarNameText();
|
||||
} else if (const auto user = asUser()) {
|
||||
if (!user->phoneText.isEmpty()) {
|
||||
return user->phoneText;
|
||||
}
|
||||
}
|
||||
return _nameText;
|
||||
}
|
||||
|
||||
const Text &PeerData::nameText() const {
|
||||
if (const auto to = migrateTo()) {
|
||||
return to->nameText();
|
||||
}
|
||||
return _nameText;
|
||||
}
|
||||
|
||||
const QString &PeerData::shortName() const {
|
||||
|
|
|
@ -204,8 +204,9 @@ public:
|
|||
return (_lastFullUpdate != 0);
|
||||
}
|
||||
|
||||
[[nodiscard]] const Text &dialogName() const;
|
||||
[[nodiscard]] const Text &nameText() const;
|
||||
[[nodiscard]] const QString &shortName() const;
|
||||
[[nodiscard]] const Text &topBarNameText() const;
|
||||
[[nodiscard]] QString userName() const;
|
||||
|
||||
[[nodiscard]] int32 bareId() const {
|
||||
|
@ -324,7 +325,6 @@ public:
|
|||
|
||||
const PeerId id;
|
||||
QString name;
|
||||
Text nameText;
|
||||
LoadedStatus loadedStatus = NotLoaded;
|
||||
MTPinputPeer input;
|
||||
|
||||
|
@ -359,6 +359,7 @@ private:
|
|||
PhotoId _userpicPhotoId = kUnknownPhotoId;
|
||||
mutable std::unique_ptr<Ui::EmptyUserpic> _userpicEmpty;
|
||||
StorageImageLocation _userpicLocation;
|
||||
Text _nameText;
|
||||
|
||||
Data::NotifySettings _notify;
|
||||
|
||||
|
|
|
@ -733,7 +733,7 @@ void InnerWidget::paintPeerSearchResult(
|
|||
if (peer->isVerified()) {
|
||||
auto icon = &(active ? st::dialogsVerifiedIconActive : (selected ? st::dialogsVerifiedIconOver : st::dialogsVerifiedIcon));
|
||||
rectForName.setWidth(rectForName.width() - icon->width());
|
||||
icon->paint(p, rectForName.topLeft() + QPoint(qMin(peer->dialogName().maxWidth(), rectForName.width()), 0), fullWidth);
|
||||
icon->paint(p, rectForName.topLeft() + QPoint(qMin(peer->nameText().maxWidth(), rectForName.width()), 0), fullWidth);
|
||||
}
|
||||
|
||||
QRect tr(nameleft, st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip, namewidth, st::dialogsTextFont->height);
|
||||
|
@ -758,7 +758,7 @@ void InnerWidget::paintPeerSearchResult(
|
|||
}
|
||||
|
||||
p.setPen(active ? st::dialogsTextFgActive : st::dialogsNameFg);
|
||||
peer->dialogName().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
peer->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
}
|
||||
|
||||
void InnerWidget::paintSearchInChat(Painter &p) const {
|
||||
|
|
|
@ -424,9 +424,9 @@ void paintRow(
|
|||
if (!(flags & Flag::SearchResult) && from->isVerified()) {
|
||||
auto icon = &(active ? st::dialogsVerifiedIconActive : (selected ? st::dialogsVerifiedIconOver : st::dialogsVerifiedIcon));
|
||||
rectForName.setWidth(rectForName.width() - icon->width());
|
||||
icon->paint(p, rectForName.topLeft() + QPoint(qMin(from->dialogName().maxWidth(), rectForName.width()), 0), fullWidth);
|
||||
icon->paint(p, rectForName.topLeft() + QPoint(qMin(from->nameText().maxWidth(), rectForName.width()), 0), fullWidth);
|
||||
}
|
||||
from->dialogName().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
from->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
} else if (hiddenSenderInfo) {
|
||||
hiddenSenderInfo->nameText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
} else {
|
||||
|
|
|
@ -117,7 +117,7 @@ void UserCheckbox::paintEvent(QPaintEvent *e) {
|
|||
auto nameTop = userpicTop + st::contactsNameTop;
|
||||
auto nameWidth = width() - nameLeft - st::contactsPadding.right();
|
||||
p.setPen(st::contactsNameFg);
|
||||
_user->nameText.drawLeftElided(p, nameLeft, nameTop, nameWidth, width());
|
||||
_user->nameText().drawLeftElided(p, nameLeft, nameTop, nameWidth, width());
|
||||
|
||||
auto statusLeft = nameLeft;
|
||||
auto statusTop = userpicTop + st::contactsStatusTop;
|
||||
|
|
|
@ -295,7 +295,7 @@ QSize Message::performCountOptimalSize() {
|
|||
if (displayFromName()) {
|
||||
const auto from = item->displayFrom();
|
||||
const auto &name = from
|
||||
? from->nameText
|
||||
? from->nameText()
|
||||
: item->hiddenForwardedInfo()->nameText;
|
||||
auto namew = st::msgPadding.left()
|
||||
+ name.maxWidth()
|
||||
|
@ -548,10 +548,10 @@ void Message::paintFromName(
|
|||
const auto from = item->displayFrom();
|
||||
if (item->isPost()) {
|
||||
p.setPen(selected ? st::msgInServiceFgSelected : st::msgInServiceFg);
|
||||
return &from->nameText;
|
||||
return &from->nameText();
|
||||
} else if (from) {
|
||||
p.setPen(FromNameFg(from->id, selected));
|
||||
return &from->nameText;
|
||||
return &from->nameText();
|
||||
} else if (const auto info = item->hiddenForwardedInfo()) {
|
||||
p.setPen(FromNameFg(info->colorPeerId, selected));
|
||||
return &info->nameText;
|
||||
|
@ -888,7 +888,7 @@ bool Message::getStateFromName(
|
|||
const auto from = item->displayFrom();
|
||||
const auto nameText = [&]() -> const Text* {
|
||||
if (from) {
|
||||
return &from->nameText;
|
||||
return &from->nameText();
|
||||
} else if (const auto info = item->hiddenForwardedInfo()) {
|
||||
return &info->nameText;
|
||||
} else {
|
||||
|
@ -1563,7 +1563,7 @@ void Message::fromNameUpdated(int width) const {
|
|||
if (!displayForwardedFrom()) {
|
||||
const auto nameText = [&]() -> const Text* {
|
||||
if (from) {
|
||||
return &from->nameText;
|
||||
return &from->nameText();
|
||||
} else if (const auto info = item->hiddenForwardedInfo()) {
|
||||
return &info->nameText;
|
||||
} else {
|
||||
|
|
|
@ -334,7 +334,7 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
|||
width(),
|
||||
text);
|
||||
} else if (const auto history = _activeChat.history()) {
|
||||
history->peer->dialogName().drawElided(p, nameleft, nametop, namewidth);
|
||||
history->peer->topBarNameText().drawElided(p, nameleft, nametop, namewidth);
|
||||
|
||||
p.setFont(st::dialogsTextFont);
|
||||
if (paintConnectingState(p, nameleft, statustop, width())) {
|
||||
|
|
|
@ -716,7 +716,7 @@ void Notification::updateNotifyDisplay() {
|
|||
|
||||
p.setPen(st::dialogsNameFg);
|
||||
if (!options.hideNameAndPhoto) {
|
||||
_history->peer->dialogName().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
_history->peer->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
} else {
|
||||
p.setFont(st::msgNameFont);
|
||||
static QString notifyTitle = st::msgNameFont->elided(qsl("Telegram Desktop"), rectForName.width());
|
||||
|
|
|
@ -332,7 +332,7 @@ void MainMenu::refreshBackground() {
|
|||
st::mainMenuCoverTextLeft,
|
||||
st::mainMenuCoverNameTop,
|
||||
std::max(
|
||||
st::semiboldFont->width(Auth().user()->nameText.toString()),
|
||||
st::semiboldFont->width(Auth().user()->nameText().toString()),
|
||||
st::normalFont->width(_phoneText)),
|
||||
st::semiboldFont->height * 2);
|
||||
|
||||
|
@ -405,7 +405,7 @@ void MainMenu::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
p.setPen(st::mainMenuCoverFg);
|
||||
p.setFont(st::semiboldFont);
|
||||
Auth().user()->nameText.drawLeftElided(
|
||||
Auth().user()->nameText().drawLeftElided(
|
||||
p,
|
||||
st::mainMenuCoverTextLeft,
|
||||
st::mainMenuCoverNameTop,
|
||||
|
|
Loading…
Reference in New Issue