Commit 0dff03e6 authored by Ulf Hermann's avatar Ulf Hermann

TextEditor: Implement BaseHoverHandler::identifyMatch()

The extra selection tooltips are a good default for a hover match. We
use that in the basic plaintext editor to show, for example, syntax
errors in XML documents, detected during extra compiler runs.

Change-Id: Ib7f755c482ebc04148567105e4779324799fb670
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 654aa3a0
......@@ -143,6 +143,13 @@ void BaseHoverHandler::process(TextEditorWidget *widget, int pos)
decorateToolTip();
}
void BaseHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos)
{
QString tooltip = editorWidget->extraSelectionTooltip(pos);
if (!tooltip.isEmpty())
setToolTip(tooltip);
}
void BaseHoverHandler::decorateToolTip()
{
if (Qt::mightBeRichText(toolTip()))
......
......@@ -77,7 +77,7 @@ private:
void clear();
void process(TextEditorWidget *widget, int pos);
virtual void identifyMatch(TextEditorWidget *editorWidget, int pos) = 0;
virtual void identifyMatch(TextEditorWidget *editorWidget, int pos);
bool m_diagnosticTooltip;
QString m_toolTip;
......
......@@ -31,6 +31,7 @@
#include "texteditorconstants.h"
#include "texteditorplugin.h"
#include "texteditorsettings.h"
#include "basehoverhandler.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/infobar.h>
......@@ -60,6 +61,7 @@ PlainTextEditorFactory::PlainTextEditorFactory()
setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
addMimeType(QLatin1String("text/css")); // for some reason freedesktop thinks css is text/x-csrc
addHoverHandler(new BaseHoverHandler);
setDocumentCreator([]() { return new TextDocument(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); });
setEditorWidgetCreator([]() { return new PlainTextEditorWidget; });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment