diff options
author | Eike Ziller <eike.ziller@qt.io> | 2017-07-21 10:08:05 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2017-07-21 10:08:05 +0200 |
commit | 1feb5c604d6dea4501279c22a2be51d0d900dd61 (patch) | |
tree | 349334e619938f9b8b5cb4e15a6d7d6e88b1f6be /src/plugins/texteditor/textmark.cpp | |
parent | 13d3a7a5dc5d8919bf8f8b1172892bd7f39b9fb1 (diff) | |
parent | e65d4c6f655b7d2045d5b40b7a0e981901ba43b7 (diff) | |
download | qt-creator-1feb5c604d6dea4501279c22a2be51d0d900dd61.tar.gz |
Merge remote-tracking branch 'origin/4.4'
Change-Id: I02e54f45d233b89ddaee9c87da9b9af2a56374b8
Diffstat (limited to 'src/plugins/texteditor/textmark.cpp')
-rw-r--r-- | src/plugins/texteditor/textmark.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index d1fc50689c..b2859642c6 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -70,9 +70,6 @@ public: QColor textColor; private: - static double clipHsl(double value); - -private: static QHash<SourceColors, AnnotationColors> m_colorCache; }; @@ -91,7 +88,8 @@ TextMark::TextMark(const QString &fileName, int lineNumber, Id category, double TextMark::~TextMark() { - TextMarkRegistry::remove(this); + if (!m_fileName.isEmpty()) + TextMarkRegistry::remove(this); if (m_baseTextDocument) m_baseTextDocument->removeMark(this); m_baseTextDocument = nullptr; @@ -376,16 +374,22 @@ QHash<AnnotationColors::SourceColors, AnnotationColors> AnnotationColors::m_colo AnnotationColors &AnnotationColors::getAnnotationColors(const QColor &markColor, const QColor &backgroundColor) { + auto highClipHsl = [](qreal value) { + return std::max(0.7, std::min(0.9, value)); + }; + auto lowClipHsl = [](qreal value) { + return std::max(0.1, std::min(0.3, value)); + }; AnnotationColors &colors = m_colorCache[{markColor, backgroundColor}]; if (!colors.rectColor.isValid() || !colors.textColor.isValid()) { - const double backgroundSaturation = clipHsl(markColor.hslSaturationF() / 2); - const double backgroundLightness = clipHsl(backgroundColor.lightnessF()); - const double foregroundLightness = clipHsl(backgroundLightness > 0.5 - ? backgroundLightness - 0.5 - : backgroundLightness + 0.5); - colors.rectColor.setHslF(markColor.hslHueF(), - backgroundSaturation, - backgroundLightness); + const double backgroundLightness = backgroundColor.lightnessF(); + const double foregroundLightness = backgroundLightness > 0.5 + ? lowClipHsl(backgroundLightness - 0.5) + : highClipHsl(backgroundLightness + 0.5); + + colors.rectColor = markColor; + colors.rectColor.setAlphaF(0.15); + colors.textColor.setHslF(markColor.hslHueF(), markColor.hslSaturationF(), foregroundLightness); @@ -393,11 +397,6 @@ AnnotationColors &AnnotationColors::getAnnotationColors(const QColor &markColor, return colors; } -double AnnotationColors::clipHsl(double value) -{ - return std::max(0.15, std::min(0.85, value)); -} - } // namespace TextEditor #include "textmark.moc" |