forked from qt-creator/qt-creator
GlslEditor: Display tool tips for errors and warnings
Change-Id: Id5f6e555599e479a83cc565966653b9e44b85772 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -56,8 +56,10 @@
|
|||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/changeset.h>
|
#include <utils/changeset.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/tooltip/tooltip.h>
|
||||||
#include <utils/uncommentselection.h>
|
#include <utils/uncommentselection.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@@ -168,6 +170,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void updateDocumentNow();
|
void updateDocumentNow();
|
||||||
void setSelectedElements();
|
void setSelectedElements();
|
||||||
|
void onTooltipRequested(const QPoint &point, int pos);
|
||||||
QString wordUnderCursor() const;
|
QString wordUnderCursor() const;
|
||||||
|
|
||||||
QTimer m_updateDocumentTimer;
|
QTimer m_updateDocumentTimer;
|
||||||
@@ -207,6 +210,8 @@ GlslEditorWidget::GlslEditorWidget()
|
|||||||
m_outlineCombo->setSizePolicy(policy);
|
m_outlineCombo->setSizePolicy(policy);
|
||||||
|
|
||||||
insertExtraToolBarWidget(TextEditorWidget::Left, m_outlineCombo);
|
insertExtraToolBarWidget(TextEditorWidget::Left, m_outlineCombo);
|
||||||
|
|
||||||
|
connect(this, &TextEditorWidget::tooltipRequested, this, &GlslEditorWidget::onTooltipRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GlslEditorWidget::editorRevision() const
|
int GlslEditorWidget::editorRevision() const
|
||||||
@@ -303,6 +308,26 @@ void GlslEditorWidget::updateDocumentNow()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GlslEditorWidget::onTooltipRequested(const QPoint &point, int pos)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_glslDocument && m_glslDocument->engine(), return);
|
||||||
|
const int lineno = document()->findBlock(pos).blockNumber() + 1;
|
||||||
|
const QStringList messages
|
||||||
|
= Utils::transform<QStringList>(
|
||||||
|
Utils::filtered(m_glslDocument->engine()->diagnosticMessages(),
|
||||||
|
[lineno](const DiagnosticMessage &msg) {
|
||||||
|
return msg.line() == lineno;
|
||||||
|
}),
|
||||||
|
[](const DiagnosticMessage &msg) {
|
||||||
|
return msg.message();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!messages.isEmpty())
|
||||||
|
Utils::ToolTip::show(point, messages.join("<hr/>"), this);
|
||||||
|
else
|
||||||
|
Utils::ToolTip::hide();
|
||||||
|
}
|
||||||
|
|
||||||
int languageVariant(const QString &type)
|
int languageVariant(const QString &type)
|
||||||
{
|
{
|
||||||
int variant = 0;
|
int variant = 0;
|
||||||
|
Reference in New Issue
Block a user