forked from qt-creator/qt-creator
Coco: update annotation color on font settings change
Change-Id: I7812fccb047d696701d477ae85697facdb1c0361 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -154,15 +154,11 @@ class CocoTextMark : public TextEditor::TextMark
|
|||||||
public:
|
public:
|
||||||
CocoTextMark(const FilePath &fileName, const CocoDiagnostic &diag, const Id &clientId)
|
CocoTextMark(const FilePath &fileName, const CocoDiagnostic &diag, const Id &clientId)
|
||||||
: TextEditor::TextMark(fileName, diag.range().start().line() + 1, clientId)
|
: TextEditor::TextMark(fileName, diag.range().start().line() + 1, clientId)
|
||||||
|
, m_severity(diag.cocoSeverity())
|
||||||
{
|
{
|
||||||
setLineAnnotation(diag.message());
|
setLineAnnotation(diag.message());
|
||||||
setToolTip(diag.message());
|
setToolTip(diag.message());
|
||||||
if (optional<CocoDiagnosticSeverity> severity = diag.cocoSeverity()) {
|
updateAnnotationColor();
|
||||||
|
|
||||||
const TextEditor::TextStyle style = styleForSeverity(*severity);
|
|
||||||
m_annotationColor =
|
|
||||||
TextEditor::TextEditorSettings::fontSettings().formatFor(style).foreground();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor annotationColor() const override
|
QColor annotationColor() const override
|
||||||
@@ -171,6 +167,16 @@ public:
|
|||||||
: TextEditor::TextMark::annotationColor();
|
: TextEditor::TextMark::annotationColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateAnnotationColor()
|
||||||
|
{
|
||||||
|
if (m_severity) {
|
||||||
|
const TextEditor::TextStyle style = styleForSeverity(*m_severity);
|
||||||
|
m_annotationColor =
|
||||||
|
TextEditor::TextEditorSettings::fontSettings().formatFor(style).foreground();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
optional<CocoDiagnosticSeverity> m_severity;
|
||||||
QColor m_annotationColor;
|
QColor m_annotationColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -180,10 +186,22 @@ public:
|
|||||||
CocoDiagnosticManager(Client *client)
|
CocoDiagnosticManager(Client *client)
|
||||||
: DiagnosticManager(client)
|
: DiagnosticManager(client)
|
||||||
{
|
{
|
||||||
|
connect(TextEditor::TextEditorSettings::instance(),
|
||||||
|
&TextEditor::TextEditorSettings::fontSettingsChanged,
|
||||||
|
this,
|
||||||
|
&CocoDiagnosticManager::fontSettingsChanged);
|
||||||
setExtraSelectionsId("CocoExtraSelections");
|
setExtraSelectionsId("CocoExtraSelections");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void fontSettingsChanged(const TextEditor::FontSettings &fontSettings)
|
||||||
|
{
|
||||||
|
forAllMarks([](TextEditor::TextMark *mark){
|
||||||
|
static_cast<CocoTextMark *>(mark)->updateAnnotationColor();
|
||||||
|
mark->updateMarker();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
TextEditor::TextMark *createTextMark(const FilePath &filePath,
|
TextEditor::TextMark *createTextMark(const FilePath &filePath,
|
||||||
const Diagnostic &diagnostic,
|
const Diagnostic &diagnostic,
|
||||||
bool /*isProjectFile*/) const override
|
bool /*isProjectFile*/) const override
|
||||||
|
@@ -176,6 +176,14 @@ void DiagnosticManager::setExtraSelectionsId(const Utils::Id &extraSelectionsId)
|
|||||||
m_extraSelectionsId = extraSelectionsId;
|
m_extraSelectionsId = extraSelectionsId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiagnosticManager::forAllMarks(std::function<void (TextEditor::TextMark *)> func)
|
||||||
|
{
|
||||||
|
for (const Marks &marks : qAsConst(m_marks)) {
|
||||||
|
for (TextEditor::TextMark *mark : marks.marks)
|
||||||
|
func(mark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DiagnosticManager::clearDiagnostics()
|
void DiagnosticManager::clearDiagnostics()
|
||||||
{
|
{
|
||||||
for (const DocumentUri &uri : m_diagnostics.keys())
|
for (const DocumentUri &uri : m_diagnostics.keys())
|
||||||
|
@@ -85,6 +85,8 @@ protected:
|
|||||||
|
|
||||||
void setExtraSelectionsId(const Utils::Id &extraSelectionsId);
|
void setExtraSelectionsId(const Utils::Id &extraSelectionsId);
|
||||||
|
|
||||||
|
void forAllMarks(std::function<void (TextEditor::TextMark *)> func);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct VersionedDiagnostics
|
struct VersionedDiagnostics
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user