diff options
author | Marco Bubke <marco.bubke@theqtcompany.com> | 2015-12-09 12:24:53 +0100 |
---|---|---|
committer | Marco Bubke <marco.bubke@theqtcompany.com> | 2015-12-09 11:31:02 +0000 |
commit | 6e5f90917f4cbe092816ac82434f827f67082f4d (patch) | |
tree | f818911b5f2a90ce67925d4dd95735cae2990a48 | |
parent | 4453ed4fc2ce5a0a662f8b6172562c16a1ca5eed (diff) |
Use text settings instead of hard coded diagnostic text formats
Change-Id: Id51d03a46b4403d9224508ff3c7647b829ee69cd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
-rw-r--r-- | src/plugins/cpptools/baseeditordocumentprocessor.cpp | 16 | ||||
-rw-r--r-- | src/plugins/debugger/qml/qmlengineutils.cpp | 8 | ||||
-rw-r--r-- | src/plugins/glsleditor/glsleditor.cpp | 10 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditor.cpp | 8 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljssemantichighlighter.cpp | 24 |
5 files changed, 35 insertions, 31 deletions
diff --git a/src/plugins/cpptools/baseeditordocumentprocessor.cpp b/src/plugins/cpptools/baseeditordocumentprocessor.cpp index 43f5fb9029..33e9887756 100644 --- a/src/plugins/cpptools/baseeditordocumentprocessor.cpp +++ b/src/plugins/cpptools/baseeditordocumentprocessor.cpp @@ -34,6 +34,9 @@ #include "cpptoolsreuse.h" #include "editordocumenthandle.h" +#include <texteditor/fontsettings.h> +#include <texteditor/texteditorsettings.h> + #include <utils/qtcassert.h> #include <QTextBlock> @@ -82,15 +85,10 @@ QList<QTextEdit::ExtraSelection> BaseEditorDocumentProcessor::toTextEditorSelect const QList<CPlusPlus::Document::DiagnosticMessage> &diagnostics, QTextDocument *textDocument) { - // Format for errors - QTextCharFormat errorFormat; - errorFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); - errorFormat.setUnderlineColor(Qt::red); - - // Format for warnings - QTextCharFormat warningFormat; - warningFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); - warningFormat.setUnderlineColor(Qt::darkYellow); + const TextEditor::FontSettings &fontSettings = TextEditor::TextEditorSettings::instance()->fontSettings(); + + QTextCharFormat warningFormat = fontSettings.toTextCharFormat(TextEditor::C_WARNING); + QTextCharFormat errorFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR); QList<QTextEdit::ExtraSelection> result; foreach (const CPlusPlus::Document::DiagnosticMessage &m, diagnostics) { diff --git a/src/plugins/debugger/qml/qmlengineutils.cpp b/src/plugins/debugger/qml/qmlengineutils.cpp index 50f707d005..684d7b69b2 100644 --- a/src/plugins/debugger/qml/qmlengineutils.cpp +++ b/src/plugins/debugger/qml/qmlengineutils.cpp @@ -36,8 +36,10 @@ #include <coreplugin/editormanager/documentmodel.h> +#include <texteditor/fontsettings.h> #include <texteditor/textdocument.h> #include <texteditor/texteditor.h> +#include <texteditor/texteditorsettings.h> #include <QTextBlock> @@ -248,10 +250,8 @@ QStringList highlightExceptionCode(int lineNumber, const QString &filePath, cons QStringList messages; QList<IEditor *> editors = DocumentModel::editorsForFilePath(filePath); - // set up the format for the errors - QTextCharFormat errorFormat; - errorFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); - errorFormat.setUnderlineColor(Qt::red); + const TextEditor::FontSettings &fontSettings = TextEditor::TextEditorSettings::instance()->fontSettings(); + QTextCharFormat errorFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR); foreach (IEditor *editor, editors) { TextEditorWidget *ed = qobject_cast<TextEditorWidget *>(editor->widget()); diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp index b7fac825e0..3a35ccadf7 100644 --- a/src/plugins/glsleditor/glsleditor.cpp +++ b/src/plugins/glsleditor/glsleditor.cpp @@ -53,6 +53,7 @@ #include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginspec.h> +#include <texteditor/fontsettings.h> #include <texteditor/refactoroverlay.h> #include <texteditor/textdocument.h> #include <texteditor/syntaxhighlighter.h> @@ -236,13 +237,10 @@ void GlslEditorWidget::updateDocumentNow() CreateRanges createRanges(document(), doc); createRanges(ast); - QTextCharFormat errorFormat; - errorFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); - errorFormat.setUnderlineColor(Qt::red); + const TextEditor::FontSettings &fontSettings = TextEditor::TextEditorSettings::instance()->fontSettings(); - QTextCharFormat warningFormat; - warningFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); - warningFormat.setUnderlineColor(Qt::darkYellow); + QTextCharFormat warningFormat = fontSettings.toTextCharFormat(TextEditor::C_WARNING); + QTextCharFormat errorFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR); QList<QTextEdit::ExtraSelection> sels; QSet<int> errors; diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index df7f849cb9..d377095f8e 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -66,6 +66,7 @@ #include <texteditor/fontsettings.h> #include <texteditor/tabsettings.h> #include <texteditor/texteditorconstants.h> +#include <texteditor/texteditorsettings.h> #include <texteditor/syntaxhighlighter.h> #include <texteditor/refactoroverlay.h> #include <texteditor/codeassist/genericproposal.h> @@ -194,12 +195,13 @@ static void appendExtraSelectionsForMessages( sel.cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, d.loc.length); } + const auto fontSettings = TextEditor::TextEditorSettings::instance()->fontSettings(); + if (d.isWarning()) - sel.format.setUnderlineColor(Qt::darkYellow); + sel.format = fontSettings.toTextCharFormat(TextEditor::C_WARNING); else - sel.format.setUnderlineColor(Qt::red); + sel.format = fontSettings.toTextCharFormat(TextEditor::C_ERROR); - sel.format.setUnderlineStyle(QTextCharFormat::SingleUnderline); sel.format.setToolTip(d.message); selections->append(sel); diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp index fb5900548e..1ba2e6a8ca 100644 --- a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp +++ b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp @@ -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; } + + const TextEditor::FontSettings &fontSettings = TextEditor::TextEditorSettings::instance()->fontSettings(); + 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) + 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.setUnderlineStyle(QTextCharFormat::SingleUnderline); format.setToolTip(d.message); collectRanges(begin, length, format); |