From 6400875d55d8a3a3a2fcc4e79d674efcedb4f539 Mon Sep 17 00:00:00 2001
From: 23rd <23rd@vivaldi.net>
Date: Mon, 3 Jun 2024 18:20:38 +0300
Subject: [PATCH] Replaced text drawing in menu from phone handler with
 Text::String.

---
 .../SourceFiles/core/phone_click_handler.cpp   | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/Telegram/SourceFiles/core/phone_click_handler.cpp b/Telegram/SourceFiles/core/phone_click_handler.cpp
index fc8d50d01..93b79d77d 100644
--- a/Telegram/SourceFiles/core/phone_click_handler.cpp
+++ b/Telegram/SourceFiles/core/phone_click_handler.cpp
@@ -168,7 +168,16 @@ void ResolvePhoneAction::paint(Painter &p) {
 			width());
 	} else {
 		p.setPen(selected ? _st.itemFgShortcutOver : _st.itemFgShortcut);
-		p.drawText(rect() - padding, _below.toString(), style::al_center);
+		const auto w = width() - padding.left() - padding.right();
+		_below.draw(p, Ui::Text::PaintContext{
+			.position = QPoint(
+				(width() - w) / 2,
+				(height - _below.countHeight(w)) / 2),
+			.availableWidth = w,
+			.outerWidth = w,
+			.align = style::al_center,
+			.elisionLines = 2,
+		});
 	}
 }
 
@@ -208,8 +217,6 @@ void ResolvePhoneAction::prepare() {
 			_below.setMarkedText(_st.itemStyle, { text }, options);
 			return _below.maxWidth();
 		}();
-		_above.setMarkedText(_st.itemStyle, { above }, options);
-		_below.setMarkedText(_st.itemStyle, { below }, options);
 		const auto textLeft = padding.left()
 			+ st::groupCallJoinAsPhotoSize
 			+ padding.left();
@@ -217,6 +224,11 @@ void ResolvePhoneAction::prepare() {
 			(textLeft + tempWidth + padding.right()),
 			_st.widthMin,
 			_st.widthMax);
+		if (!no.isEmpty()) {
+			_below = Ui::Text::String(w);
+		}
+		_above.setMarkedText(_st.itemStyle, { above }, options);
+		_below.setMarkedText(_st.itemStyle, { below }, options);
 		setMinWidth(w);
 		_aboveWidth = w - textLeft - padding.right();
 		_belowWidth = w