Commit a8d8e8ed authored by Tanbir Jishan's avatar Tanbir Jishan Committed by Nate Graham
Browse files

kcms/colors: Show last-used custom accent color when clicking custom color checkbox

Right now it opens the color picker dialog with the current first accent color.
Remembering the user's prior custom accent color (if any) is nicer.

BUG: 455894
FIXED-IN: 5.26
parent 923ce7e5
Pipeline #197133 passed with stage
in 7 minutes and 33 seconds
......@@ -147,6 +147,19 @@ void KCMColors::setAccentColorFromWallpaper(bool boolean)
Q_EMIT settingsChanged();
}
QColor KCMColors::lastUsedCustomAccentColor() const
{
return colorsSettings()->lastUsedCustomAccentColor();
}
void KCMColors::setLastUsedCustomAccentColor(const QColor &accentColor)
{
if (accentColor == QColor(Qt::transparent)) {
return;
}
colorsSettings()->setLastUsedCustomAccentColor(accentColor);
Q_EMIT lastUsedCustomAccentColorChanged();
Q_EMIT settingsChanged();
}
bool KCMColors::downloadingFile() const
{
return m_tempCopyJob;
......
......@@ -42,6 +42,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(QColor lastUsedCustomAccentColor READ lastUsedCustomAccentColor WRITE setLastUsedCustomAccentColor NOTIFY lastUsedCustomAccentColorChanged)
Q_PROPERTY(bool accentColorFromWallpaper READ accentColorFromWallpaper WRITE setAccentColorFromWallpaper NOTIFY accentColorFromWallpaperChanged)
public:
......@@ -68,6 +69,10 @@ public:
void resetAccentColor();
Q_SIGNAL void accentColorChanged();
QColor lastUsedCustomAccentColor() const;
void setLastUsedCustomAccentColor(const QColor &accentColor);
Q_SIGNAL void lastUsedCustomAccentColorChanged();
bool accentColorFromWallpaper() const;
void setAccentColorFromWallpaper(bool boolean);
Q_SIGNAL void accentColorFromWallpaperChanged();
......
......@@ -13,6 +13,10 @@
<label>Accent color</label>
<default>transparent</default>
</entry>
<entry name="lastUsedCustomAccentColor" key="LastUsedCustomAccentColor" type="Color">
<label>The last used custom accent color before user switched to wallpaper generated color or default color</label>
<default>transparent</default>
</entry>
<entry name="accentColorFromWallpaper" key="accentColorFromWallpaper" type="Bool">
<label>Whether accent color from wallpaper should be applied</label>
<default>false</default>
......
......@@ -174,7 +174,7 @@ KCM.GridViewKCM {
onToggled: {
if (checked) {
kcm.accentColorFromWallpaper = false;
kcm.accentColor = colorRepeater.model[0]
kcm.accentColor = Qt.colorEqual(kcm.lastUsedCustomAccentColor, "transparent") ? colorRepeater.model[0] : kcm.lastUsedCustomAccentColor
}
}
}
......@@ -237,6 +237,7 @@ KCM.GridViewKCM {
onToggled: {
kcm.accentColorFromWallpaper = false;
kcm.accentColor = modelData
kcm.lastUsedCustomAccentColor = modelData
checked = Qt.binding(() => Qt.colorEqual(kcm.accentColor, modelData));
}
}
......@@ -254,9 +255,10 @@ KCM.GridViewKCM {
title: i18n("Choose custom accent color")
// User must either choose a colour or cancel the operation before doing something else
modality: Qt.ApplicationModal
color: kcm.accentColor
color: Qt.colorEqual(kcm.lastUsedCustomAccentColor, "transparent") ? kcm.accentColor : kcm.lastUsedCustomAccentColor
onAccepted: {
kcm.accentColor = colorDialog.color
kcm.lastUsedCustomAccentColor = colorDialog.color
kcm.accentColorFromWallpaper = false
}
}
......
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