Show PM voice and video delivery status in both shared renderers

This commit is contained in:
evgeny committed 2026-10-01 18:49:59 +03:00
1 parent 5092bdf9fe
commit 20322e7ecb
3 files changed
+18 -6

No files matched your search

+16 -4
View File
@@ -78,8 +78,6 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
if (L.isVideo) {
int dlState = index.data(MsgFileDownloadStateRole).toInt();
qint64 msgId = index.data(MsgIdRole).toLongLong();
QString chId = index.data(MsgChannelIdRole).toString();
if (dlState == 2) { /* скачано — открыть плеер */
QString fp = index.data(MsgVoiceFileRole).toString();
@@ -96,8 +94,6 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
if (L.isImage) {
int dlState = index.data(MsgFileDownloadStateRole).toInt();
qint64 msgId = index.data(MsgIdRole).toLongLong();
QString chId = index.data(MsgChannelIdRole).toString();
if (dlState == 2) { /* скачано — открыть просмотрщик */
QString fp = index.data(MsgVoiceFileRole).toString();
@@ -364,6 +360,10 @@ MessageDelegate::Layout MessageDelegate::calcLayout(
L.voiceWaveformRect = QRect(wx, kPadTop + 1, ww, wh);
L.voiceDurationRect = QRect(wx, kPadTop + wh + 4, ww - 40, th);
L.voiceTimeRect = QRect(wx + ww - 40, kPadTop + wh + 4, 40, th);
if (!index.data(MsgDeliveryStateRole).toString().isEmpty()) {
L.deliveryRect = QRect(bx, bubbleH + 2, L.bubbleWidth, th);
L.totalHeight += th + 2;
}
if (!L.narrow) {
int avatarY = L.bubbleRect.bottom() - kAvatar;
@@ -392,6 +392,10 @@ MessageDelegate::Layout MessageDelegate::calcLayout(
L.videoThumbRect = L.bubbleRect;
L.mediaBarRect = QRect(L.isOutgoing ? bx + thW + 1 : bx - barW - 1, 0, barW, thH);
L.statusRect = QRect(bx, thH + 2, thW, infoH - 2);
if (!index.data(MsgDeliveryStateRole).toString().isEmpty()) {
L.deliveryRect = QRect(bx, thH + infoH + 2, thW, infoH - 2);
L.totalHeight += infoH;
}
int dlState = index.data(MsgFileDownloadStateRole).toInt();
int bd = index.data(MsgMediaBlocksDoneRole).toInt();
@@ -817,6 +821,14 @@ void MessageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
painter->setClipRect(QRect(QPoint(0, 0), option.rect.size()));
Layout L = calcLayout(option, index);
if (L.deliveryRect.isValid()) {
QFont font = option.font;
font.setPointSize(qMax(1, font.pointSize() - 2));
painter->setFont(font);
painter->setPen(option.palette.text().color().lighter(150));
const auto text = QFontMetrics(font).elidedText(index.data(MsgDeliveryStateRole).toString(), Qt::ElideRight, L.deliveryRect.width());
painter->drawText(L.deliveryRect, Qt::AlignRight | Qt::AlignVCenter, text);
}
if (L.emojiOnly) {
QString msgText = index.data(MsgTextRole).toString();