Keep message footer layout and click gesture states consistent
This commit is contained in:
1 parent
f71e5531e0
commit
fc79fa7345
3 files changed
+76
-75
No files matched your search
@@ -137,6 +137,7 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||
Layout L = calcLayout(option, index);
|
||||
|
||||
const auto* mouse = static_cast<QMouseEvent*>(event);
|
||||
if (mouse->button() != Qt::LeftButton) return false;
|
||||
const QPoint point = mouse->pos() - option.rect.topLeft();
|
||||
int reaction = L.reactionHeart.contains(point) ? -1 : -2;
|
||||
for (const auto& chip : L.reactionChips) if (chip.rect.contains(point)) { reaction = chip.id; break; }
|
||||
@@ -147,13 +148,13 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||
m_avatarPress=onAvatar ? index : QModelIndex(); m_avatarPressPosition=mouse->pos(); return onAvatar || onReaction;
|
||||
}
|
||||
const bool hadReactionPress = m_reactionPress.isValid();
|
||||
const bool activateAvatar=onAvatar && m_avatarPress==index && (mouse->pos()-m_avatarPressPosition).manhattanLength()<5;
|
||||
m_avatarPress=QPersistentModelIndex();
|
||||
const bool activateReaction = onReaction && m_reactionPress == index && m_pressedReaction == reaction
|
||||
&& (mouse->pos() - m_reactionPressPosition).manhattanLength() < 5;
|
||||
m_reactionPress = QPersistentModelIndex(); m_pressedReaction = -2;
|
||||
if (activateReaction) { emit reactionRequested(index, reaction); return true; }
|
||||
if (hadReactionPress || onReaction || (L.reactionHeart.isValid() && point.y() >= L.reactionHeart.top())) return true;
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user