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