mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-02 07:35:12 +00:00
Received messages are not marked as read while scroll is at the top.
HistoryToEnd button is always shown if there are unread messages. HistoryToEnd button displayes unread messages count. New service message (HistoryCleared) is handled (not displayed at all).
This commit is contained in:
@@ -134,6 +134,8 @@ QImage colorizeCircleHalf(int size, int half, int xoffset, style::color color) {
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namepsace
|
||||
|
||||
void paintUnreadBadge(Painter &p, const QRect &rect, bool active, bool muted) {
|
||||
int index = (active ? 0x01 : 0x00) | (muted ? 0x02 : 0x00);
|
||||
int size = rect.height(), sizehalf = size / 2;
|
||||
@@ -155,16 +157,21 @@ void paintUnreadBadge(Painter &p, const QRect &rect, bool active, bool muted) {
|
||||
p.drawPixmap(rect.x() + sizehalf + bar, rect.y(), unreadBadgeStyle->right[index]);
|
||||
}
|
||||
|
||||
void paintUnreadCount(Painter &p, const QString &text, int top, int w, bool active, bool muted, int *outAvailableWidth) {
|
||||
void paintUnreadCount(Painter &p, const QString &text, int x, int y, style::align align, bool active, bool muted, int *outUnreadWidth) {
|
||||
int unreadWidth = st::dlgUnreadFont->width(text);
|
||||
int unreadRectWidth = unreadWidth + 2 * st::dlgUnreadPaddingHor;
|
||||
int unreadRectHeight = st::dlgUnreadHeight;
|
||||
accumulate_max(unreadRectWidth, unreadRectHeight);
|
||||
|
||||
int unreadRectLeft = w - st::dlgPaddingHor - unreadRectWidth;
|
||||
int unreadRectTop =top;
|
||||
if (outAvailableWidth) {
|
||||
*outAvailableWidth -= unreadRectWidth + st::dlgUnreadPaddingHor;
|
||||
int unreadRectLeft = x;
|
||||
if ((align & Qt::AlignHorizontal_Mask) & style::al_center) {
|
||||
unreadRectLeft = (x - unreadRectWidth) / 2;
|
||||
} else if ((align & Qt::AlignHorizontal_Mask) & style::al_right) {
|
||||
unreadRectLeft = x - unreadRectWidth;
|
||||
}
|
||||
int unreadRectTop = y;
|
||||
if (outUnreadWidth) {
|
||||
*outUnreadWidth = unreadRectWidth;
|
||||
}
|
||||
|
||||
paintUnreadBadge(p, QRect(unreadRectLeft, unreadRectTop, unreadRectWidth, unreadRectHeight), active, muted);
|
||||
@@ -174,8 +181,6 @@ void paintUnreadCount(Painter &p, const QString &text, int top, int w, bool acti
|
||||
p.drawText(unreadRectLeft + (unreadRectWidth - unreadWidth) / 2, unreadRectTop + st::dlgUnreadTop + st::dlgUnreadFont->ascent, text);
|
||||
}
|
||||
|
||||
} // namepsace
|
||||
|
||||
void RowPainter::paint(Painter &p, const Row *row, int w, bool active, bool selected, bool onlyBackground) {
|
||||
auto history = row->history();
|
||||
auto item = history->lastMsg;
|
||||
@@ -189,8 +194,11 @@ void RowPainter::paint(Painter &p, const Row *row, int w, bool active, bool sele
|
||||
int availableWidth = namewidth;
|
||||
int texttop = st::dlgPaddingVer + st::dlgFont->height + st::dlgSep;
|
||||
if (unread) {
|
||||
int unreadRight = w - st::dlgPaddingHor;
|
||||
int unreadTop = texttop + st::dlgHistFont->ascent - st::dlgUnreadFont->ascent - st::dlgUnreadTop;
|
||||
paintUnreadCount(p, QString::number(unread), unreadTop, w, active, history->mute(), &availableWidth);
|
||||
int unreadWidth = 0;
|
||||
paintUnreadCount(p, QString::number(unread), unreadRight, unreadTop, style::al_right, active, history->mute(), &unreadWidth);
|
||||
availableWidth -= unreadWidth + st::dlgUnreadPaddingHor;
|
||||
}
|
||||
if (history->typing.isEmpty() && history->sendActions.isEmpty()) {
|
||||
item->drawInDialog(p, QRect(nameleft, texttop, availableWidth, st::dlgFont->height), active, history->textCachedFor, history->lastItemTextCache);
|
||||
@@ -227,7 +235,8 @@ void paintImportantSwitch(Painter &p, Mode current, int w, bool selected, bool o
|
||||
|
||||
if (mutedHidden) {
|
||||
if (int32 unread = App::histories().unreadMutedCount()) {
|
||||
paintUnreadCount(p, QString::number(unread), unreadTop, w, false, true, nullptr);
|
||||
int unreadRight = w - st::dlgPaddingHor;
|
||||
paintUnreadCount(p, QString::number(unread), unreadRight, unreadTop, style::al_right, false, true, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,9 @@ public:
|
||||
|
||||
void paintImportantSwitch(Painter &p, Mode current, int w, bool selected, bool onlyBackground);
|
||||
|
||||
void paintUnreadCount(Painter &p, const QString &text, int x, int y, style::align align, bool active, bool muted, int *outUnreadWidth);
|
||||
void paintUnreadBadge(Painter &p, const QRect &rect, bool active, bool muted);
|
||||
|
||||
// This will be moved somewhere outside as soon as anyone starts using that.
|
||||
class StyleSheet {
|
||||
public:
|
||||
|
Reference in New Issue
Block a user