From 11eea3aae0e936ecbb1081ab4f2201cc6e69fea0 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 21 Jan 2019 14:12:16 +0100 Subject: [PATCH] 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 --- src/plugins/texteditor/texteditor.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index a194b524e03..31c11aef8b1 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -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,10 +5528,7 @@ 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; + d->m_linkPressed = true; } } } else if (e->button() == Qt::RightButton) { @@ -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); - + QTimer::singleShot(0, this, &TextEditorWidgetPrivate::updateLink); return; } } @@ -6214,7 +6207,6 @@ void TextEditorWidgetPrivate::showLink(const Utils::Link &link) q->setExtraSelections(TextEditorWidget::OtherSelection, QList() << 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()); q->viewport()->setCursor(Qt::IBeamCursor); m_currentLink = Utils::Link(); - m_linkPressed = false; } void TextEditorWidgetPrivate::highlightSearchResultsSlot(const QString &txt, FindFlags findFlags)