Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Right to Left capability to Telegram for languages like arabic, urdu and persian #24467

Draft
wants to merge 34 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f2c5dd0
fix(dialogs): fix cornerBadge position
AMP999 Mar 30, 2022
fb9cd49
fix(dialogs): fix userpic postion when userbadge exists
AMP999 Mar 31, 2022
d683ae0
fix(dialogs): fix empty unread badge's position
AMP999 Mar 31, 2022
b22cd45
fix(dialogs): fix paintRowTopRight to be rtl compatible
AMP999 Apr 3, 2022
33c2fe7
fix(dialogs): fix last message date position
AMP999 Apr 3, 2022
4f7637a
fix(dialogs): fix unread counter and unread mark position
AMP999 Apr 3, 2022
4b63190
fix(dialogs): fix pinned icon position
AMP999 Apr 3, 2022
4531441
fix(dialogs): fix mention or reaction badge position
AMP999 Apr 3, 2022
7e70fd1
fix(dialogs): fix drawScamFakeBadge to be rtl compatible
AMP999 Apr 3, 2022
e00a501
fix(dialogs): fix scam badge position
AMP999 Apr 3, 2022
b882976
fix(dialogs): fix sender name position in message view
AMP999 Apr 3, 2022
e6884c1
fix(dialogs): fix mini image preview position in message view
AMP999 Apr 3, 2022
def7be6
fix(dialogs): fix text preview position in message view
AMP999 Apr 3, 2022
7d46366
fix(dialogs): fix archived chats title's position in collapsed row
AMP999 Apr 3, 2022
212b04d
fix(dialogs): fix unread message count position in collapsed row
AMP999 Apr 3, 2022
e4726d5
docs(dialogs): explain conditions in paintRow
AMP999 Apr 4, 2022
2afacb0
fix(dialogs): fix topPromotionType position
AMP999 Apr 4, 2022
16b13f2
fix(dialogs): fix chatTypeIcon position
AMP999 Apr 4, 2022
946287b
fix(dialogs): fix last message summary position
AMP999 Apr 5, 2022
4c663b4
docs(dialogs): explain hiddenSenderInfo
AMP999 Apr 5, 2022
e92da63
fix(dialogs): fix Date position when draft exists
AMP999 Apr 5, 2022
4792d49
fix(dialogs): fix date position in dialogs
AMP999 Apr 5, 2022
7784c9b
fix(dialogs): fix chat's name position
AMP999 Apr 5, 2022
0079c41
fix(dialogs): fix dialog's name when hidden sender exists
AMP999 Apr 5, 2022
577a333
fix(connecting_widget): fix connecting widget's circle when connected
AMP999 Apr 3, 2022
1012f89
fix(history): fix history's geometry
AMP999 Apr 28, 2022
703a91c
fix(histroy): fix history's resize area geometry
AMP999 Apr 28, 2022
40bd013
fix(history): fix history's resize area direction
AMP999 Apr 28, 2022
d4e819a
fix(third_section): fix third section geometry
AMP999 Apr 28, 2022
e2f14e6
fix(third_section): fix third section's resize area geometry
AMP999 Apr 28, 2022
dc7e047
fix(third_section): fix third section's resize direction
AMP999 Apr 28, 2022
77b861e
Merge branch 'dev' into rtl-telegram
AMP999 May 8, 2022
159c7b5
Merge branch 'dev' into rtl-telegram
AMP999 May 14, 2022
ca8c16b
Merge branch 'rtl-telegram' of https://github.com/AMP999/tdesktop int…
AMP999 May 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Telegram/SourceFiles/dialogs/dialogs_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ void BasicRow::PaintCornerBadgeFrame(
q.setBrush(data->active
? st::dialogsOnlineBadgeFgActive
: st::dialogsOnlineBadgeFg);
//paints corner online or calling badge next to userpic in dialogs
q.drawEllipse(QRectF(
st::dialogsPhotoSize - skip.x() - size,
(rtl()
? skip.x()
: (st::dialogsPhotoSize - skip.x() - size)),
st::dialogsPhotoSize - skip.y() - size,
size,
size
Expand Down Expand Up @@ -247,7 +250,10 @@ void BasicRow::paintUserpic(
_cornerBadgeUserpic->active = active;
PaintCornerBadgeFrame(_cornerBadgeUserpic.get(), peer, _userpic);
}
p.drawImage(st::dialogsPadding, _cornerBadgeUserpic->frame);
//when a corner badge exists this function is called to paint userpic
rtl()
? p.drawImage(fullWidth - st::dialogsPadding.x() - st::dialogsPhotoSize, st::dialogsPadding.y(), _cornerBadgeUserpic->frame)
: p.drawImage(st::dialogsPadding, _cornerBadgeUserpic->frame);
Comment on lines +254 to +256
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rtl()
? p.drawImage(fullWidth - st::dialogsPadding.x() - st::dialogsPhotoSize, st::dialogsPadding.y(), _cornerBadgeUserpic->frame)
: p.drawImage(st::dialogsPadding, _cornerBadgeUserpic->frame);
p.drawImage(
rtl()
? fullWidth - st::dialogsPadding.x() - st::dialogsPhotoSize
: st::dialogsPadding.x(),
st::dialogsPadding.y(),
_cornerBadgeUserpic->frame);

if (historyForCornerBadge->peer->isUser()) {
return;
}
Expand Down
73 changes: 56 additions & 17 deletions Telegram/SourceFiles/dialogs/ui/dialogs_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,19 @@ const auto kPsaBadgePrefix = "cloud_lng_badge_psa_";
|| history->peer->asUser()->onlineTill > 0);
}

void PaintRowTopRight(Painter &p, const QString &text, QRect &rectForName, bool active, bool selected) {
void PaintRowTopRight(Painter &p, const QString &text, QRect &rectForName, bool active, bool selected, int outerw = -1) {
const auto width = st::dialogsDateFont->width(text);
rectForName.setWidth(rectForName.width() - width - st::dialogsDateSkip);
p.setFont(st::dialogsDateFont);
p.setPen(active ? st::dialogsDateFgActive : (selected ? st::dialogsDateFgOver : st::dialogsDateFg));
p.drawText(rectForName.left() + rectForName.width() + st::dialogsDateSkip, rectForName.top() + st::msgNameFont->height - st::msgDateFont->descent, text);
auto left = rectForName.left() + rectForName.width() + st::dialogsDateSkip;
if (rtl() && outerw > 0){
left = outerw - left - width;
}
p.drawText(left, rectForName.top() + st::msgNameFont->height - st::msgDateFont->descent, text);
}

void PaintRowDate(Painter &p, QDateTime date, QRect &rectForName, bool active, bool selected) {
void PaintRowDate(Painter &p, QDateTime date, QRect &rectForName, bool active, bool selected, int outerw) {
const auto now = QDateTime::currentDateTime();
const auto &lastTime = date;
const auto nowDate = now.date();
Expand All @@ -77,7 +81,8 @@ void PaintRowDate(Painter &p, QDateTime date, QRect &rectForName, bool active, b
return lastDate.toString(cDateFormat());
}
}();
PaintRowTopRight(p, dt, rectForName, active, selected);
//paints dialogs last message date on each row
PaintRowTopRight(p, dt, rectForName, active, selected, outerw);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PaintRowTopRight(p, dt, rectForName, active, selected, outerw);
PaintRowTopRight(p, dt, rectForName, active, selected, outerw);

}

void PaintNarrowCounter(
Expand All @@ -102,6 +107,7 @@ void PaintNarrowCounter(
: 3;
const auto unreadRight = st::dialogsPadding.x()
+ st::dialogsPhotoSize;
const auto unreadLeft = st::dialogsPadding.x();
const auto unreadTop = st::dialogsPadding.y()
+ st::dialogsPhotoSize
- st::dialogsUnreadHeight;
Expand All @@ -110,10 +116,14 @@ void PaintNarrowCounter(
st.active = active;
st.selected = selected;
st.muted = unreadMuted;
st.align = rtl() ? style::al_left : style::al_right;
//paints unread counter or mark badge in narrow dialogs
const auto badge = PaintUnreadBadge(
p,
counter,
unreadRight,
(rtl()
? unreadLeft
: unreadRight),
Comment on lines +124 to +126
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(rtl()
? unreadLeft
: unreadRight),
(rtl() ? unreadLeft : unreadRight),

unreadTop,
st,
allowDigits);
Expand Down Expand Up @@ -178,8 +188,10 @@ int PaintWideCounter(
const auto counter = (unreadCount > 0)
? QString::number(unreadCount)
: QString();
//sets unread counter or unread mark badge coordination
const auto unreadRight = fullWidth
- st::dialogsPadding.x();
const auto unreadLeft = st::dialogsPadding.x();
const auto unreadTop = texttop
+ st::dialogsTextFont->ascent
- st::dialogsUnreadFont->ascent
Expand All @@ -189,10 +201,14 @@ int PaintWideCounter(
st.active = active;
st.selected = selected;
st.muted = unreadMuted;
st.align = rtl() ? style::al_left : style::al_right;
//paints unread counter or unread mark badge
const auto badge = PaintUnreadBadge(
p,
counter,
unreadRight,
(rtl()
? unreadLeft
: unreadRight),
Comment on lines +209 to +211
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(rtl()
? unreadLeft
: unreadRight),
(rtl() ? unreadLeft : unreadRight),

unreadTop,
st);
availableWidth -= badge.width() + st.padding;
Expand All @@ -204,6 +220,7 @@ int PaintWideCounter(
: selected
? st::dialogsPinnedIconOver
: st::dialogsPinnedIcon;
//paints pinned icon on dialogs if unread counter or unread mark doesn't exist
icon.paint(
p,
fullWidth - st::dialogsPadding.x() - icon.width(),
Expand All @@ -215,9 +232,11 @@ int PaintWideCounter(
}
if (displayMentionBadge || displayReactionBadge) {
const auto counter = QString();
//mention or reaction badge coordination
const auto unreadRight = fullWidth
- st::dialogsPadding.x()
- (initial - availableWidth);
const auto unreadLeft = st::dialogsPadding.x() + (initial - availableWidth);
const auto unreadTop = texttop
+ st::dialogsTextFont->ascent
- st::dialogsUnreadFont->ascent
Expand All @@ -232,12 +251,13 @@ int PaintWideCounter(
st.muted = mentionOrReactionMuted;
st.padding = 0;
st.textTop = 0;
st.align = rtl() ? style::al_left : style::al_right;
const auto badge = PaintUnreadBadge(
p,
counter,
unreadRight,
rtl() ? unreadLeft : unreadRight,
unreadTop,
st);
st); /**paints mention or reaction badge*/
(displayMentionBadge
? (st.active
? st::dialogsUnreadMentionActive
Expand All @@ -248,7 +268,7 @@ int PaintWideCounter(
? st::dialogsUnreadReactionActive
: st.selected
? st::dialogsUnreadReactionOver
: st::dialogsUnreadReaction)).paintInCenter(p, badge);
: st::dialogsUnreadReaction)).paintInCenter(p, badge); /**paints mention or reaction inner icon at the center*/
availableWidth -= badge.width()
+ st.padding
+ (hadOneBadge ? st::dialogsUnreadPadding : 0);
Expand Down Expand Up @@ -372,6 +392,7 @@ void paintRow(
fullWidth,
st::dialogsPhotoSize);
} else {
//Archived Chats folder goes here
entry->paintUserpicLeft(
p,
row->userpicView(),
Expand Down Expand Up @@ -410,9 +431,11 @@ void paintRow(
: custom.isEmpty()
? tr::lng_badge_psa_default(tr::now)
: custom;
PaintRowTopRight(p, text, rectForName, active, selected);
//paints promoted chat's type for example "proxy sponsor"
PaintRowTopRight(p, text, rectForName, active, selected, fullWidth);
} else if (from) {
if (const auto chatTypeIcon = ChatTypeIcon(from, active, selected)) {
//paints chat type icon(it's rtl compatible due to lib_ui function usage)
chatTypeIcon->paint(p, rectForName.topLeft(), fullWidth);
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
}
Expand All @@ -435,7 +458,8 @@ void paintRow(
|| (supportMode
&& entry->session().supportHelper().isOccupiedBySomeone(history))) {
if (!promoted) {
PaintRowDate(p, date, rectForName, active, selected);
//paints date when drafts exists
PaintRowDate(p , date, rectForName, active, selected, fullWidth);
}

auto availableWidth = namewidth;
Expand Down Expand Up @@ -495,7 +519,8 @@ void paintRow(
}
} else if (!item->isEmpty()) {
if (history && !promoted) {
PaintRowDate(p, date, rectForName, active, selected);
//paints date
PaintRowDate(p, date, rectForName, active, selected, fullWidth);
}

paintItemCallback(nameleft, namewidth);
Expand Down Expand Up @@ -582,14 +607,16 @@ void paintRow(
: selected
? st::dialogsNameFgOver
: st::dialogsNameFg);
from->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
//draw chat's name
from->nameText().drawLeftElided(p, rectForName.left(), rectForName.top(), rectForName.width(), fullWidth, 1);
} else if (hiddenSenderInfo) {
p.setPen(active
? st::dialogsNameFgActive
: selected
? st::dialogsNameFgOver
: st::dialogsNameFg);
hiddenSenderInfo->nameText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
//draw chat's name when hidden sender info exists
hiddenSenderInfo->nameText.drawLeftElided(p, rectForName.left(), rectForName.top(), rectForName.width(), fullWidth);
} else {
p.setPen(active
? st::dialogsNameFgActive
Expand Down Expand Up @@ -889,8 +916,11 @@ void RowPainter::paint(
: (selected
? st::dialogsTextFgServiceOver
: st::dialogsTextFgService);
//creates rect for last message in each dialog
const auto itemRect = QRect(
nameleft,
(rtl()
? fullWidth - nameleft - availableWidth
: nameleft),
Comment on lines +921 to +923
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(rtl()
? fullWidth - nameleft - availableWidth
: nameleft),
(rtl() ? (fullWidth - nameleft - availableWidth) : nameleft),

texttop,
availableWidth,
st::dialogsTextFont->height);
Expand Down Expand Up @@ -1128,7 +1158,11 @@ void PaintCollapsedRow(
const auto left = narrow
? ((fullWidth - st::semiboldFont->width(text)) / 2)
: st::dialogsPadding.x();
p.drawText(left, textBaseline, text);
const auto right = (narrow
? (fullWidth - st::semiboldFont->width(text)) / 2
: (fullWidth - st::semiboldFont->width(text) - st::dialogsPadding.x()));
//draws achived chats title when collapsed
p.drawText(rtl() ? right : left, textBaseline, text);
} else {
folder->paintUserpicLeft(
p,
Expand All @@ -1140,12 +1174,17 @@ void PaintCollapsedRow(
}
if (!narrow && unread) {
const auto unreadRight = fullWidth - st::dialogsPadding.x();
const auto unreadLeft = st::dialogsPadding.x();
UnreadBadgeStyle st;
st.muted = true;
st.align = rtl() ? style::al_left : style::al_right;
//paints unread counter badge in collapsed archived folder in wide mode
PaintUnreadBadge(
p,
QString::number(unread),
unreadRight,
(rtl()
? unreadLeft
: unreadRight),
Comment on lines +1185 to +1187
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(rtl()
? unreadLeft
: unreadRight),
(rtl() ? unreadLeft : unreadRight),

unreadTop,
st);
}
Expand Down
12 changes: 9 additions & 3 deletions Telegram/SourceFiles/dialogs/ui/dialogs_message_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ void MessageView::paint(
if (!_senderCache.isEmpty()) {
_senderCache.drawElided(
p,
rect.left(),
(rtl()
? (geometry.left() + geometry.right() - rect.left() - _senderCache.maxWidth())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use QRect::right() method. It can be replaced with geometry.left() + geometry.width().

: rect.left()),
rect.top(),
rect.width(),
rect.height() / st::dialogsTextFont->height);
Expand All @@ -177,7 +179,9 @@ void MessageView::paint(
break;
}
p.drawImage(
rect.x(),
(rtl()
? (geometry.left() + geometry.right() - rect.left() - st::dialogsMiniPreview)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use QRect::right() method. It can be replaced with geometry.left() + geometry.width().

: rect.x()),
rect.y() + st::dialogsMiniPreviewTop,
image.data);
rect.setLeft(rect.x()
Expand All @@ -192,7 +196,9 @@ void MessageView::paint(
}
_textCache.drawElided(
p,
rect.left(),
(rtl()
? geometry.left()
: rect.left()),
Comment on lines +199 to +201
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(rtl()
? geometry.left()
: rect.left()),
(rtl() ? geometry.left() : rect.left()),

rect.top(),
rect.width(),
rect.height() / st::dialogsTextFont->height);
Expand Down
22 changes: 18 additions & 4 deletions Telegram/SourceFiles/mainwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,9 @@ void MainWidget::updateControlsGeometry() {
if (_thirdSection) {
auto thirdSectionTop = getThirdSectionTop();
_thirdSection->setGeometry(
width() - thirdSectionWidth,
(rtl()
? 0
: width() - thirdSectionWidth),
Comment on lines +2196 to +2198
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(rtl()
? 0
: width() - thirdSectionWidth),
(rtl() ? 0 : (width() - thirdSectionWidth)),

thirdSectionTop,
thirdSectionWidth,
height() - thirdSectionTop);
Expand Down Expand Up @@ -2238,7 +2240,9 @@ void MainWidget::updateControlsGeometry() {
_callTopBarHeight + _exportTopBarHeight);
}
_history->setGeometryWithTopMoved(QRect(
dialogsWidth,
(rtl()
? thirdSectionWidth
: dialogsWidth),
Comment on lines +2243 to +2245
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(rtl()
? thirdSectionWidth
: dialogsWidth),
(rtl() ? thirdSectionWidth : dialogsWidth),

mainSectionTop,
mainSectionWidth,
height() - mainSectionTop
Expand Down Expand Up @@ -2275,7 +2279,9 @@ void MainWidget::refreshResizeAreas() {
if (!isOneColumn()) {
ensureFirstColumnResizeAreaCreated();
_firstColumnResizeArea->setGeometryToLeft(
_history->x(),
(rtl()
? _dialogsWidth
: _history->x()),
Comment on lines +2282 to +2284
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(rtl()
? _dialogsWidth
: _history->x()),
(rtl() ? _dialogsWidth : _history->x()),

0,
st::historyResizeWidth,
height());
Expand All @@ -2286,7 +2292,9 @@ void MainWidget::refreshResizeAreas() {
if (isThreeColumn() && _thirdSection) {
ensureThirdColumnResizeAreaCreated();
_thirdColumnResizeArea->setGeometryToLeft(
_thirdSection->x(),
(rtl()
? (width() - _thirdSection->width())
: _thirdSection->x()),
Comment on lines +2295 to +2297
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(rtl()
? (width() - _thirdSection->width())
: _thirdSection->x()),
(rtl() ? (width() - _thirdSection->width()) : _thirdSection->x()),

0,
st::historyResizeWidth,
height());
Expand Down Expand Up @@ -2315,6 +2323,9 @@ void MainWidget::ensureFirstColumnResizeAreaCreated() {
}
auto moveLeftCallback = [=](int globalLeft) {
auto newWidth = globalLeft - mapToGlobal(QPoint(0, 0)).x();
newWidth = rtl()
? width() - newWidth
: newWidth;
Comment on lines +2326 to +2328
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
newWidth = rtl()
? width() - newWidth
: newWidth;
newWidth = rtl() ? (width() - newWidth) : newWidth;

auto newRatio = (newWidth < st::columnMinimalWidthLeft / 2)
? 0.
: float64(newWidth) / width();
Expand Down Expand Up @@ -2342,6 +2353,9 @@ void MainWidget::ensureThirdColumnResizeAreaCreated() {
}
auto moveLeftCallback = [=](int globalLeft) {
auto newWidth = mapToGlobal(QPoint(width(), 0)).x() - globalLeft;
newWidth = rtl()
? (width() - newWidth)
: newWidth;
Comment on lines +2356 to +2358
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
newWidth = rtl()
? (width() - newWidth)
: newWidth;
newWidth = rtl() ? (width() - newWidth) : newWidth;

Core::App().settings().setThirdColumnWidth(newWidth);
};
auto moveFinishedCallback = [=] {
Expand Down
29 changes: 19 additions & 10 deletions Telegram/SourceFiles/ui/unread_badge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,21 @@ void DrawScamFakeBadge(
p.setBrush(Qt::NoBrush);
p.drawRoundedRect(rect, st::dialogsScamRadius, st::dialogsScamRadius);
p.setFont(st::dialogsScamFont);
p.drawTextLeft(
rect.x() + st::dialogsScamPadding.left(),
rect.y() + st::dialogsScamPadding.top(),
outerWidth,
phrase,
phraseWidth);
if (rtl()) {
p.drawTextRight(
rect.x() + st::dialogsScamPadding.left(),
rect.y() + st::dialogsScamPadding.top(),
outerWidth,
phrase,
phraseWidth);
} else {
p.drawTextLeft(
rect.x() + st::dialogsScamPadding.left(),
rect.y() + st::dialogsScamPadding.top(),
outerWidth,
phrase,
phraseWidth);
}
}

void DrawScamBadge(
Expand Down Expand Up @@ -128,11 +137,11 @@ int DrawPeerBadgeGetWidth(
const auto height = st::dialogsScamPadding.top()
+ st::dialogsScamFont->height
+ st::dialogsScamPadding.bottom();
auto x = (rtl()
? rectForName.right() - qMin(nameWidth + st::dialogsScamSkip, rectForName.width() - width) - width
: rectForName.x() + qMin(nameWidth + st::dialogsScamSkip, rectForName.width() - width));
Comment on lines +140 to +142
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto x = (rtl()
? rectForName.right() - qMin(nameWidth + st::dialogsScamSkip, rectForName.width() - width) - width
: rectForName.x() + qMin(nameWidth + st::dialogsScamSkip, rectForName.width() - width));
const auto minWidth = std::min(
nameWidth + st::dialogsScamSkip,
rectForName.width() - width);
const auto x = rtl()
? (rectForName.x() + rectForName.width() - minWidth - width)
: (rectForName.x() + minWidth);

const auto rect = QRect(
(rectForName.x()
+ qMin(
nameWidth + st::dialogsScamSkip,
rectForName.width() - width)),
x,
rectForName.y() + (rectForName.height() - height) / 2,
width,
height);
Expand Down
Loading