Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KDevelop
KDevelop
Commits
11b71de3
Commit
11b71de3
authored
Jul 13, 2022
by
Milian Wolff
Browse files
Introduce isBrightColor for more readability
It's still unclear what the saturation check is doing though...
parent
4354c48f
Changes
1
Hide whitespace changes
Inline
Side-by-side
kdevplatform/util/widgetcolorizer.cpp
View file @
11b71de3
...
...
@@ -103,6 +103,12 @@ std::optional<QColor> backgroundColor(const QTextFormat& format)
return
format
.
background
().
color
();
}
bool
isBrightColor
(
const
QColor
&
color
)
{
// TODO: what's the saturation check doing here? add comment!
return
color
.
valueF
()
>
0.5
&&
color
.
hsvSaturationF
()
<
0.08
;
}
void
collectRanges
(
QTextFrame
*
frame
,
const
QColor
&
fgcolor
,
const
QColor
&
bgcolor
,
bool
bgSet
,
std
::
vector
<
FormatRange
>&
ranges
)
{
...
...
@@ -135,13 +141,13 @@ void collectRanges(QTextFrame* frame, const QColor& fgcolor, const QColor& bgcol
auto
bg
=
background
.
value_or
(
bgcolor
);
auto
fg
=
foreground
.
value_or
(
fgcolor
);
if
(
bg
.
valueF
()
>
0.3
)
{
if
(
background
&&
bg
.
valueF
()
>
0.5
&&
bg
.
hsvSaturationF
()
<
0.08
)
{
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
(
fg
.
valueF
()
>
0.5
&&
fg
.
hsvSaturationF
()
<
0.08
)
{
}
else
if
(
isBrightColor
(
fg
)
)
{
fg
=
invertColor
(
fg
);
fmt
.
setForeground
(
fg
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment