Open desktop chat polls with a single left click

This commit is contained in:
evgeny committed 2026-10-07 17:11:43 +02:00
1 parent 7e88d15e1d
commit ddcc36aa26
3 files changed
+26 -1

No files matched your search

+22 -1
View File
@@ -143,10 +143,19 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
for (const auto& chip : L.reactionChips) if (chip.rect.contains(point)) { reaction = chip.id; break; }
const bool onReaction = mouse->button() == Qt::LeftButton && reaction != -2;
const bool onAvatar=mouse->button()==Qt::LeftButton && !L.narrow && L.avatarRect.contains(mouse->pos()-option.rect.topLeft());
const bool onPoll = index.data(MsgContentTypeRole).toString() == "poll"
&& !index.data(MsgChannelIdRole).toString().startsWith("dm:") && L.bubbleRect.contains(point)
&& (!L.reactionHeart.isValid() || point.y() < L.reactionHeart.top());
if (event->type()==QEvent::MouseButtonPress) {
m_reactionPress = onReaction ? index : QModelIndex(); m_pressedReaction = reaction; m_reactionPressPosition = mouse->pos();
m_avatarPress=onAvatar ? index : QModelIndex(); m_avatarPressPosition=mouse->pos(); return onAvatar || onReaction;
m_avatarPress=onAvatar ? index : QModelIndex(); m_avatarPressPosition=mouse->pos();
m_pollPress = onPoll ? index : QModelIndex(); m_pollPressPosition = mouse->pos();
return onAvatar || onReaction || onPoll;
}
const auto* view = qobject_cast<const ChatView*>(option.widget);
const bool activatePoll = onPoll && m_pollPress == index && (mouse->pos() - m_pollPressPosition).manhattanLength() < 5
&& (!view || !view->textSelection().active);
m_pollPress = QPersistentModelIndex();
const bool hadReactionPress = m_reactionPress.isValid();
const bool activateAvatar=onAvatar && m_avatarPress==index && (mouse->pos()-m_avatarPressPosition).manhattanLength()<5;
m_avatarPress=QPersistentModelIndex();
@@ -162,6 +171,18 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
if (onAvatar) return true;
if (L.reactionHeart.isValid() && point.y() >= L.reactionHeart.top()) return true;
if (onPoll) {
if (!activatePoll) return true;
const QString messageId = index.data(MsgMessageKeyRole).toString();
if (messageId.size() != 64) {
GUI_WARN("poll: cannot open message with invalid key row=%d key_bytes=%d", index.row(), int(messageId.size()));
return true;
}
GUI_INFO("poll: left click ch=%s message=%s", qPrintable(index.data(MsgChannelIdRole).toString()), qPrintable(messageId));
emit pollRequested(messageId);
return true;
}
if (L.isVideo) {
int dlState = index.data(MsgFileDownloadStateRole).toInt();