Commit 078242aa authored by Milian Wolff's avatar Milian Wolff
Browse files

Simplify by flattening nested conditionals

The `bg.valueF() > 0.3` check is contained in the isBrightColor
check, so we can easily flatten this nested conditional here.
parent 11b71de3
......@@ -140,17 +140,15 @@ void collectRanges(QTextFrame* frame, const QColor& fgcolor, const QColor& bgcol
} else {
auto bg = background.value_or(bgcolor);
auto fg = foreground.value_or(fgcolor);
if (bg.valueF() > 0.3) {
if (background && isBrightColor(bg)) {
bg = invertColor(bg);
fmt.setBackground(bg);
if (fg.valueF() < 0.7) {
fmt.setForeground(WidgetColorizer::blendForeground(fg, 1.0, fgcolor, bg));
}
} else if (isBrightColor(fg)) {
fg = invertColor(fg);
fmt.setForeground(fg);
if (background && isBrightColor(bg)) {
bg = invertColor(bg);
fmt.setBackground(bg);
if (fg.valueF() < 0.7) {
fmt.setForeground(WidgetColorizer::blendForeground(fg, 1.0, fgcolor, bg));
}
} else if (bg.valueF() > 0.3 && isBrightColor(fg)) {
fg = invertColor(fg);
fmt.setForeground(fg);
}
}
ranges.push_back({fragment.position(), fragment.position() + fragment.length(), fmt});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment