Use text settings instead of hard coded diagnostic text formats

Change-Id: Id51d03a46b4403d9224508ff3c7647b829ee69cd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Marco Bubke
2015-12-09 12:24:53 +01:00
parent 4453ed4fc2
commit 6e5f90917f
5 changed files with 38 additions and 34 deletions

View File

@@ -45,6 +45,7 @@
#include <texteditor/syntaxhighlighter.h>
#include <texteditor/textdocument.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h>
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
@@ -385,13 +386,14 @@ protected:
length = end-begin;
}
const TextEditor::FontSettings &fontSettings = TextEditor::TextEditorSettings::instance()->fontSettings();
QTextCharFormat format;
if (d.isWarning())
format.setUnderlineColor(Qt::darkYellow);
format = fontSettings.toTextCharFormat(TextEditor::C_WARNING);
else
format.setUnderlineColor(Qt::red);
format = fontSettings.toTextCharFormat(TextEditor::C_ERROR);
format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
format.setToolTip(d.message);
collectRanges(begin, length, format);
@@ -420,15 +422,19 @@ protected:
column += begin - d.location.begin();
length = end-begin;
}
QTextCharFormat format;
if (d.severity == Severity::Warning || d.severity == Severity::MaybeWarning)
format.setUnderlineColor(Qt::darkYellow);
else if (d.severity == Severity::Error || d.severity == Severity::MaybeError)
format.setUnderlineColor(Qt::red);
else if (d.severity == Severity::Hint)
format.setUnderlineColor(Qt::darkGreen);
format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
const TextEditor::FontSettings &fontSettings = TextEditor::TextEditorSettings::instance()->fontSettings();
QTextCharFormat format;
if (d.severity == Severity::Warning || d.severity == Severity::MaybeWarning) {
format = fontSettings.toTextCharFormat(TextEditor::C_WARNING);
} else if (d.severity == Severity::Error || d.severity == Severity::MaybeError) {
format = fontSettings.toTextCharFormat(TextEditor::C_ERROR);
} else if (d.severity == Severity::Hint) {
format = fontSettings.toTextCharFormat(TextEditor::C_WARNING);
format.setUnderlineColor(Qt::darkGreen);
}
format.setToolTip(d.message);
collectRanges(begin, length, format);