TextEditor: skip update link on mouse press events

The link is updated on the release anyway. Reset the press state of
the link now after a mouse move event.

Fixes: QTCREATORBUG-21848
Change-Id: Ice7a9873b1635a1b59ba7b8f2a266bf14e28c112
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2019-01-21 14:12:16 +01:00
parent 1492284241
commit 11eea3aae0

View File

@@ -553,7 +553,7 @@ public:
QTextBlock foldedBlockAt(const QPoint &pos, QRect *box = nullptr) const;
void requestUpdateLink(QMouseEvent *e, bool immediate = false);
void requestUpdateLink(QMouseEvent *e);
void updateLink();
void showLink(const Utils::Link &);
void clearLink();
@@ -5414,6 +5414,7 @@ void TextEditorWidgetPrivate::clearVisibleFoldedBlock()
void TextEditorWidget::mouseMoveEvent(QMouseEvent *e)
{
d->requestUpdateLink(e);
d->m_linkPressed = false;
if (e->buttons() == Qt::NoButton) {
const QTextBlock collapsedBlock = d->foldedBlockAt(e->pos());
@@ -5527,9 +5528,6 @@ void TextEditorWidget::mousePressEvent(QMouseEvent *e)
if (refactorMarker.callback)
refactorMarker.callback(this);
} else {
d->requestUpdateLink(e, true);
if (d->m_currentLink.hasValidLinkText())
d->m_linkPressed = true;
}
}
@@ -6144,7 +6142,7 @@ bool TextEditorWidget::openLink(const Utils::Link &link, bool inNextSplit)
Id(), flags);
}
void TextEditorWidgetPrivate::requestUpdateLink(QMouseEvent *e, bool immediate)
void TextEditorWidgetPrivate::requestUpdateLink(QMouseEvent *e)
{
if (!q->mouseNavigationEnabled())
return;
@@ -6167,12 +6165,7 @@ void TextEditorWidgetPrivate::requestUpdateLink(QMouseEvent *e, bool immediate)
if (onText) {
m_pendingLinkUpdate = cursor;
if (immediate)
updateLink();
else
QTimer::singleShot(0, this, &TextEditorWidgetPrivate::updateLink);
return;
}
}
@@ -6214,7 +6207,6 @@ void TextEditorWidgetPrivate::showLink(const Utils::Link &link)
q->setExtraSelections(TextEditorWidget::OtherSelection, QList<QTextEdit::ExtraSelection>() << sel);
q->viewport()->setCursor(Qt::PointingHandCursor);
m_currentLink = link;
m_linkPressed = false;
}
void TextEditorWidgetPrivate::clearLink()
@@ -6227,7 +6219,6 @@ void TextEditorWidgetPrivate::clearLink()
q->setExtraSelections(TextEditorWidget::OtherSelection, QList<QTextEdit::ExtraSelection>());
q->viewport()->setCursor(Qt::IBeamCursor);
m_currentLink = Utils::Link();
m_linkPressed = false;
}
void TextEditorWidgetPrivate::highlightSearchResultsSlot(const QString &txt, FindFlags findFlags)