diff --git a/kcms/colors/colors.cpp b/kcms/colors/colors.cpp index 04db87410..da5796400 100644 --- a/kcms/colors/colors.cpp +++ b/kcms/colors/colors.cpp @@ -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); } diff --git a/kcms/colors/colors.h b/kcms/colors/colors.h index 743e1d44f..d056600d7 100644 --- a/kcms/colors/colors.h +++ b/kcms/colors/colors.h @@ -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; diff --git a/kcms/colors/colorsapplicator.cpp b/kcms/colors/colorsapplicator.cpp index 79ea76e08..740ebfc90 100644 --- a/kcms/colors/colorsapplicator.cpp +++ b/kcms/colors/colorsapplicator.cpp @@ -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("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("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("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"), diff --git a/kcms/colors/colorsapplicator.h b/kcms/colors/colorsapplicator.h index 78808ce28..b691cae16 100644 --- a/kcms/colors/colorsapplicator.h +++ b/kcms/colors/colorsapplicator.h @@ -10,8 +10,8 @@ #include #include -#include #include +#include 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); } diff --git a/kcms/colors/editor/scmeditordialog.h b/kcms/colors/editor/scmeditordialog.h index 7da0ee7a0..dd0b101ff 100644 --- a/kcms/colors/editor/scmeditordialog.h +++ b/kcms/colors/editor/scmeditordialog.h @@ -35,7 +35,6 @@ Q_SIGNALS: private Q_SLOTS: - void on_buttonBox_clicked(QAbstractButton *button); void updateTabs(bool byUser = false);