Browse Source

chatgui: баббл видео — размер + время m:ss (напр. 1.5MB · 0:45)

v2
evgeny 3 weeks ago
parent
commit
f2b34459c3
  1. 11
      tools/chatgui/src/messagedelegate.cpp
  2. 3
      tools/chatgui/src/messagelist.cpp

11
tools/chatgui/src/messagedelegate.cpp

@ -395,7 +395,7 @@ MessageDelegate::Layout MessageDelegate::calcLayout(
if (dlState == 1) { L.progressBarRect = QRect(bx, thH - 3, thW, 3); }
L.videoPlayBtnRect = QRect(bx + thW / 2 - 24, thH / 2 - 24, 48, 48);
L.videoDurBadgeRect = QRect(bx + thW - 56, thH - 26, 48, 18);
L.videoDurBadgeRect = QRect(bx + thW - 116, thH - 26, 108, 18);
if (!L.narrow) {
int avatarY = L.bubbleRect.bottom() - kAvatar;
@ -1010,9 +1010,12 @@ void MessageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
painter->drawPath(tri);
}
/* duration-бейдж */
/* бейдж: размер · длительность (m:ss) */
qint64 fsz = index.data(MsgFileSizeRole).toLongLong();
QString sizeStr = formatFileSize(fsz);
QString durStr = index.data(MsgVoiceDurationRole).toString();
if (!durStr.isEmpty()) {
QString badge = durStr.isEmpty() ? sizeStr : sizeStr + " \xC2\xB7 " + durStr;
if (!badge.isEmpty()) {
QFont durFont = option.font;
durFont.setPointSize(durFont.pointSize() - 1);
painter->setFont(durFont);
@ -1020,7 +1023,7 @@ void MessageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
painter->setBrush(QColor(0, 0, 0, 160));
painter->drawRoundedRect(L.videoDurBadgeRect, 5, 5);
painter->setPen(Qt::white);
painter->drawText(L.videoDurBadgeRect, Qt::AlignCenter, durStr);
painter->drawText(L.videoDurBadgeRect, Qt::AlignCenter, badge);
}
painter->restore();

3
tools/chatgui/src/messagelist.cpp

@ -216,7 +216,8 @@ static void setVoiceMessageRoles(QStandardItem* item, const QByteArray& data,
if (p.startsWith("dur=")) {
qint64 durMs = p.mid(4).toLongLong();
if (durMs > 0) {
QString d = QString::number(durMs / 1000.0, 'f', 0) + "s";
qint64 s = durMs / 1000;
QString d = QString("%1:%2").arg(s / 60).arg(s % 60, 2, 10, QChar('0'));
item->setData(d, MsgVoiceDurationRole);
}
}

Loading…
Cancel
Save