Keep invite hit testing in the message presenter and show link cursor
This commit is contained in:
1 parent
149c397b7b
commit
f07a5b7a83
3 files changed
+10
-3
No files matched your search
@@ -154,6 +154,8 @@ void ChatView::mouseMoveEvent(QMouseEvent *event) {
|
||||
}
|
||||
if (!m_selecting) {
|
||||
QModelIndex idx = indexAt(viewport()->mapFrom(this, event->pos()));
|
||||
const bool link = m_inviteHitTest && !m_inviteHitTest(idx, event->pos()).isEmpty();
|
||||
viewport()->setCursor(link ? Qt::PointingHandCursor : Qt::ArrowCursor);
|
||||
if (idx != QModelIndex(m_lastHovered)) {
|
||||
m_lastHovered = idx;
|
||||
const auto paths = animatedEmojiPaths(idx);
|
||||
@@ -183,9 +185,7 @@ 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();
|
||||
const QString link = m_inviteHitTest ? m_inviteHitTest(pressed, event->pos()) : QString();
|
||||
if (!link.isEmpty()) {
|
||||
m_pressIndex = QPersistentModelIndex();
|
||||
GUI_INFO("invite link: activated row=%d bytes=%d", pressed.row(), link.size());
|
||||
|
||||
Reference in new issue
Block a user