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);
|
const Format &format = m_scheme.formatFor(mixinStyle);
|
||||||
|
|
||||||
if (textCharFormat.hasProperty(QTextFormat::ForegroundBrush)) {
|
if (textCharFormat.hasProperty(QTextFormat::ForegroundBrush)) {
|
||||||
textCharFormat.setForeground(mixBrush(textCharFormat.foreground(),
|
if (format.foreground().isValid())
|
||||||
format.relativeForegroundSaturation(),
|
textCharFormat.setForeground(format.foreground());
|
||||||
format.relativeForegroundLightness()));
|
else
|
||||||
|
textCharFormat.setForeground(mixBrush(textCharFormat.foreground(),
|
||||||
|
format.relativeForegroundSaturation(),
|
||||||
|
format.relativeForegroundLightness()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textCharFormat.hasProperty(QTextFormat::BackgroundBrush)) {
|
if (textCharFormat.hasProperty(QTextFormat::BackgroundBrush)) {
|
||||||
textCharFormat.setBackground(mixBrush(textCharFormat.background(),
|
if (format.background().isValid())
|
||||||
format.relativeBackgroundSaturation(),
|
textCharFormat.setBackground(format.background());
|
||||||
format.relativeBackgroundLightness()));
|
else
|
||||||
|
textCharFormat.setBackground(mixBrush(textCharFormat.background(),
|
||||||
|
format.relativeBackgroundSaturation(),
|
||||||
|
format.relativeBackgroundLightness()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!textCharFormat.fontItalic())
|
if (!textCharFormat.fontItalic())
|
||||||
textCharFormat.setFontItalic(format.italic());
|
textCharFormat.setFontItalic(format.italic());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user