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