aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/basehoverhandler.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2019-11-04 17:14:25 +0100
committerEike Ziller <eike.ziller@qt.io>2019-11-06 14:36:41 +0000
commit8e4fb0553291ec64e5b2868fed161b574cb53ae2 (patch)
treed0edbec40e5fe949fc7eb52d2c2f669091e142d9 /src/plugins/texteditor/basehoverhandler.cpp
parent177f14b11514075b19f236f02b1b3fcc3fb49fef (diff)
TextEditor: Allow explicitly passing the text format for tool tips
Change-Id: I6e592a73fa6a3229cda9e76a4ab33f2c0ca330c5 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/texteditor/basehoverhandler.cpp')
-rw-r--r--src/plugins/texteditor/basehoverhandler.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/texteditor/basehoverhandler.cpp b/src/plugins/texteditor/basehoverhandler.cpp
index 52f1990d116..8d7fcad5173 100644
--- a/src/plugins/texteditor/basehoverhandler.cpp
+++ b/src/plugins/texteditor/basehoverhandler.cpp
@@ -89,9 +89,10 @@ void BaseHoverHandler::contextHelpId(TextEditorWidget *widget,
m_isContextHelpRequest = false;
}
-void BaseHoverHandler::setToolTip(const QString &tooltip)
+void BaseHoverHandler::setToolTip(const QString &tooltip, Qt::TextFormat format)
{
m_toolTip = tooltip;
+ m_textFormat = format;
}
const QString &BaseHoverHandler::toolTip() const
@@ -153,15 +154,18 @@ void BaseHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPoi
Utils::ToolTip::hide();
} else {
if (helpContents.isEmpty()) {
- Utils::ToolTip::show(point, m_toolTip, editorWidget, helpItem);
+ Utils::ToolTip::show(point, m_toolTip, m_textFormat, editorWidget, helpItem);
} else if (m_toolTip.isEmpty()) {
- Utils::ToolTip::show(point, helpContents, editorWidget, helpItem);
+ Utils::ToolTip::show(point, helpContents, Qt::RichText, editorWidget, helpItem);
} else {
// separate labels for tool tip text and help,
// so the text format (plain, rich, markdown) can be handled differently
auto layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
- layout->addWidget(new QLabel(m_toolTip));
+ auto label = new QLabel;
+ label->setTextFormat(m_textFormat);
+ label->setText(m_toolTip);
+ layout->addWidget(label);
layout->addWidget(new QLabel("<hr/>" + helpContents));
Utils::ToolTip::show(point, layout, editorWidget, helpItem);
}