diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp index 13544424bd8..1e94d55aef2 100644 --- a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp +++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp @@ -31,7 +31,9 @@ #include "clangdiagnosticfilter.h" #include "clangdiagnosticmanager.h" +#include #include +#include #include #include @@ -53,7 +55,7 @@ QTextEdit::ExtraSelection createExtraSelections(const QTextCharFormat &mainforma void addRangeSelections(const ClangBackEnd::DiagnosticContainer &diagnostic, QTextDocument *textDocument, - const QTextCharFormat &rangeFormat, + const QTextCharFormat &contextFormat, const QString &diagnosticText, QList &extraSelections) { @@ -62,7 +64,7 @@ void addRangeSelections(const ClangBackEnd::DiagnosticContainer &diagnostic, cursor.setPosition(int(range.start().offset())); cursor.setPosition(int(range.end().offset()), QTextCursor::KeepAnchor); - auto extraSelection = createExtraSelections(rangeFormat, cursor, diagnosticText); + auto extraSelection = createExtraSelections(contextFormat, cursor, diagnosticText); extraSelections.push_back(std::move(extraSelection)); } @@ -116,7 +118,7 @@ QString diagnosticText(const ClangBackEnd::DiagnosticContainer &diagnostic) void addSelections(const QVector &diagnostics, QTextDocument *textDocument, const QTextCharFormat &mainFormat, - const QTextCharFormat &rangeFormat, + const QTextCharFormat &contextFormat, QList &extraSelections) { for (auto &&diagnostic : diagnostics) { @@ -125,7 +127,7 @@ void addSelections(const QVector &diagnostics auto text = diagnosticText(diagnostic); auto extraSelection = createExtraSelections(mainFormat, cursor, text); - addRangeSelections(diagnostic, textDocument, rangeFormat, text, extraSelections); + addRangeSelections(diagnostic, textDocument, contextFormat, text, extraSelections); extraSelections.push_back(std::move(extraSelection)); } @@ -135,30 +137,25 @@ void addWarningSelections(const QVector &diag QTextDocument *textDocument, QList &extraSelections) { - QTextCharFormat warningFormat; - warningFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); - warningFormat.setUnderlineColor(QColor(180, 180, 0, 255)); + const auto fontSettings = TextEditor::TextEditorSettings::instance()->fontSettings(); - QTextCharFormat warningRangeFormat; - warningRangeFormat.setUnderlineStyle(QTextCharFormat::DotLine); - warningRangeFormat.setUnderlineColor(QColor(180, 180, 0, 255)); + QTextCharFormat warningFormat = fontSettings.toTextCharFormat(TextEditor::C_WARNING); - addSelections(diagnostics, textDocument, warningFormat, warningRangeFormat, extraSelections); + QTextCharFormat warningContextFormat = fontSettings.toTextCharFormat(TextEditor::C_WARNING_CONTEXT); + + addSelections(diagnostics, textDocument, warningFormat, warningContextFormat, extraSelections); } void addErrorSelections(const QVector &diagnostics, QTextDocument *textDocument, QList &extraSelections) { - QTextCharFormat errorFormat; - errorFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); - errorFormat.setUnderlineColor(QColor(255, 0, 0, 255)); + const auto fontSettings = TextEditor::TextEditorSettings::instance()->fontSettings(); - QTextCharFormat errorRangeFormat; - errorRangeFormat.setUnderlineStyle(QTextCharFormat::DotLine); - errorRangeFormat.setUnderlineColor(QColor(255, 0, 0, 255)); + QTextCharFormat errorFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR); + QTextCharFormat errorContextFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR_CONTEXT); - addSelections(diagnostics, textDocument, errorFormat, errorRangeFormat, extraSelections); + addSelections(diagnostics, textDocument, errorFormat, errorContextFormat, extraSelections); } } // anonymous