|
|
|
|
@ -131,14 +131,21 @@ static void ensureVoiceTimer() {
|
|
|
|
|
bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, |
|
|
|
|
const QStyleOptionViewItem &option, |
|
|
|
|
const QModelIndex &index) { |
|
|
|
|
if (event->type() != QEvent::MouseButtonRelease) return false; |
|
|
|
|
if (event->type() != QEvent::MouseButtonPress && event->type() != QEvent::MouseButtonRelease) return false; |
|
|
|
|
Layout L = calcLayout(option, index); |
|
|
|
|
|
|
|
|
|
const auto* mouse = static_cast<QMouseEvent*>(event); |
|
|
|
|
if (mouse->button() == Qt::LeftButton && !L.narrow && L.avatarRect.contains(mouse->pos() - option.rect.topLeft())) { |
|
|
|
|
const bool onAvatar=mouse->button()==Qt::LeftButton && !L.narrow && L.avatarRect.contains(mouse->pos()-option.rect.topLeft()); |
|
|
|
|
if (event->type()==QEvent::MouseButtonPress) { |
|
|
|
|
m_avatarPress=onAvatar ? index : QModelIndex(); m_avatarPressPosition=mouse->pos(); return onAvatar; |
|
|
|
|
} |
|
|
|
|
const bool activateAvatar=onAvatar && m_avatarPress==index && (mouse->pos()-m_avatarPressPosition).manhattanLength()<5; |
|
|
|
|
m_avatarPress=QPersistentModelIndex(); |
|
|
|
|
if (activateAvatar) { |
|
|
|
|
emit avatarRequested(index.data(MsgChannelIdRole).toString(), index.data(MsgAuthorNodeIdRole).toULongLong()); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (onAvatar) return true; |
|
|
|
|
|
|
|
|
|
if (L.isVideo) { |
|
|
|
|
int dlState = index.data(MsgFileDownloadStateRole).toInt(); |
|
|
|
|
|