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 <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-09-13 12:42:08 +02:00
parent 32ba65c7f8
commit 425463ce8d

View File

@@ -228,22 +228,24 @@ void FontSettings::addMixinStyle(QTextCharFormat &textCharFormat,
for (TextStyle mixinStyle : mixinStyles) { for (TextStyle mixinStyle : mixinStyles) {
const Format &format = m_scheme.formatFor(mixinStyle); const Format &format = m_scheme.formatFor(mixinStyle);
if (textCharFormat.hasProperty(QTextFormat::ForegroundBrush)) { if (format.foreground().isValid()) {
if (format.foreground().isValid())
textCharFormat.setForeground(format.foreground()); textCharFormat.setForeground(format.foreground());
else } else {
if (textCharFormat.hasProperty(QTextFormat::ForegroundBrush)) {
textCharFormat.setForeground(mixBrush(textCharFormat.foreground(), textCharFormat.setForeground(mixBrush(textCharFormat.foreground(),
format.relativeForegroundSaturation(), format.relativeForegroundSaturation(),
format.relativeForegroundLightness())); format.relativeForegroundLightness()));
} }
if (textCharFormat.hasProperty(QTextFormat::BackgroundBrush)) { }
if (format.background().isValid()) if (format.background().isValid()) {
textCharFormat.setBackground(format.background()); textCharFormat.setBackground(format.background());
else } else {
if (textCharFormat.hasProperty(QTextFormat::BackgroundBrush)) {
textCharFormat.setBackground(mixBrush(textCharFormat.background(), textCharFormat.setBackground(mixBrush(textCharFormat.background(),
format.relativeBackgroundSaturation(), format.relativeBackgroundSaturation(),
format.relativeBackgroundLightness())); format.relativeBackgroundLightness()));
} }
}
if (!textCharFormat.fontItalic()) if (!textCharFormat.fontItalic())
textCharFormat.setFontItalic(format.italic()); textCharFormat.setFontItalic(format.italic());