diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp index 8dc928251..cfa21ba9a 100644 --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -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; } diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp index 6bffd26a6..06949a6ba 100644 --- a/src/plasma/theme.cpp +++ b/src/plasma/theme.cpp @@ -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; }