Do background contrast fallback at runtime
When a theme doesn't supply background contrast values, we take an educated guess based on whether it's a dark or light theme. We didn't update the values when switching only color schemes at runtime (when theme follows it). This lead to washed out Plasma popup and panel backgrounds. Instead, compute the fallback value at runtime. Also, while at it, update complimentary colorscheme as well, which was forgotten here. BUG: 401142 Differential Revision: https://phabricator.kde.org/D18487
This commit is contained in:
parent
dda4edcc6e
commit
7ca1f01ea9
@ -71,9 +71,9 @@ ThemePrivate::ThemePrivate(QObject *parent)
|
|||||||
useGlobal(true),
|
useGlobal(true),
|
||||||
hasWallpapers(false),
|
hasWallpapers(false),
|
||||||
fixedName(false),
|
fixedName(false),
|
||||||
backgroundContrast(0),
|
backgroundContrast(qQNaN()),
|
||||||
backgroundIntensity(0),
|
backgroundIntensity(qQNaN()),
|
||||||
backgroundSaturation(0),
|
backgroundSaturation(qQNaN()),
|
||||||
backgroundContrastEnabled(true),
|
backgroundContrastEnabled(true),
|
||||||
apiMajor(1),
|
apiMajor(1),
|
||||||
apiMinor(0),
|
apiMinor(0),
|
||||||
@ -728,23 +728,9 @@ void ThemePrivate::processContrastSettings(KConfigBase *metadata)
|
|||||||
cg = KConfigGroup(metadata, "ContrastEffect");
|
cg = KConfigGroup(metadata, "ContrastEffect");
|
||||||
backgroundContrastEnabled = cg.readEntry("enabled", false);
|
backgroundContrastEnabled = cg.readEntry("enabled", false);
|
||||||
|
|
||||||
//if (backgroundContrastEnabled) {
|
backgroundContrast = cg.readEntry("contrast", qQNaN());
|
||||||
// Make up sensible default values, based on the background color
|
backgroundIntensity = cg.readEntry("intensity", qQNaN());
|
||||||
// This works for a light theme -- lighting up the background
|
backgroundSaturation = cg.readEntry("saturation", qQNaN());
|
||||||
qreal _contrast = 0.3;
|
|
||||||
qreal _intensity = 1.9;
|
|
||||||
qreal _saturation = 1.7;
|
|
||||||
|
|
||||||
// If we're using a dark background color, darken the background
|
|
||||||
if (qGray(color(Plasma::Theme::BackgroundColor).rgb()) < 127) {
|
|
||||||
_contrast = 0.45;
|
|
||||||
_intensity = 0.45;
|
|
||||||
_saturation = 1.7;
|
|
||||||
}
|
|
||||||
backgroundContrast = cg.readEntry("contrast", _contrast);
|
|
||||||
backgroundIntensity = cg.readEntry("intensity", _intensity);
|
|
||||||
backgroundSaturation = cg.readEntry("saturation", _saturation);
|
|
||||||
//}
|
|
||||||
} else {
|
} else {
|
||||||
backgroundContrastEnabled = false;
|
backgroundContrastEnabled = false;
|
||||||
}
|
}
|
||||||
|
@ -477,16 +477,36 @@ bool Theme::backgroundContrastEnabled() const
|
|||||||
|
|
||||||
qreal Theme::backgroundContrast() const
|
qreal Theme::backgroundContrast() const
|
||||||
{
|
{
|
||||||
|
if (qIsNaN(d->backgroundContrast)) {
|
||||||
|
// Make up sensible default values, based on the background color
|
||||||
|
// If we're using a dark background color, darken the background
|
||||||
|
if (qGray(color(Plasma::Theme::BackgroundColor).rgb()) < 127) {
|
||||||
|
return 0.45;
|
||||||
|
// for a light theme lighten up the background
|
||||||
|
} else {
|
||||||
|
return 0.3;
|
||||||
|
}
|
||||||
|
}
|
||||||
return d->backgroundContrast;
|
return d->backgroundContrast;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal Theme::backgroundIntensity() const
|
qreal Theme::backgroundIntensity() const
|
||||||
{
|
{
|
||||||
|
if (qIsNaN(d->backgroundIntensity)) {
|
||||||
|
if (qGray(color(Plasma::Theme::BackgroundColor).rgb()) < 127) {
|
||||||
|
return 0.45;
|
||||||
|
} else {
|
||||||
|
return 1.9;
|
||||||
|
}
|
||||||
|
}
|
||||||
return d->backgroundIntensity;
|
return d->backgroundIntensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal Theme::backgroundSaturation() const
|
qreal Theme::backgroundSaturation() const
|
||||||
{
|
{
|
||||||
|
if (qIsNaN(d->backgroundSaturation)) {
|
||||||
|
return 1.7;
|
||||||
|
}
|
||||||
return d->backgroundSaturation;
|
return d->backgroundSaturation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user