Add Theme::blurBehindEnabled()

Summary:
Allows themes to disable the blurring of what is behind panels,
if they either do not need it (being fully opaque) or by design want
non-blurry transparency.

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D19907
This commit is contained in:
Friedrich W. H. Kossebau 2019-03-20 11:01:27 +01:00
parent 349648c1e6
commit fb1a332948
5 changed files with 37 additions and 1 deletions

View File

@ -75,6 +75,7 @@ ThemePrivate::ThemePrivate(QObject *parent)
backgroundIntensity(qQNaN()),
backgroundSaturation(qQNaN()),
backgroundContrastEnabled(true),
blurBehindEnabled(true),
apiMajor(1),
apiMinor(0),
apiRevision(0)
@ -736,6 +737,17 @@ void ThemePrivate::processContrastSettings(KConfigBase *metadata)
}
}
void ThemePrivate::processBlurBehindSettings(KConfigBase *metadata)
{
KConfigGroup cg;
if (metadata->hasGroup("BlurBehindEffect")) {
cg = KConfigGroup(metadata, "BlurBehindEffect");
blurBehindEnabled = cg.readEntry("enabled", true);
} else {
blurBehindEnabled = true;
}
}
void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings, bool emitChanged)
{
QString theme = tempThemeName;
@ -800,6 +812,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
pluginInfo = KPluginInfo(metadataPath);
processContrastSettings(&metadata);
processBlurBehindSettings(&metadata);
processWallpaperSettings(&metadata);

View File

@ -76,6 +76,7 @@ public:
void setThemeName(const QString &themeName, bool writeSettings, bool emitChanged);
void processWallpaperSettings(KConfigBase *metadata);
void processContrastSettings(KConfigBase *metadata);
void processBlurBehindSettings(KConfigBase *metadata);
const QString processStyleSheet(const QString &css, Plasma::Svg::Status status);
const QString svgStyleSheet(Plasma::Theme::ColorGroup group, Plasma::Svg::Status status);
@ -156,6 +157,7 @@ public:
qreal backgroundIntensity;
qreal backgroundSaturation;
bool backgroundContrastEnabled;
bool blurBehindEnabled;
//Version number of Plasma the Theme has been designed for
int apiMajor;

View File

@ -510,6 +510,11 @@ qreal Theme::backgroundSaturation() const
return d->backgroundSaturation;
}
bool Theme::blurBehindEnabled() const
{
return d->blurBehindEnabled;
}
}
#include "moc_theme.cpp"

View File

@ -380,6 +380,22 @@ public:
*/
qreal backgroundSaturation() const;
/** This method allows Plasma to enable and disable the blurring
* of what is behind the background for a given theme. The
* value is read from the "enabled" key in the "BlurBehindEffect"
* group in the Theme's metadata file. Default is @c true.
*
* The configuration in the metadata.desktop file of the theme
* could look like this:
* \code
* [BlurBehindEffect]
* enabled=false
* \endcode
* @return Whether or not to enable blurring of what is behind
* @since 5.57
*/
bool blurBehindEnabled() const;
/**
* Returns the size of the letter "M" as rendered on the screen with the given font.
* This values gives you a base size that:

View File

@ -241,7 +241,7 @@ void DialogPrivate::updateTheme()
frameSvgItem->setImagePath(QStringLiteral("dialogs/background"));
}
KWindowEffects::enableBlurBehind(q->winId(), true, frameSvgItem->frameSvg()->mask());
KWindowEffects::enableBlurBehind(q->winId(), theme.blurBehindEnabled(), frameSvgItem->frameSvg()->mask());
KWindowEffects::enableBackgroundContrast(q->winId(), theme.backgroundContrastEnabled(),
theme.backgroundContrast(),