forked from qt-creator/qt-creator
TextEditor: Implement color overriding mixins
This is the first implementation of "color overriding mixins". Mixins are already initialized with fore/background color = QColor() = "invalid color" (see Format::createMixinFormat). This patch uses above contract in FontSettings::addMixinStyle. Only mixins with a valid fore- or background color can override other style options' colors. Unset mixins will have no effect. TEST=No functional change (will be enabled in a follow-up). Requires Clang. Task-number: QTCREATORBUG-16625 Change-Id: I983bb876c060963f6d66cc64881bc138e384f5e5 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -229,17 +229,21 @@ void FontSettings::addMixinStyle(QTextCharFormat &textCharFormat,
|
||||
const Format &format = m_scheme.formatFor(mixinStyle);
|
||||
|
||||
if (textCharFormat.hasProperty(QTextFormat::ForegroundBrush)) {
|
||||
textCharFormat.setForeground(mixBrush(textCharFormat.foreground(),
|
||||
format.relativeForegroundSaturation(),
|
||||
format.relativeForegroundLightness()));
|
||||
if (format.foreground().isValid())
|
||||
textCharFormat.setForeground(format.foreground());
|
||||
else
|
||||
textCharFormat.setForeground(mixBrush(textCharFormat.foreground(),
|
||||
format.relativeForegroundSaturation(),
|
||||
format.relativeForegroundLightness()));
|
||||
}
|
||||
|
||||
if (textCharFormat.hasProperty(QTextFormat::BackgroundBrush)) {
|
||||
textCharFormat.setBackground(mixBrush(textCharFormat.background(),
|
||||
format.relativeBackgroundSaturation(),
|
||||
format.relativeBackgroundLightness()));
|
||||
if (format.background().isValid())
|
||||
textCharFormat.setBackground(format.background());
|
||||
else
|
||||
textCharFormat.setBackground(mixBrush(textCharFormat.background(),
|
||||
format.relativeBackgroundSaturation(),
|
||||
format.relativeBackgroundLightness()));
|
||||
}
|
||||
|
||||
if (!textCharFormat.fontItalic())
|
||||
textCharFormat.setFontItalic(format.italic());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user