From 425463ce8daf6ca862526d07c4d24d09215da151 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 13 Sep 2018 12:42:08 +0200 Subject: [PATCH] TextEditor: Fix highlighting for mixins The color from mix-ins should be always override the previous color. It should only be tested for relative colors. It looks like the branches was mixed up. Change-Id: I9b8602ab65cab65f0df8ec2c111845cf2d8d33cf Reviewed-by: Ivan Donchevskii --- src/plugins/texteditor/fontsettings.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/plugins/texteditor/fontsettings.cpp b/src/plugins/texteditor/fontsettings.cpp index e1ebc812ee3..9c6667d00c5 100644 --- a/src/plugins/texteditor/fontsettings.cpp +++ b/src/plugins/texteditor/fontsettings.cpp @@ -228,21 +228,23 @@ void FontSettings::addMixinStyle(QTextCharFormat &textCharFormat, for (TextStyle mixinStyle : mixinStyles) { const Format &format = m_scheme.formatFor(mixinStyle); - if (textCharFormat.hasProperty(QTextFormat::ForegroundBrush)) { - if (format.foreground().isValid()) - textCharFormat.setForeground(format.foreground()); - else + if (format.foreground().isValid()) { + textCharFormat.setForeground(format.foreground()); + } else { + if (textCharFormat.hasProperty(QTextFormat::ForegroundBrush)) { textCharFormat.setForeground(mixBrush(textCharFormat.foreground(), format.relativeForegroundSaturation(), format.relativeForegroundLightness())); + } } - if (textCharFormat.hasProperty(QTextFormat::BackgroundBrush)) { - if (format.background().isValid()) - textCharFormat.setBackground(format.background()); - else + if (format.background().isValid()) { + textCharFormat.setBackground(format.background()); + } else { + if (textCharFormat.hasProperty(QTextFormat::BackgroundBrush)) { textCharFormat.setBackground(mixBrush(textCharFormat.background(), format.relativeBackgroundSaturation(), format.relativeBackgroundLightness())); + } } if (!textCharFormat.fontItalic()) textCharFormat.setFontItalic(format.italic());