Browse Source

Show PM file delivery state without invoking group downloads

master
evgeny 2 days ago
parent
commit
1ceb09062f
  1. 3
      tools/chatgui/src/messagedelegate.cpp
  2. 1
      tools/chatgui/src/messagedelegate.h

3
tools/chatgui/src/messagedelegate.cpp

@ -140,6 +140,7 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
qint64 msgId = index.data(MsgIdRole).toLongLong();
QString chId = index.data(MsgChannelIdRole).toString();
if (chId.startsWith(QStringLiteral("dm:"))) return false; /* PM сохраняется через контекстное меню. */
if (dlState == 2) { /* downloaded: open file */
QString fp = index.data(MsgVoiceFileRole).toString();
if (!fp.isEmpty() && QFile::exists(fp)) {
@ -1273,6 +1274,8 @@ void MessageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
qint64 fsz = index.data(MsgFileSizeRole).toLongLong();
QString sizeStr = formatFileSize(fsz);
QString stateStr = (dlState == 2) ? QString::fromUtf8("\xE2\x9C\x85") : (dlState == 1) ? "Downloading..." : "Download";
QString deliveryState = index.data(MsgDeliveryStateRole).toString();
if (!deliveryState.isEmpty()) stateStr = deliveryState;
QString info = sizeStr + " \xC2\xB7 " + stateStr;
int nameH = QFontMetrics(fileFont).height();
QRect sizeRect(L.textRect.left(), L.textRect.top() + nameH, L.textRect.width(), QFontMetrics(sizeFont).height());

1
tools/chatgui/src/messagedelegate.h

@ -39,6 +39,7 @@ enum MessageDataRole {
MsgVideoWidthRole = Qt::UserRole + 33,
MsgVideoHeightRole = Qt::UserRole + 34,
MsgVideoDurationMsRole = Qt::UserRole + 35,
MsgDeliveryStateRole = Qt::UserRole + 36,
};
class MessageDelegate : public QStyledItemDelegate {

Loading…
Cancel
Save