Browse Source

Keep member avatar drags separate from viewer clicks

master
evgeny 5 days ago
parent
commit
3f4df4233b
  1. 10
      tools/chatgui/src/accountdelegate.cpp
  2. 2
      tools/chatgui/src/accountdelegate.h

10
tools/chatgui/src/accountdelegate.cpp

@ -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
tools/chatgui/src/accountdelegate.h

@ -20,4 +20,6 @@ signals:
void avatarRequested(const QModelIndex& index);
private:
QPersistentModelIndex m_invitePress;
QPersistentModelIndex m_avatarPress;
QPoint m_avatarPosition;
};

Loading…
Cancel
Save