Moved out common big unread counter formatting logic to single place.

This commit is contained in:
23rd
2025-09-26 15:08:02 +03:00
committed by John Preston
parent 53321160c4
commit 1c56c4dfe5
5 changed files with 61 additions and 24 deletions

View File

@@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h"
#include "ui/unread_badge.h"
#include "ui/unread_badge_paint.h"
#include "ui/unread_counter_format.h"
#include "styles/style_dialogs.h"
#include "styles/style_widgets.h"
#include "styles/style_window.h"
@@ -180,16 +181,10 @@ int PaintBadges(
st.active = context.active;
st.selected = context.selected;
st.muted = badgesState.unreadMuted;
const auto counter = (badgesState.unreadCounter <= 0)
? QString()
: !narrow
? QString::number(badgesState.unreadCounter)
: ((badgesState.mention || badgesState.reaction)
&& (badgesState.unreadCounter > 999))
? (u"99+"_q)
: (badgesState.unreadCounter > 999999)
? (u"99999+"_q)
: QString::number(badgesState.unreadCounter);
const auto counter = FormatUnreadCounter(
badgesState.unreadCounter,
badgesState.mention || badgesState.reaction,
narrow);
const auto badge = PaintUnreadBadge(p, counter, right, top, st);
right -= badge.width() + st.padding;
} else if (const auto used = PaintRightButton(p, context)) {