Activate desktop invite links on clicks while preserving drag selection

This commit is contained in:
evgeny committed 2026-10-04 14:56:11 +02:00
1 parent 56fe1cab95
commit b7821121c3
3 files changed
+16

No files matched your search

+13
View File
@@ -180,6 +180,19 @@ void ChatView::mouseMoveEvent(QMouseEvent *event) {
}
void ChatView::mouseReleaseEvent(QMouseEvent *event) {
const QModelIndex pressed(m_pressIndex);
if (event->button() == Qt::LeftButton && !m_selecting && pressed.isValid() &&
(event->pos() - m_pressPos).manhattanLength() < 5 && indexAt(event->pos()) == pressed) {
auto* delegate = qobject_cast<MessageDelegate*>(itemDelegate(pressed));
QStyleOptionViewItem option; option.initFrom(this); option.widget = this; option.rect = visualRect(pressed);
const QString link = delegate ? delegate->inviteLinkAt(option, pressed, event->pos()) : QString();
if (!link.isEmpty()) {
m_pressIndex = QPersistentModelIndex();
GUI_INFO("invite link: activated row=%d bytes=%d", pressed.row(), link.size());
emit inviteLinkActivated(link);
event->accept(); return;
}
}
if (event->button() == Qt::LeftButton && m_selecting) {
m_selecting = false;
viewport()->update();