From 20322e7ecbbe63736f60201b4645e5215baf4647 Mon Sep 17 00:00:00 2001 From: evgeny Date: Thu, 1 Oct 2026 18:49:59 +0300 Subject: [PATCH] Show PM voice and video delivery status in both shared renderers --- .../utun/chat/ui/components/MessageBubble.kt | 3 +-- tools/chatgui/src/messagedelegate.cpp | 20 +++++++++++++++---- tools/chatgui/src/messagedelegate.h | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/components/MessageBubble.kt b/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/components/MessageBubble.kt index 6ed4b25a..3de3f55e 100644 --- a/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/components/MessageBubble.kt +++ b/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/components/MessageBubble.kt @@ -245,7 +245,7 @@ private fun VoiceBubble(message: Message, textColor: Color, isActive: Boolean, color = ChatColors.Secondary ) Text( - formatTime(message.ts), + listOf(formatTime(message.ts), message.deliveryStatus).filter { it.isNotEmpty() }.joinToString(" · "), fontSize = 11.sp, color = ChatColors.Secondary, modifier = Modifier.align(Alignment.CenterVertically).padding(start = 8.dp) @@ -293,7 +293,6 @@ private fun FileBubble(message: Message, textColor: Color, onDownload: (Message) } } -private val VIDEO_EXTENSIONS = setOf("mp4", "m4v", "mov", "webm", "3gp", "mkv", "avi", "ts", "mpg", "mpeg") private fun isVideoMessage(message: Message): Boolean { return message.contentType.startsWith("video/") diff --git a/tools/chatgui/src/messagedelegate.cpp b/tools/chatgui/src/messagedelegate.cpp index cc7d8307..2c60fde1 100644 --- a/tools/chatgui/src/messagedelegate.cpp +++ b/tools/chatgui/src/messagedelegate.cpp @@ -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(); diff --git a/tools/chatgui/src/messagedelegate.h b/tools/chatgui/src/messagedelegate.h index a8181e16..d758f128 100644 --- a/tools/chatgui/src/messagedelegate.h +++ b/tools/chatgui/src/messagedelegate.h @@ -75,6 +75,7 @@ private: QRect quoteTextRect; QRect textRect; QRect statusRect; + QRect deliveryRect; int totalHeight; bool narrow = false; bool emojiOnly = false;