clang-format the colors kcm

wilder-5.25
Jan Blackquill 4 years ago
parent 4150506920
commit fa7b051471
  1. 4
      kcms/colors/colors.cpp
  2. 6
      kcms/colors/colors.h
  3. 13
      kcms/colors/colorsapplicator.cpp
  4. 30
      kcms/colors/colorsapplicator.h
  5. 1
      kcms/colors/editor/scmeditordialog.h

@ -391,12 +391,12 @@ void KCMColors::saveColors()
setGlobals(); setGlobals();
} }
QColor KCMColors::accentBackground(const QColor& accent, const QColor& background) QColor KCMColors::accentBackground(const QColor &accent, const QColor &background)
{ {
return ::accentBackground(accent, 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); return ::accentForeground(accent, isActive);
} }

@ -63,7 +63,7 @@ public:
Q_INVOKABLE void knsEntryChanged(KNSCore::EntryWrapper *entry); Q_INVOKABLE void knsEntryChanged(KNSCore::EntryWrapper *entry);
QColor accentColor() const; QColor accentColor() const;
void setAccentColor(const QColor& accentColor); void setAccentColor(const QColor &accentColor);
void resetAccentColor(); void resetAccentColor();
Q_SIGNAL void accentColorChanged(); Q_SIGNAL void accentColorChanged();
@ -71,8 +71,8 @@ public:
Q_INVOKABLE void editScheme(const QString &schemeName, QQuickItem *ctx); Q_INVOKABLE void editScheme(const QString &schemeName, QQuickItem *ctx);
Q_INVOKABLE QColor accentBackground(const QColor& accent, const QColor& background); Q_INVOKABLE QColor accentBackground(const QColor &accent, const QColor &background);
Q_INVOKABLE QColor accentForeground(const QColor& accent, const bool& isActive); Q_INVOKABLE QColor accentForeground(const QColor &accent, const bool &isActive);
public Q_SLOTS: public Q_SLOTS:
void load() override; void load() override;

@ -92,10 +92,10 @@ void applyScheme(const QString &colorSchemePath, KConfig *configOutput, KConfig:
if (item == QStringLiteral("Colors:Selection") && hasAccent()) { if (item == QStringLiteral("Colors:Selection") && hasAccent()) {
QColor accentbg = accentBackground(getAccent(), config->group("Colors:View").readEntry<QColor>("BackgroundNormal", QColor())); 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); 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)); 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()) { if (item == QStringLiteral("Colors:Header") && config->hasGroup(QStringLiteral("Colors:Header")) && hasAccent()) {
QColor accentbg = accentBackground(getAccent(), config->group("Colors:Window").readEntry<QColor>("BackgroundNormal", QColor())); QColor accentbg = accentBackground(getAccent(), config->group("Colors:Window").readEntry<QColor>("BackgroundNormal", QColor()));
if (accentActiveTitlebar) { if (accentActiveTitlebar) {
@ -120,7 +120,7 @@ void applyScheme(const QString &colorSchemePath, KConfig *configOutput, KConfig:
if (accentInactiveTitlebar) { if (accentInactiveTitlebar) {
targetGroup = targetGroup.group("Inactive"); targetGroup = targetGroup.group("Inactive");
targetGroup.writeEntry("BackgroundNormal", accentbg); 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; ++i;
} }
if (hasAccent()) { //Titlebar accent colouring if (hasAccent()) { // Titlebar accent colouring
QColor accentbg = accentBackground(getAccent(), config->group("Colors:Window").readEntry<QColor>("BackgroundNormal", QColor())); QColor accentbg = accentBackground(getAccent(), config->group("Colors:Window").readEntry<QColor>("BackgroundNormal", QColor()));
if (accentActiveTitlebar) { if (accentActiveTitlebar) {
groupWMOut.writeEntry("activeBackground", accentbg); groupWMOut.writeEntry("activeBackground", accentbg);
@ -157,11 +157,10 @@ void applyScheme(const QString &colorSchemePath, KConfig *configOutput, KConfig:
} }
if (accentInactiveTitlebar) { if (accentInactiveTitlebar) {
groupWMOut.writeEntry("inactiveBackground", accentbg); 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 groupNameList{QStringLiteral("ColorEffects:Inactive"), QStringLiteral("ColorEffects:Disabled")};
const QStringList effectList{QStringLiteral("Enable"), const QStringList effectList{QStringLiteral("Enable"),

@ -10,8 +10,8 @@
#include <QColor> #include <QColor>
#include <QString> #include <QString>
#include <KConfig>
#include <KColorUtils> #include <KColorUtils>
#include <KConfig>
inline QColor alphaBlend(const QColor &foreground, const QColor &background) 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) { if (backgroundAlpha == 1.0) {
return QColor::fromRgb( return QColor::fromRgb((foregroundAlpha * foreground.red()) + (inverseForegroundAlpha * background.red()),
(foregroundAlpha*foreground.red()) + (inverseForegroundAlpha*background.red()), (foregroundAlpha * foreground.green()) + (inverseForegroundAlpha * background.green()),
(foregroundAlpha*foreground.green()) + (inverseForegroundAlpha*background.green()), (foregroundAlpha * foreground.blue()) + (inverseForegroundAlpha * background.blue()),
(foregroundAlpha*foreground.blue()) + (inverseForegroundAlpha*background.blue()), 0xff);
0xff
);
} else { } else {
const auto inverseBackgroundAlpha = (backgroundAlpha * inverseForegroundAlpha); const auto inverseBackgroundAlpha = (backgroundAlpha * inverseForegroundAlpha);
const auto finalAlpha = foregroundAlpha + inverseBackgroundAlpha; const auto finalAlpha = foregroundAlpha + inverseBackgroundAlpha;
Q_ASSERT(finalAlpha != 0.0); Q_ASSERT(finalAlpha != 0.0);
return QColor::fromRgb( return QColor::fromRgb((foregroundAlpha * foreground.red()) + (inverseBackgroundAlpha * background.red()),
(foregroundAlpha*foreground.red()) + (inverseBackgroundAlpha*background.red()), (foregroundAlpha * foreground.green()) + (inverseBackgroundAlpha * background.green()),
(foregroundAlpha*foreground.green()) + (inverseBackgroundAlpha*background.green()), (foregroundAlpha * foreground.blue()) + (inverseBackgroundAlpha * background.blue()),
(foregroundAlpha*foreground.blue()) + (inverseBackgroundAlpha*background.blue()), finalAlpha);
finalAlpha
);
} }
} }
inline QColor accentBackground(const QColor& accent, const QColor& background) inline QColor accentBackground(const QColor &accent, const QColor &background)
{ {
auto c = accent; auto c = accent;
// light bg // light bg
if (KColorUtils::luma(background) > 0.5) { if (KColorUtils::luma(background) > 0.5) {
c.setAlphaF(0.7); c.setAlphaF(0.7);
} else { } else {
// dark bg // dark bg
c.setAlphaF(0.4); c.setAlphaF(0.4);
} }
return alphaBlend(c, background); 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); auto c = QColor(Qt::white);
// light bg // light bg
if (KColorUtils::luma(accent) > 0.5) { if (KColorUtils::luma(accent) > 0.5) {
c = QColor(Qt::black); c = QColor(Qt::black);
} else { } else {
// dark bg // dark bg
c = QColor(Qt::white); c = QColor(Qt::white);
} }

@ -35,7 +35,6 @@ Q_SIGNALS:
private Q_SLOTS: private Q_SLOTS:
void on_buttonBox_clicked(QAbstractButton *button); void on_buttonBox_clicked(QAbstractButton *button);
void updateTabs(bool byUser = false); void updateTabs(bool byUser = false);

Loading…
Cancel
Save