forked from qt-creator/qt-creator
Coco: use the diagnostic foreground color as annotation color
Change-Id: I4f0991c8956b0b31a441aa4348aaf8b7d0677dda Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -138,7 +138,21 @@ public:
|
||||
{
|
||||
setLineAnnotation(diag.message());
|
||||
setToolTip(diag.message());
|
||||
if (optional<CocoDiagnosticSeverity> severity = diag.cocoSeverity()) {
|
||||
|
||||
const TextEditor::TextStyle style = styleForSeverity(*severity);
|
||||
m_annotationColor =
|
||||
TextEditor::TextEditorSettings::fontSettings().formatFor(style).foreground();
|
||||
}
|
||||
}
|
||||
|
||||
QColor annotationColor() const override
|
||||
{
|
||||
return m_annotationColor.isValid() ? m_annotationColor
|
||||
: TextEditor::TextMark::annotationColor();
|
||||
}
|
||||
|
||||
QColor m_annotationColor;
|
||||
};
|
||||
|
||||
class CocoDiagnosticManager : public DiagnosticManager
|
||||
@@ -171,8 +185,9 @@ private:
|
||||
QTextCursor::KeepAnchor);
|
||||
|
||||
const TextEditor::TextStyle style = styleForSeverity(*severity);
|
||||
const QTextCharFormat format = TextEditor::TextEditorSettings::fontSettings()
|
||||
.toTextCharFormat(style);
|
||||
QTextCharFormat format = TextEditor::TextEditorSettings::fontSettings()
|
||||
.toTextCharFormat(style);
|
||||
format.clearForeground();
|
||||
return QTextEdit::ExtraSelection{cursor, format};
|
||||
}
|
||||
return {};
|
||||
|
@@ -155,13 +155,12 @@ void TextMark::paintAnnotation(QPainter &painter,
|
||||
return;
|
||||
}
|
||||
|
||||
const QColor &markColor = m_color.has_value()
|
||||
? Utils::creatorTheme()->color(m_color.value()).toHsl()
|
||||
: painter.pen().color();
|
||||
const QColor &markColor = annotationColor();
|
||||
|
||||
const FontSettings &fontSettings = m_baseTextDocument->fontSettings();
|
||||
const AnnotationColors &colors = AnnotationColors::getAnnotationColors(
|
||||
markColor, fontSettings.toTextCharFormat(C_TEXT).background().color());
|
||||
markColor.isValid() ? markColor : painter.pen().color(),
|
||||
fontSettings.toTextCharFormat(C_TEXT).background().color());
|
||||
|
||||
painter.save();
|
||||
QLinearGradient grad(rects.fadeInRect.topLeft() - contentOffset,
|
||||
@@ -355,6 +354,13 @@ bool TextMark::addToolTipContent(QLayout *target) const
|
||||
return true;
|
||||
}
|
||||
|
||||
QColor TextMark::annotationColor() const
|
||||
{
|
||||
if (m_color.has_value())
|
||||
return Utils::creatorTheme()->color(*m_color).toHsl();
|
||||
return {};
|
||||
}
|
||||
|
||||
void TextMark::setIcon(const QIcon &icon)
|
||||
{
|
||||
m_icon = icon;
|
||||
|
@@ -101,6 +101,7 @@ public:
|
||||
virtual void dragToLine(int lineNumber);
|
||||
void addToToolTipLayout(QGridLayout *target) const;
|
||||
virtual bool addToolTipContent(QLayout *target) const;
|
||||
virtual QColor annotationColor() const;
|
||||
|
||||
void setIcon(const QIcon &icon);
|
||||
void setIconProvider(const std::function<QIcon()> &iconProvider);
|
||||
|
Reference in New Issue
Block a user