diff options
author | Tobias Hunger <[email protected]> | 2012-03-06 14:32:32 +0100 |
---|---|---|
committer | Tobias Hunger <[email protected]> | 2012-03-06 14:34:01 +0100 |
commit | 4b366303e65f15511200d6996d02315973e68f75 (patch) | |
tree | 484e059a396cd4c0d1213db3e1db4de86f4b7fc0 /src/plugins/vcsbase/baseannotationhighlighter.cpp | |
parent | 5e365686287d39c6bec414de6bba91ad3fb0e5fa (diff) |
VCS: Make dark color schemes work with annotation highlighter
Task-number: QTCREATORBUG-6257
Change-Id: Ied01cf6773b5114100afccbac33f359cc72c0889
Reviewed-by: Tobias Hunger <[email protected]>
Diffstat (limited to 'src/plugins/vcsbase/baseannotationhighlighter.cpp')
-rw-r--r-- | src/plugins/vcsbase/baseannotationhighlighter.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/plugins/vcsbase/baseannotationhighlighter.cpp b/src/plugins/vcsbase/baseannotationhighlighter.cpp index 08c8831955a..6cd06fda20f 100644 --- a/src/plugins/vcsbase/baseannotationhighlighter.cpp +++ b/src/plugins/vcsbase/baseannotationhighlighter.cpp @@ -62,15 +62,18 @@ class BaseAnnotationHighlighterPrivate { public: ChangeNumberFormatMap m_changeNumberMap; + QColor m_background; }; } // namespace Internal BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers, - QTextDocument *document) : + const QColor &bg, + QTextDocument *document) : TextEditor::SyntaxHighlighter(document), d(new Internal::BaseAnnotationHighlighterPrivate) { + d->m_background = bg; setChangeNumbers(changeNumbers); } @@ -81,6 +84,7 @@ BaseAnnotationHighlighter::~BaseAnnotationHighlighter() void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumbers) { + QColor bg = d->m_background; d->m_changeNumberMap.clear(); if (!changeNumbers.isEmpty()) { // Assign a color gradient to annotation change numbers. Give @@ -89,10 +93,16 @@ void BaseAnnotationHighlighter::setChangeNumbers(const ChangeNumbers &changeNumb const int step = qRound(ceil(pow(double(changeNumbers.count()), oneThird))); QList<QColor> colors; const int factor = 255 / step; - for (int i=0; i<step; ++i) - for (int j=0; j<step; ++j) - for (int k=0; k<step; ++k) - colors.append(QColor(i*factor, j*factor, k*factor)); + int half = factor / 2; + for (int i=0; i<=step; ++i) + for (int j=0; j<=step; ++j) + for (int k=0; k<=step; ++k) { + QColor c(i*factor, j*factor, k*factor); + if ((bg.red() - half > c.red() ||bg.red() + half <= c.red()) + && (bg.green() - half > c.green() || bg.green() + half <= c.green()) + && (bg.blue() - half > c.blue() || bg.blue() + half <= c.blue())) + colors.prepend(c); + } int m = 0; const int cstep = colors.count() / changeNumbers.count(); @@ -116,4 +126,10 @@ void BaseAnnotationHighlighter::highlightBlock(const QString &text) setFormat(0, text.length(), it.value()); } +void BaseAnnotationHighlighter::setBackgroundColor(const QColor &color) +{ + d->m_background = color; + setChangeNumbers(d->m_changeNumberMap.keys().toSet()); +} + } // namespace VcsBase |