Skip to content

Commit

Permalink
liteeditor: fix show link toolip bug on Qt5.12
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Oct 5, 2020
1 parent b49fbe7 commit cb45a0d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
38 changes: 28 additions & 10 deletions liteidex/src/plugins/liteeditor/liteeditorwidgetbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ void LiteEditorWidgetBase::navigateAreaMouseEvent(QMouseEvent *e)
if (isInNavigateHead(e->pos())) {
tooltip = true;
QPoint pos(1,1);
QToolTip::showText(m_navigateArea->mapToGlobal(pos),this->m_navigateManager->m_msg,this->m_navigateArea);
showTipText(m_navigateArea->mapToGlobal(pos),this->m_navigateManager->m_msg,this->m_navigateArea);
} else {
int offset = 0;
NavigateMark *mark = findNavigateMarkByPos(e->pos(),&offset,0);
Expand All @@ -1187,12 +1187,12 @@ void LiteEditorWidgetBase::navigateAreaMouseEvent(QMouseEvent *e)
if (node) {
tooltip = true;
QPoint pos(1,offset);
QToolTip::showText(m_navigateArea->mapToGlobal(pos),node->msg,this->m_navigateArea);
showTipText(m_navigateArea->mapToGlobal(pos),node->msg,this->m_navigateArea);
}
}
}
if (!tooltip) {
QToolTip::hideText();
hideTipText();
}
}
}
Expand Down Expand Up @@ -2404,7 +2404,7 @@ void LiteEditorWidgetBase::keyPressEvent(QKeyEvent *e)
QPlainTextEdit::keyPressEvent(e);
return;
}
QToolTip::hideText();
hideTipText();
this->m_moveLineUndoHack = false;
bool ro = isReadOnly();

Expand Down Expand Up @@ -2947,9 +2947,27 @@ static QString simpleInfo(const QString &info, int maxLine)

void LiteEditorWidgetBase::showToolTipInfo(const QPoint &pos, const QString &text)
{
QToolTip::showText(pos,simpleInfo(text,m_maxTipInfoLines),this);
showTipText(pos,simpleInfo(text,m_maxTipInfoLines),this);
}

void LiteEditorWidgetBase::showTipText(const QPoint &pos, const QString &text, QWidget *widget)
{
static QString last;
static QPoint lastPos;
if (last == text && lastPos == pos) {
return;
}
last = text;
lastPos = pos;
QToolTip::showText(pos,text,widget);
}

void LiteEditorWidgetBase::hideTipText()
{
QToolTip::hideText();
}


void LiteEditorWidgetBase::cleanWhitespace(bool wholeDocument)
{
QTextCursor cursor = this->textCursor();
Expand Down Expand Up @@ -3194,7 +3212,7 @@ void LiteEditorWidgetBase::uplinkDeployTimeout()
void LiteEditorWidgetBase::uplinkInfoTimeout()
{
if (m_lastUpToolTipPos != m_upToolTipPos) {
QToolTip::hideText();
hideTipText();
return;
}
QTextCursor cursor = cursorForPosition(m_upToolTipPos);
Expand All @@ -3209,20 +3227,20 @@ void LiteEditorWidgetBase::uplinkInfoTimeout()
if (rc.contains(m_upToolTipPos)) {
findLink = true;
m_showLinkInfomation = true;
QToolTip::hideText();
hideTipText();
emit updateLink(cursor,m_upToolTipPos,false);
}
}
}
if (!findLink) {
QToolTip::hideText();
hideTipText();
}
}

void LiteEditorWidgetBase::stopUplinkTimer()
{
m_showLinkInfomation = false;
QToolTip::hideText();
hideTipText();
m_upToolTipTimer->stop();
m_upToolTipDeployTimer->stop();
}
Expand Down Expand Up @@ -3289,7 +3307,7 @@ void LiteEditorWidgetBase::clearLink()
setExtraSelections(LiteApi::LinkSelection, QList<QTextEdit::ExtraSelection>());
viewport()->setCursor(Qt::IBeamCursor);
m_currentLink = LiteApi::Link();
QToolTip::hideText();
hideTipText();
}

bool LiteEditorWidgetBase::openLink(const LiteApi::Link &link)
Expand Down
2 changes: 2 additions & 0 deletions liteidex/src/plugins/liteeditor/liteeditorwidgetbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ protected slots:
NavigateManager *m_navigateManager;
bool m_inBlockSelectionMode;
TextEditor::BaseTextBlockSelection m_blockSelection;
void showTipText(const QPoint &pos, const QString &text, QWidget *widget);
void hideTipText();
};

inline bool isIdentifierChar(const QChar &ch)
Expand Down

0 comments on commit cb45a0d

Please sign in to comment.