From 4d4db0b199780d8e3a94594fb72739565cd3919d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Venerandi?= Date: Mon, 1 Mar 2021 22:25:52 +0000 Subject: [PATCH] Use adaptive transparency and tweak contrast effect to make better use of it --- .../breeze-dark/metadata.desktop.cmake | 9 +- .../breeze-light/metadata.desktop.cmake | 9 +- src/desktoptheme/breeze/CMakeLists.txt | 6 + .../breeze/metadata.desktop.cmake | 8 +- .../breeze/solid/dialogs/background.svg | 1733 +++++++++++++++++ .../breeze/solid/widgets/panel-background.svg | 1057 ++++++++++ .../breeze/translucent/dialogs/background.svg | 18 +- .../translucent/widgets/panel-background.svg | 132 +- .../breeze/translucent/widgets/tooltip.svg | 18 +- .../breeze/widgets/panel-background.svg | 16 +- .../breeze/widgets/plasmoidheading.svg | 36 +- src/plasma/private/theme_p.cpp | 14 + src/plasma/private/theme_p.h | 2 + src/plasma/theme.cpp | 5 + src/plasma/theme.h | 15 + src/plasmaquick/dialog.cpp | 16 +- src/plasmaquick/dialog.h | 3 +- 17 files changed, 2973 insertions(+), 124 deletions(-) create mode 100644 src/desktoptheme/breeze/solid/dialogs/background.svg create mode 100644 src/desktoptheme/breeze/solid/widgets/panel-background.svg diff --git a/src/desktoptheme/breeze-dark/metadata.desktop.cmake b/src/desktoptheme/breeze-dark/metadata.desktop.cmake index 0cc9fa5bc..f26ef6f59 100644 --- a/src/desktoptheme/breeze-dark/metadata.desktop.cmake +++ b/src/desktoptheme/breeze-dark/metadata.desktop.cmake @@ -102,6 +102,9 @@ defaultHeight=1080 [ContrastEffect] enabled=true -contrast=0.2 -intensity=0.4 -saturation=1.7 +contrast=0.17 +intensity=1.25 +saturation=9 + +[AdaptiveTransparency] +enabled=true diff --git a/src/desktoptheme/breeze-light/metadata.desktop.cmake b/src/desktoptheme/breeze-light/metadata.desktop.cmake index 607d74b27..0c6326cf1 100644 --- a/src/desktoptheme/breeze-light/metadata.desktop.cmake +++ b/src/desktoptheme/breeze-light/metadata.desktop.cmake @@ -100,6 +100,9 @@ defaultHeight=1080 [ContrastEffect] enabled=true -contrast=0.2 -intensity=2.0 -saturation=1.7 +contrast=0.17 +intensity=1.25 +saturation=9 + +[AdaptiveTransparency] +enabled=true diff --git a/src/desktoptheme/breeze/CMakeLists.txt b/src/desktoptheme/breeze/CMakeLists.txt index 6e50dcfb8..69d08bf7f 100644 --- a/src/desktoptheme/breeze/CMakeLists.txt +++ b/src/desktoptheme/breeze/CMakeLists.txt @@ -28,6 +28,12 @@ plasma_install_desktoptheme_svgs(default SUBPATH translucent/widgets FILES ${tra FILE(GLOB translucent_dialogs translucent/dialogs/*.svg) plasma_install_desktoptheme_svgs(default SUBPATH translucent/dialogs FILES ${translucent_dialogs}) +FILE(GLOB solid_widgets solid/widgets/*.svg) +plasma_install_desktoptheme_svgs(default SUBPATH solid/widgets FILES ${solid_widgets}) + +FILE(GLOB solid_dialogs solid/dialogs/*.svg) +plasma_install_desktoptheme_svgs(default SUBPATH solid/dialogs FILES ${solid_dialogs}) + FILE(GLOB icons icons/*.svg) plasma_install_desktoptheme_svgs(default SUBPATH icons FILES ${icons}) diff --git a/src/desktoptheme/breeze/metadata.desktop.cmake b/src/desktoptheme/breeze/metadata.desktop.cmake index 88a49e742..ad2e28c79 100644 --- a/src/desktoptheme/breeze/metadata.desktop.cmake +++ b/src/desktoptheme/breeze/metadata.desktop.cmake @@ -102,6 +102,8 @@ defaultHeight=1080 [ContrastEffect] enabled=true contrast=0.2 -#intensity is disabled, in order to auto adjust to the chosen theme color -#intensity=2.0 -saturation=1.7 +intensity=1.4 +saturation=10 + +[AdaptiveTransparency] +enabled=true diff --git a/src/desktoptheme/breeze/solid/dialogs/background.svg b/src/desktoptheme/breeze/solid/dialogs/background.svg new file mode 100644 index 000000000..87f5df11f --- /dev/null +++ b/src/desktoptheme/breeze/solid/dialogs/background.svg @@ -0,0 +1,1733 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/desktoptheme/breeze/solid/widgets/panel-background.svg b/src/desktoptheme/breeze/solid/widgets/panel-background.svg new file mode 100644 index 000000000..bc2418e1d --- /dev/null +++ b/src/desktoptheme/breeze/solid/widgets/panel-background.svg @@ -0,0 +1,1057 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/desktoptheme/breeze/translucent/dialogs/background.svg b/src/desktoptheme/breeze/translucent/dialogs/background.svg index e438ef104..705006f6e 100644 --- a/src/desktoptheme/breeze/translucent/dialogs/background.svg +++ b/src/desktoptheme/breeze/translucent/dialogs/background.svg @@ -943,14 +943,14 @@ height="32" width="6" id="rect4152" - style="opacity:0.6;fill:currentColor;fill-opacity:1;stroke:none" + style="opacity:0.85;fill:currentColor;fill-opacity:1;stroke:none" transform="matrix(0,-1,-1,0,0,0)" class="ColorScheme-Background" /> @@ -1005,7 +1005,7 @@ id="left"> - - + + - - + + - - + + - - + + - + - + - + - + - - - - + + + + - - - - + + + + - + - + - - - - + + + + - - - - + + + + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - - - + + + + - - + + diff --git a/src/desktoptheme/breeze/translucent/widgets/tooltip.svg b/src/desktoptheme/breeze/translucent/widgets/tooltip.svg index 0ea962612..2ae80ac19 100644 --- a/src/desktoptheme/breeze/translucent/widgets/tooltip.svg +++ b/src/desktoptheme/breeze/translucent/widgets/tooltip.svg @@ -947,7 +947,7 @@ height="32" width="6" id="rect4152" - style="opacity:0.6;fill:currentColor;fill-opacity:1;stroke:none" + style="opacity:0.85;fill:currentColor;fill-opacity:1;stroke:none" transform="matrix(0,-1,-1,0,0,0)" class="ColorScheme-Background" /> @@ -956,7 +956,7 @@ id="bottom"> diff --git a/src/desktoptheme/breeze/widgets/panel-background.svg b/src/desktoptheme/breeze/widgets/panel-background.svg index 03d2e5ce6..d4b976aa2 100644 --- a/src/desktoptheme/breeze/widgets/panel-background.svg +++ b/src/desktoptheme/breeze/widgets/panel-background.svg @@ -200,10 +200,10 @@ - - - - + + + + @@ -225,10 +225,10 @@ - - - - + + + + diff --git a/src/desktoptheme/breeze/widgets/plasmoidheading.svg b/src/desktoptheme/breeze/widgets/plasmoidheading.svg index fe4fcae9b..fe4b6d39b 100644 --- a/src/desktoptheme/breeze/widgets/plasmoidheading.svg +++ b/src/desktoptheme/breeze/widgets/plasmoidheading.svg @@ -6,42 +6,42 @@ color:#eff0f1; } - - - + + + - + - + - + - + - - - - - + + + + + - + - + - + - + - - + + diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp index 7871717b3..cbcab7f36 100644 --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -63,6 +63,7 @@ ThemePrivate::ThemePrivate(QObject *parent) backgroundIntensity(qQNaN()), backgroundSaturation(qQNaN()), backgroundContrastEnabled(true), + adaptiveTransparencyEnabled(false), blurBehindEnabled(true), apiMajor(1), apiMinor(0), @@ -753,6 +754,18 @@ void ThemePrivate::processContrastSettings(KConfigBase *metadata) } } + +void ThemePrivate::processAdaptiveTransparencySettings(KConfigBase *metadata) +{ + KConfigGroup cg; + if (metadata->hasGroup("AdaptiveTransparency")) { + cg = KConfigGroup(metadata, "ContrastEffect"); + adaptiveTransparencyEnabled = cg.readEntry("enabled", false); + } else { + adaptiveTransparencyEnabled = false; + } +} + void ThemePrivate::processBlurBehindSettings(KConfigBase *metadata) { KConfigGroup cg; @@ -832,6 +845,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings processContrastSettings(&metadata); processBlurBehindSettings(&metadata); + processAdaptiveTransparencySettings(&metadata); processWallpaperSettings(&metadata); diff --git a/src/plasma/private/theme_p.h b/src/plasma/private/theme_p.h index 3117f8a40..a419ee658 100644 --- a/src/plasma/private/theme_p.h +++ b/src/plasma/private/theme_p.h @@ -64,6 +64,7 @@ public: void setThemeName(const QString &themeName, bool writeSettings, bool emitChanged); void processWallpaperSettings(KConfigBase *metadata); void processContrastSettings(KConfigBase *metadata); + void processAdaptiveTransparencySettings(KConfigBase *metadata); void processBlurBehindSettings(KConfigBase *metadata); const QString processStyleSheet(const QString &css, Plasma::Svg::Status status); @@ -142,6 +143,7 @@ public: qreal backgroundIntensity; qreal backgroundSaturation; bool backgroundContrastEnabled; + bool adaptiveTransparencyEnabled; bool blurBehindEnabled; //Version number of Plasma the Theme has been designed for diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp index 75e02221d..e5450e08d 100644 --- a/src/plasma/theme.cpp +++ b/src/plasma/theme.cpp @@ -414,6 +414,11 @@ bool Theme::backgroundContrastEnabled() const return d->backgroundContrastEnabled; } +bool Theme::adaptiveTransparencyEnabled() const +{ + return d->adaptiveTransparencyEnabled; +} + qreal Theme::backgroundContrast() const { if (qIsNaN(d->backgroundContrast)) { diff --git a/src/plasma/theme.h b/src/plasma/theme.h index 03acdb0ce..c8a40a071 100644 --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -366,6 +366,21 @@ public: */ bool backgroundContrastEnabled() const; + /** This method allows Plasma to enable and disable the adaptive + * transparency option of the panel, which allows user to decide + * whether the panel should be always transparent, always opaque + * or only opaque when a window is maximized. + * The configuration in the metadata.desktop file of the theme + * could look like this (for a lighter background): + * \code + * [AdaptiveTransparency] + * enabled=true + * \endcode + * @return Whether or not to enable the adaptive transparency + * @since 5.20 + */ + bool adaptiveTransparencyEnabled() const; + /** This method allows Plasma to set a background contrast effect * for a given theme, improving readability. The value is read * from the "contrast" key in the "ContrastEffect" group in the diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index fc8c490cd..e6955a075 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -228,10 +228,14 @@ void DialogPrivate::updateTheme() q->setMask(QRegion()); DialogShadows::self()->removeWindow(q); } else { + auto prefix = QStringLiteral(""); + if ((backgroundHints & Dialog::SolidBackground) == Dialog::SolidBackground) { + prefix = QStringLiteral("solid/"); + } if (type == Dialog::Tooltip) { - frameSvgItem->setImagePath(QStringLiteral("widgets/tooltip")); + frameSvgItem->setImagePath(prefix + QStringLiteral("widgets/tooltip")); } else { - frameSvgItem->setImagePath(QStringLiteral("dialogs/background")); + frameSvgItem->setImagePath(prefix + QStringLiteral("dialogs/background")); } KWindowEffects::enableBlurBehind(q->winId(), theme.blurBehindEnabled(), frameSvgItem->mask()); @@ -758,10 +762,14 @@ void DialogPrivate::applyType() if (backgroundHints == Dialog::NoBackground) { frameSvgItem->setImagePath(QString()); } else { + auto prefix = QStringLiteral(""); + if ((backgroundHints & Dialog::SolidBackground) == Dialog::SolidBackground) { + prefix = QStringLiteral("solid/"); + } if (type == Dialog::Tooltip) { - frameSvgItem->setImagePath(QStringLiteral("widgets/tooltip")); + frameSvgItem->setImagePath(prefix + QStringLiteral("widgets/tooltip")); } else { - frameSvgItem->setImagePath(QStringLiteral("dialogs/background")); + frameSvgItem->setImagePath(prefix + QStringLiteral("dialogs/background")); } } diff --git a/src/plasmaquick/dialog.h b/src/plasmaquick/dialog.h index 3e3552fb2..5f03cd7a6 100644 --- a/src/plasmaquick/dialog.h +++ b/src/plasmaquick/dialog.h @@ -159,7 +159,8 @@ public: enum BackgroundHints { NoBackground = 0, /**< Not drawing a background under the applet, the dialog has its own implementation */ - StandardBackground = 1 /**< The standard background from the theme is drawn */ + StandardBackground = 1, /**< The standard background from the theme is drawn */ + SolidBackground = 2, /**< The solid version of the background is preferred */ }; Q_ENUM(BackgroundHints)