Keep member avatar drags separate from viewer clicks

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

No files matched your search

+8 -2
View File
@@ -96,8 +96,14 @@ bool AccountDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, cons
event->type() != QEvent::MouseButtonDblClick) return false;
auto* mouse = static_cast<QMouseEvent*>(event);
if (mouse->button() != Qt::LeftButton) return false;
if (QRect(option.rect.left()+4, option.rect.center().y()-12, 24,24).contains(mouse->pos())) {
if (event->type()==QEvent::MouseButtonRelease) emit avatarRequested(index);
const bool onAvatar=QRect(option.rect.left()+4,option.rect.center().y()-12,24,24).contains(mouse->pos());
if (event->type()==QEvent::MouseButtonPress) {
m_avatarPress=onAvatar ? index : QModelIndex(); m_avatarPosition=mouse->pos();
}
if (onAvatar) {
if (event->type()==QEvent::MouseButtonRelease && m_avatarPress==index && (mouse->pos()-m_avatarPosition).manhattanLength()<5)
emit avatarRequested(index);
if (event->type()==QEvent::MouseButtonRelease) m_avatarPress=QPersistentModelIndex();
return true;
}
if (index.data(Qt::UserRole + 2).toBool()) return false;
+2
View File
@@ -20,4 +20,6 @@ signals:
void avatarRequested(const QModelIndex& index);
private:
QPersistentModelIndex m_invitePress;
QPersistentModelIndex m_avatarPress;
QPoint m_avatarPosition;
};