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());
|
setLineAnnotation(diag.message());
|
||||||
setToolTip(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
|
class CocoDiagnosticManager : public DiagnosticManager
|
||||||
@@ -171,8 +185,9 @@ private:
|
|||||||
QTextCursor::KeepAnchor);
|
QTextCursor::KeepAnchor);
|
||||||
|
|
||||||
const TextEditor::TextStyle style = styleForSeverity(*severity);
|
const TextEditor::TextStyle style = styleForSeverity(*severity);
|
||||||
const QTextCharFormat format = TextEditor::TextEditorSettings::fontSettings()
|
QTextCharFormat format = TextEditor::TextEditorSettings::fontSettings()
|
||||||
.toTextCharFormat(style);
|
.toTextCharFormat(style);
|
||||||
|
format.clearForeground();
|
||||||
return QTextEdit::ExtraSelection{cursor, format};
|
return QTextEdit::ExtraSelection{cursor, format};
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
@@ -155,13 +155,12 @@ void TextMark::paintAnnotation(QPainter &painter,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QColor &markColor = m_color.has_value()
|
const QColor &markColor = annotationColor();
|
||||||
? Utils::creatorTheme()->color(m_color.value()).toHsl()
|
|
||||||
: painter.pen().color();
|
|
||||||
|
|
||||||
const FontSettings &fontSettings = m_baseTextDocument->fontSettings();
|
const FontSettings &fontSettings = m_baseTextDocument->fontSettings();
|
||||||
const AnnotationColors &colors = AnnotationColors::getAnnotationColors(
|
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();
|
painter.save();
|
||||||
QLinearGradient grad(rects.fadeInRect.topLeft() - contentOffset,
|
QLinearGradient grad(rects.fadeInRect.topLeft() - contentOffset,
|
||||||
@@ -355,6 +354,13 @@ bool TextMark::addToolTipContent(QLayout *target) const
|
|||||||
return true;
|
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)
|
void TextMark::setIcon(const QIcon &icon)
|
||||||
{
|
{
|
||||||
m_icon = icon;
|
m_icon = icon;
|
||||||
|
@@ -101,6 +101,7 @@ public:
|
|||||||
virtual void dragToLine(int lineNumber);
|
virtual void dragToLine(int lineNumber);
|
||||||
void addToToolTipLayout(QGridLayout *target) const;
|
void addToToolTipLayout(QGridLayout *target) const;
|
||||||
virtual bool addToolTipContent(QLayout *target) const;
|
virtual bool addToolTipContent(QLayout *target) const;
|
||||||
|
virtual QColor annotationColor() const;
|
||||||
|
|
||||||
void setIcon(const QIcon &icon);
|
void setIcon(const QIcon &icon);
|
||||||
void setIconProvider(const std::function<QIcon()> &iconProvider);
|
void setIconProvider(const std::function<QIcon()> &iconProvider);
|
||||||
|
Reference in New Issue
Block a user