Browse Source

Show PM voice and video delivery status in both shared renderers

master
evgeny 1 week ago
parent
commit
20322e7ecb
  1. 3
      tools/chatgui-android/app/src/main/java/com/utun/chat/ui/components/MessageBubble.kt
  2. 20
      tools/chatgui/src/messagedelegate.cpp
  3. 1
      tools/chatgui/src/messagedelegate.h

3
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/")

20
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();

1
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;

Loading…
Cancel
Save