mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Moved left elision of counters to Dialogs::Layout::paintUnreadCount.
This commit is contained in:
parent
626e7c1f76
commit
1dd461b24a
@ -79,9 +79,6 @@ void PaintNarrowCounter(
|
||||
? QString::number(unreadCount)
|
||||
: QString();
|
||||
const auto allowDigits = displayMentionBadge ? 1 : 3;
|
||||
if (counter.size() > allowDigits + 1) {
|
||||
counter = qsl("..") + counter.mid(counter.size() - allowDigits);
|
||||
}
|
||||
auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize;
|
||||
auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight;
|
||||
auto unreadWidth = 0;
|
||||
@ -89,7 +86,7 @@ void PaintNarrowCounter(
|
||||
UnreadBadgeStyle st;
|
||||
st.active = active;
|
||||
st.muted = unreadMuted;
|
||||
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
|
||||
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth, allowDigits);
|
||||
skipBeforeMention += unreadWidth + st.padding;
|
||||
}
|
||||
if (displayMentionBadge) {
|
||||
@ -553,11 +550,16 @@ UnreadBadgeStyle::UnreadBadgeStyle()
|
||||
|
||||
void paintUnreadCount(
|
||||
Painter &p,
|
||||
const QString &text,
|
||||
const QString &unreadCount,
|
||||
int x,
|
||||
int y,
|
||||
const UnreadBadgeStyle &st,
|
||||
int *outUnreadWidth) {
|
||||
int *outUnreadWidth,
|
||||
int allowDigits) {
|
||||
const auto text = (allowDigits > 0) && (unreadCount.size() > allowDigits + 1)
|
||||
? qsl("..") + unreadCount.mid(unreadCount.size() - allowDigits)
|
||||
: unreadCount;
|
||||
|
||||
int unreadWidth = st.font->width(text);
|
||||
int unreadRectWidth = unreadWidth + 2 * st.padding;
|
||||
int unreadRectHeight = st.size;
|
||||
|
@ -81,11 +81,12 @@ struct UnreadBadgeStyle {
|
||||
};
|
||||
void paintUnreadCount(
|
||||
Painter &p,
|
||||
const QString &text,
|
||||
const QString &t,
|
||||
int x,
|
||||
int y,
|
||||
const UnreadBadgeStyle &st,
|
||||
int *outUnreadWidth = nullptr);
|
||||
int *outUnreadWidth = nullptr,
|
||||
int allowDigits = 0);
|
||||
|
||||
void clearUnreadBadgesCache();
|
||||
|
||||
|
@ -158,16 +158,13 @@ void HistoryDownButton::paintEvent(QPaintEvent *e) {
|
||||
((over || down) ? _st.iconAboveOver : _st.iconAbove).paint(p, _st.iconPosition, width());
|
||||
if (_unreadCount > 0) {
|
||||
auto unreadString = QString::number(_unreadCount);
|
||||
if (unreadString.size() > 4) {
|
||||
unreadString = qsl("..") + unreadString.mid(unreadString.size() - 4);
|
||||
}
|
||||
|
||||
Dialogs::Layout::UnreadBadgeStyle st;
|
||||
st.align = style::al_center;
|
||||
st.font = st::historyToDownBadgeFont;
|
||||
st.size = st::historyToDownBadgeSize;
|
||||
st.sizeId = Dialogs::Layout::UnreadBadgeInHistoryToDown;
|
||||
Dialogs::Layout::paintUnreadCount(p, unreadString, width(), 0, st, nullptr);
|
||||
Dialogs::Layout::paintUnreadCount(p, unreadString, width(), 0, st, nullptr, 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user