Commit dca34e52 authored by Ismael Asensio's avatar Ismael Asensio
Browse files

kcms/colors: Small code Cosmetic changes

- Apply clang-format
- Rename property to not look like a verb
- Use new connection syntax
parent 6e7a147e
Pipeline #178955 passed with stage
in 10 minutes and 35 seconds
......@@ -114,10 +114,9 @@ QColor KCMColors::accentColor() const
return color;
}
QColor KCMColors::tinted(const QColor& color, const QColor& accent, bool tints, qreal tintFactor)
QColor KCMColors::tinted(const QColor &color, const QColor &accent, bool tints, qreal tintFactor)
{
if (accent == QColor(Qt::transparent) || !tints)
{
if (accent == QColor(Qt::transparent) || !tints) {
return color;
}
return tintColor(color, accentColor(), tintFactor);
......@@ -129,11 +128,12 @@ void KCMColors::setAccentColor(const QColor &accentColor)
Q_EMIT settingsChanged();
}
bool KCMColors::applyAccentColorFromWallpaper() const
bool KCMColors::accentColorFromWallpaper() const
{
return colorsSettings()->accentColorFromWallpaper();
}
void KCMColors::setApplyAccentColorFromWallpaper(bool boolean)
void KCMColors::setAccentColorFromWallpaper(bool boolean)
{
if (boolean == colorsSettings()->accentColorFromWallpaper()) {
return;
......@@ -142,7 +142,7 @@ void KCMColors::setApplyAccentColorFromWallpaper(bool boolean)
applyWallpaperAccentColor();
}
colorsSettings()->setAccentColorFromWallpaper(boolean);
Q_EMIT applyAccentColorFromWallpaperChanged();
Q_EMIT accentColorFromWallpaperChanged();
Q_EMIT settingsChanged();
}
......@@ -361,7 +361,7 @@ void KCMColors::load()
loadSelectedColorScheme();
Q_EMIT applyAccentColorFromWallpaperChanged();
Q_EMIT accentColorFromWallpaperChanged();
Q_EMIT accentColorChanged();
// If need save is true at the end of load() function, it will stay disabled forever.
......@@ -406,7 +406,7 @@ void KCMColors::saveColors()
auto setGlobals = [=]() {
globalConfig->group("General").writeEntry("AccentColor", QColor());
globalConfig->group("General").writeEntry("accentColorFromWallpaper", applyAccentColorFromWallpaper(), KConfig::Notify);
globalConfig->group("General").writeEntry("accentColorFromWallpaper", accentColorFromWallpaper(), KConfig::Notify);
if (accentColor() != QColor(Qt::transparent)) {
globalConfig->group("General").writeEntry("AccentColor", accentColor(), KConfig::Notify);
} else {
......@@ -437,7 +437,7 @@ void KCMColors::applyWallpaperAccentColor()
QDBusPendingCall async = connection.asyncCall(accentColor);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), this, SLOT(wallpaperAccentColorArrivedSlot(QDBusPendingCallWatcher *)));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &KCMColors::wallpaperAccentColorArrivedSlot);
}
void KCMColors::wallpaperAccentColorArrivedSlot(QDBusPendingCallWatcher *call)
......
......@@ -43,8 +43,7 @@ class KCMColors : public KQuickAddons::ManagedConfigModule
Q_PROPERTY(ColorsSettings *colorsSettings READ colorsSettings CONSTANT)
Q_PROPERTY(bool downloadingFile READ downloadingFile NOTIFY downloadingFileChanged)
Q_PROPERTY(QColor accentColor READ accentColor WRITE setAccentColor NOTIFY accentColorChanged)
Q_PROPERTY(bool applyAccentColorFromWallpaper READ applyAccentColorFromWallpaper WRITE setApplyAccentColorFromWallpaper NOTIFY
applyAccentColorFromWallpaperChanged)
Q_PROPERTY(bool accentColorFromWallpaper READ accentColorFromWallpaper WRITE setAccentColorFromWallpaper NOTIFY accentColorFromWallpaperChanged)
public:
KCMColors(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
......@@ -70,9 +69,9 @@ public:
void resetAccentColor();
Q_SIGNAL void accentColorChanged();
bool applyAccentColorFromWallpaper() const;
void setApplyAccentColorFromWallpaper(bool boolean);
Q_SIGNAL void applyAccentColorFromWallpaperChanged();
bool accentColorFromWallpaper() const;
void setAccentColorFromWallpaper(bool boolean);
Q_SIGNAL void accentColorFromWallpaperChanged();
Q_INVOKABLE void installSchemeFromFile(const QUrl &url);
......@@ -80,7 +79,7 @@ public:
// we take an extraneous reference to the accent colour here in order to have the bindings
// re-evaluate when it changes
Q_INVOKABLE QColor tinted(const QColor& color, const QColor& accent, bool tints, qreal tintFactor);
Q_INVOKABLE QColor tinted(const QColor &color, const QColor &accent, bool tints, qreal tintFactor);
Q_INVOKABLE QColor accentBackground(const QColor &accent, const QColor &background);
Q_INVOKABLE QColor accentForeground(const QColor &accent, const bool &isActive);
......
......@@ -154,11 +154,11 @@ KCM.GridViewKCM {
QtControls.RadioButton {
id: wallpaperAccentBox
text: i18nc("@option:radio wallpaper accent color option", "From current wallpaper")
checked: kcm.applyAccentColorFromWallpaper
checked: kcm.accentColorFromWallpaper
onToggled: {
if (checked) {
kcm.applyAccentColorFromWallpaper = true;
kcm.accentColorFromWallpaper = true;
}
}
}
......@@ -167,7 +167,7 @@ KCM.GridViewKCM {
spacing: 0
QtControls.RadioButton {
id: accentBox
checked: !Qt.colorEqual(kcm.accentColor, "transparent") && !kcm.applyAccentColorFromWallpaper
checked: !Qt.colorEqual(kcm.accentColor, "transparent") && !kcm.accentColorFromWallpaper
onToggled: {
if (checked) {
......@@ -264,7 +264,7 @@ KCM.GridViewKCM {
ColorRadioButton {
id: customColorIndicator
readonly property bool isCustomColor: !kcm.applyAccentColorFromWallpaper
readonly property bool isCustomColor: !kcm.accentColorFromWallpaper
&& !Qt.colorEqual(kcm.accentColor, "transparent")
&& !colorRepeater.model.some(color => Qt.colorEqual(color, root.accentColor))
......@@ -321,7 +321,7 @@ KCM.GridViewKCM {
Kirigami.Theme.inherit: false
Kirigami.Theme.highlightColor: root.accentColor || model.palette.highlight
Kirigami.Theme.textColor: kcm.tinted(model.palette.text, kcm.accentColor, model.tints, model.tintFactor)
Kirigami.Theme.textColor: kcm.tinted(model.palette.text, kcm.accentColor, model.tints, model.tintFactor)
Rectangle {
id: windowTitleBar
......
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