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),
|
||||
hasWallpapers(false),
|
||||
fixedName(false),
|
||||
backgroundContrast(0),
|
||||
backgroundIntensity(0),
|
||||
backgroundSaturation(0),
|
||||
backgroundContrast(qQNaN()),
|
||||
backgroundIntensity(qQNaN()),
|
||||
backgroundSaturation(qQNaN()),
|
||||
backgroundContrastEnabled(true),
|
||||
apiMajor(1),
|
||||
apiMinor(0),
|
||||
@ -728,23 +728,9 @@ void ThemePrivate::processContrastSettings(KConfigBase *metadata)
|
||||
cg = KConfigGroup(metadata, "ContrastEffect");
|
||||
backgroundContrastEnabled = cg.readEntry("enabled", false);
|
||||
|
||||
//if (backgroundContrastEnabled) {
|
||||
// Make up sensible default values, based on the background color
|
||||
// This works for a light theme -- lighting up the background
|
||||
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);
|
||||
//}
|
||||
backgroundContrast = cg.readEntry("contrast", qQNaN());
|
||||
backgroundIntensity = cg.readEntry("intensity", qQNaN());
|
||||
backgroundSaturation = cg.readEntry("saturation", qQNaN());
|
||||
} else {
|
||||
backgroundContrastEnabled = false;
|
||||
}
|
||||
|
@ -477,16 +477,36 @@ bool Theme::backgroundContrastEnabled() 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
qreal Theme::backgroundSaturation() const
|
||||
{
|
||||
if (qIsNaN(d->backgroundSaturation)) {
|
||||
return 1.7;
|
||||
}
|
||||
return d->backgroundSaturation;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user