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
Plasma
Plasma Workspace
Commits
fa7b0514
Commit
fa7b0514
authored
Apr 08, 2022
by
Jan Blackquill
🌈
Browse files
clang-format the colors kcm
parent
41505069
Pipeline
#161490
passed with stage
in 7 minutes and 20 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
kcms/colors/colors.cpp
View file @
fa7b0514
...
...
@@ -391,12 +391,12 @@ void KCMColors::saveColors()
setGlobals
();
}
QColor
KCMColors
::
accentBackground
(
const
QColor
&
accent
,
const
QColor
&
background
)
QColor
KCMColors
::
accentBackground
(
const
QColor
&
accent
,
const
QColor
&
background
)
{
return
::
accentBackground
(
accent
,
background
);
}
QColor
KCMColors
::
accentForeground
(
const
QColor
&
accent
,
const
bool
&
isActive
)
QColor
KCMColors
::
accentForeground
(
const
QColor
&
accent
,
const
bool
&
isActive
)
{
return
::
accentForeground
(
accent
,
isActive
);
}
...
...
kcms/colors/colors.h
View file @
fa7b0514
...
...
@@ -63,7 +63,7 @@ public:
Q_INVOKABLE
void
knsEntryChanged
(
KNSCore
::
EntryWrapper
*
entry
);
QColor
accentColor
()
const
;
void
setAccentColor
(
const
QColor
&
accentColor
);
void
setAccentColor
(
const
QColor
&
accentColor
);
void
resetAccentColor
();
Q_SIGNAL
void
accentColorChanged
();
...
...
@@ -71,8 +71,8 @@ public:
Q_INVOKABLE
void
editScheme
(
const
QString
&
schemeName
,
QQuickItem
*
ctx
);
Q_INVOKABLE
QColor
accentBackground
(
const
QColor
&
accent
,
const
QColor
&
background
);
Q_INVOKABLE
QColor
accentForeground
(
const
QColor
&
accent
,
const
bool
&
isActive
);
Q_INVOKABLE
QColor
accentBackground
(
const
QColor
&
accent
,
const
QColor
&
background
);
Q_INVOKABLE
QColor
accentForeground
(
const
QColor
&
accent
,
const
bool
&
isActive
);
public
Q_SLOTS
:
void
load
()
override
;
...
...
kcms/colors/colorsapplicator.cpp
View file @
fa7b0514
...
...
@@ -92,10 +92,10 @@ void applyScheme(const QString &colorSchemePath, KConfig *configOutput, KConfig:
if
(
item
==
QStringLiteral
(
"Colors:Selection"
)
&&
hasAccent
())
{
QColor
accentbg
=
accentBackground
(
getAccent
(),
config
->
group
(
"Colors:View"
).
readEntry
<
QColor
>
(
"BackgroundNormal"
,
QColor
()));
for
(
const
auto
&
entry
:
{
QStringLiteral
(
"BackgroundNormal"
),
QStringLiteral
(
"BackgroundAlternate"
)})
{
for
(
const
auto
&
entry
:
{
QStringLiteral
(
"BackgroundNormal"
),
QStringLiteral
(
"BackgroundAlternate"
)})
{
targetGroup
.
writeEntry
(
entry
,
accentbg
);
}
for
(
const
auto
&
entry
:
{
QStringLiteral
(
"ForegroundNormal"
),
QStringLiteral
(
"ForegroundInactive"
)})
{
for
(
const
auto
&
entry
:
{
QStringLiteral
(
"ForegroundNormal"
),
QStringLiteral
(
"ForegroundInactive"
)})
{
targetGroup
.
writeEntry
(
entry
,
accentForeground
(
accentbg
,
true
));
}
}
...
...
@@ -109,7 +109,7 @@ void applyScheme(const QString &colorSchemePath, KConfig *configOutput, KConfig:
}
}
//Header accent colouring
//
Header accent colouring
if
(
item
==
QStringLiteral
(
"Colors:Header"
)
&&
config
->
hasGroup
(
QStringLiteral
(
"Colors:Header"
))
&&
hasAccent
())
{
QColor
accentbg
=
accentBackground
(
getAccent
(),
config
->
group
(
"Colors:Window"
).
readEntry
<
QColor
>
(
"BackgroundNormal"
,
QColor
()));
if
(
accentActiveTitlebar
)
{
...
...
@@ -120,7 +120,7 @@ void applyScheme(const QString &colorSchemePath, KConfig *configOutput, KConfig:
if
(
accentInactiveTitlebar
)
{
targetGroup
=
targetGroup
.
group
(
"Inactive"
);
targetGroup
.
writeEntry
(
"BackgroundNormal"
,
accentbg
);
targetGroup
.
writeEntry
(
"ForegroundNormal"
,
accentForeground
(
accentbg
,
false
));
//Dimmed foreground
targetGroup
.
writeEntry
(
"ForegroundNormal"
,
accentForeground
(
accentbg
,
false
));
//
Dimmed foreground
}
}
}
...
...
@@ -149,7 +149,7 @@ void applyScheme(const QString &colorSchemePath, KConfig *configOutput, KConfig:
++
i
;
}
if
(
hasAccent
())
{
//Titlebar accent colouring
if
(
hasAccent
())
{
//
Titlebar accent colouring
QColor
accentbg
=
accentBackground
(
getAccent
(),
config
->
group
(
"Colors:Window"
).
readEntry
<
QColor
>
(
"BackgroundNormal"
,
QColor
()));
if
(
accentActiveTitlebar
)
{
groupWMOut
.
writeEntry
(
"activeBackground"
,
accentbg
);
...
...
@@ -157,11 +157,10 @@ void applyScheme(const QString &colorSchemePath, KConfig *configOutput, KConfig:
}
if
(
accentInactiveTitlebar
)
{
groupWMOut
.
writeEntry
(
"inactiveBackground"
,
accentbg
);
groupWMOut
.
writeEntry
(
"inactiveForeground"
,
accentForeground
(
accentbg
,
false
));
//Dimmed foreground
groupWMOut
.
writeEntry
(
"inactiveForeground"
,
accentForeground
(
accentbg
,
false
));
//
Dimmed foreground
}
}
const
QStringList
groupNameList
{
QStringLiteral
(
"ColorEffects:Inactive"
),
QStringLiteral
(
"ColorEffects:Disabled"
)};
const
QStringList
effectList
{
QStringLiteral
(
"Enable"
),
...
...
kcms/colors/colorsapplicator.h
View file @
fa7b0514
...
...
@@ -10,8 +10,8 @@
#include
<QColor>
#include
<QString>
#include
<KConfig>
#include
<KColorUtils>
#include
<KConfig>
inline
QColor
alphaBlend
(
const
QColor
&
foreground
,
const
QColor
&
background
)
{
...
...
@@ -24,47 +24,43 @@ inline QColor alphaBlend(const QColor &foreground, const QColor &background)
}
if
(
backgroundAlpha
==
1
.
0
)
{
return
QColor
::
fromRgb
(
(
foregroundAlpha
*
foreground
.
red
())
+
(
inverseForegroundAlpha
*
background
.
red
()),
(
foregroundAlpha
*
foreground
.
green
())
+
(
inverseForegroundAlpha
*
background
.
green
()),
(
foregroundAlpha
*
foreground
.
blue
())
+
(
inverseForegroundAlpha
*
background
.
blue
()),
0xff
);
return
QColor
::
fromRgb
((
foregroundAlpha
*
foreground
.
red
())
+
(
inverseForegroundAlpha
*
background
.
red
()),
(
foregroundAlpha
*
foreground
.
green
())
+
(
inverseForegroundAlpha
*
background
.
green
()),
(
foregroundAlpha
*
foreground
.
blue
())
+
(
inverseForegroundAlpha
*
background
.
blue
()),
0xff
);
}
else
{
const
auto
inverseBackgroundAlpha
=
(
backgroundAlpha
*
inverseForegroundAlpha
);
const
auto
finalAlpha
=
foregroundAlpha
+
inverseBackgroundAlpha
;
Q_ASSERT
(
finalAlpha
!=
0
.
0
);
return
QColor
::
fromRgb
(
(
foregroundAlpha
*
foreground
.
red
())
+
(
inverseBackgroundAlpha
*
background
.
red
()),
(
foregroundAlpha
*
foreground
.
green
())
+
(
inverseBackgroundAlpha
*
background
.
green
()),
(
foregroundAlpha
*
foreground
.
blue
())
+
(
inverseBackgroundAlpha
*
background
.
blue
()),
finalAlpha
);
return
QColor
::
fromRgb
((
foregroundAlpha
*
foreground
.
red
())
+
(
inverseBackgroundAlpha
*
background
.
red
()),
(
foregroundAlpha
*
foreground
.
green
())
+
(
inverseBackgroundAlpha
*
background
.
green
()),
(
foregroundAlpha
*
foreground
.
blue
())
+
(
inverseBackgroundAlpha
*
background
.
blue
()),
finalAlpha
);
}
}
inline
QColor
accentBackground
(
const
QColor
&
accent
,
const
QColor
&
background
)
inline
QColor
accentBackground
(
const
QColor
&
accent
,
const
QColor
&
background
)
{
auto
c
=
accent
;
// light bg
if
(
KColorUtils
::
luma
(
background
)
>
0
.
5
)
{
c
.
setAlphaF
(
0
.
7
);
}
else
{
// dark bg
// dark bg
c
.
setAlphaF
(
0
.
4
);
}
return
alphaBlend
(
c
,
background
);
}
inline
QColor
accentForeground
(
const
QColor
&
accent
,
const
bool
&
isActive
)
inline
QColor
accentForeground
(
const
QColor
&
accent
,
const
bool
&
isActive
)
{
auto
c
=
QColor
(
Qt
::
white
);
// light bg
if
(
KColorUtils
::
luma
(
accent
)
>
0
.
5
)
{
c
=
QColor
(
Qt
::
black
);
}
else
{
// dark bg
// dark bg
c
=
QColor
(
Qt
::
white
);
}
...
...
kcms/colors/editor/scmeditordialog.h
View file @
fa7b0514
...
...
@@ -35,7 +35,6 @@ Q_SIGNALS:
private
Q_SLOTS
:
void
on_buttonBox_clicked
(
QAbstractButton
*
button
);
void
updateTabs
(
bool
byUser
=
false
);
...
...
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