forked from qt-creator/qt-creator
Escape tooltip text
The tooltip text may contain characters that need to be escaped without 'Qt::mightBeRichText' categorizing this as rich text. This is needed e.g. to show the proper type when hovering over a variable of type 'std::vector<int>' (or some smart pointer) in edit view (no debugging session). Otherwise, just "std::vector" is shown since 'Qt::mightBeRichText' returns false for that string and "<int>" is then probably just ignored as an invalid tag when the tooltip is displayed. Change-Id: I25ded2b21e4350a1036ab4b3d8f144383aee776d Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -142,17 +142,14 @@ void BaseHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos, Re
|
|||||||
|
|
||||||
void BaseHoverHandler::decorateToolTip()
|
void BaseHoverHandler::decorateToolTip()
|
||||||
{
|
{
|
||||||
if (Qt::mightBeRichText(toolTip()))
|
m_toolTip = m_toolTip.toHtmlEscaped();
|
||||||
setToolTip(toolTip().toHtmlEscaped());
|
|
||||||
|
|
||||||
if (lastHelpItemIdentified().isValid() && !lastHelpItemIdentified().isFuzzyMatch()) {
|
if (lastHelpItemIdentified().isValid() && !lastHelpItemIdentified().isFuzzyMatch()) {
|
||||||
const QString &helpContents = lastHelpItemIdentified().extractContent(false);
|
const QString &helpContents = lastHelpItemIdentified().extractContent(false);
|
||||||
if (!helpContents.isEmpty()) {
|
if (!helpContents.isEmpty())
|
||||||
m_toolTip = toolTip().toHtmlEscaped();
|
|
||||||
m_toolTip = m_toolTip.isEmpty() ? helpContents : ("<p>" + m_toolTip + "</p><hr/><p>" + helpContents + "</p>");
|
m_toolTip = m_toolTip.isEmpty() ? helpContents : ("<p>" + m_toolTip + "</p><hr/><p>" + helpContents + "</p>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void BaseHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPoint &point)
|
void BaseHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPoint &point)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user