Open desktop message avatars only after a completed click

This commit is contained in:
evgeny committed 2026-10-06 20:01:38 +02:00
1 parent 7d69404532
commit 1f9dbd9dea
2 files changed
+12 -2

No files matched your search

+9 -2
View File
@@ -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();
+3
View File
@@ -4,6 +4,7 @@
#include <cstdint>
#include <QStyledItemDelegate>
#include <QPersistentModelIndex>
#include <functional>
enum MessageDataRole {
@@ -111,6 +112,8 @@ private:
std::function<void(const QString&)> m_videoOpenCb;
std::function<void(const QString&)> m_imageOpenCb;
QPersistentModelIndex m_avatarPress;
QPoint m_avatarPressPosition;
std::function<bool(const QModelIndex&)> m_downloadCb;
Layout calcLayout(const QStyleOptionViewItem &option,