mirror of https://github.com/procxx/kepka.git
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::number(unreadCount)
|
||||||
: QString();
|
: QString();
|
||||||
const auto allowDigits = displayMentionBadge ? 1 : 3;
|
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 unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize;
|
||||||
auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight;
|
auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight;
|
||||||
auto unreadWidth = 0;
|
auto unreadWidth = 0;
|
||||||
|
@ -89,7 +86,7 @@ void PaintNarrowCounter(
|
||||||
UnreadBadgeStyle st;
|
UnreadBadgeStyle st;
|
||||||
st.active = active;
|
st.active = active;
|
||||||
st.muted = unreadMuted;
|
st.muted = unreadMuted;
|
||||||
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
|
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth, allowDigits);
|
||||||
skipBeforeMention += unreadWidth + st.padding;
|
skipBeforeMention += unreadWidth + st.padding;
|
||||||
}
|
}
|
||||||
if (displayMentionBadge) {
|
if (displayMentionBadge) {
|
||||||
|
@ -553,11 +550,16 @@ UnreadBadgeStyle::UnreadBadgeStyle()
|
||||||
|
|
||||||
void paintUnreadCount(
|
void paintUnreadCount(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const QString &text,
|
const QString &unreadCount,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
const UnreadBadgeStyle &st,
|
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 unreadWidth = st.font->width(text);
|
||||||
int unreadRectWidth = unreadWidth + 2 * st.padding;
|
int unreadRectWidth = unreadWidth + 2 * st.padding;
|
||||||
int unreadRectHeight = st.size;
|
int unreadRectHeight = st.size;
|
||||||
|
|
|
@ -81,11 +81,12 @@ struct UnreadBadgeStyle {
|
||||||
};
|
};
|
||||||
void paintUnreadCount(
|
void paintUnreadCount(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const QString &text,
|
const QString &t,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
const UnreadBadgeStyle &st,
|
const UnreadBadgeStyle &st,
|
||||||
int *outUnreadWidth = nullptr);
|
int *outUnreadWidth = nullptr,
|
||||||
|
int allowDigits = 0);
|
||||||
|
|
||||||
void clearUnreadBadgesCache();
|
void clearUnreadBadgesCache();
|
||||||
|
|
||||||
|
|
|
@ -158,16 +158,13 @@ void HistoryDownButton::paintEvent(QPaintEvent *e) {
|
||||||
((over || down) ? _st.iconAboveOver : _st.iconAbove).paint(p, _st.iconPosition, width());
|
((over || down) ? _st.iconAboveOver : _st.iconAbove).paint(p, _st.iconPosition, width());
|
||||||
if (_unreadCount > 0) {
|
if (_unreadCount > 0) {
|
||||||
auto unreadString = QString::number(_unreadCount);
|
auto unreadString = QString::number(_unreadCount);
|
||||||
if (unreadString.size() > 4) {
|
|
||||||
unreadString = qsl("..") + unreadString.mid(unreadString.size() - 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialogs::Layout::UnreadBadgeStyle st;
|
Dialogs::Layout::UnreadBadgeStyle st;
|
||||||
st.align = style::al_center;
|
st.align = style::al_center;
|
||||||
st.font = st::historyToDownBadgeFont;
|
st.font = st::historyToDownBadgeFont;
|
||||||
st.size = st::historyToDownBadgeSize;
|
st.size = st::historyToDownBadgeSize;
|
||||||
st.sizeId = Dialogs::Layout::UnreadBadgeInHistoryToDown;
|
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