diff --git a/app/plasma/extended/panelbackground.cpp b/app/plasma/extended/panelbackground.cpp index 99a271fb1..a3d64ac48 100644 --- a/app/plasma/extended/panelbackground.cpp +++ b/app/plasma/extended/panelbackground.cpp @@ -20,6 +20,9 @@ #include "panelbackground.h" +// local +#include "theme.h" + // Qt #include #include @@ -31,9 +34,10 @@ namespace Latte { namespace PlasmaExtended { -PanelBackground::PanelBackground(Plasma::Types::Location edge, QObject *parent) +PanelBackground::PanelBackground(Plasma::Types::Location edge, Theme *parent) : QObject(parent), - m_location(edge) + m_location(edge), + m_parentTheme(parent) { } @@ -143,35 +147,6 @@ void PanelBackground::updatePaddings(Plasma::Svg *svg) emit paddingsChanged(); } -bool PanelBackground::hasVisibleShadow(Plasma::Svg *svg) const -{ - if (!svg || !svg->hasElement("shadow-topleft")) { - return false; - } - - QString cornerId = "shadow-topleft"; - QImage corner = svg->image(svg->elementSize(cornerId), cornerId); - - int fullTransparentPixels = 0; - - for(int c=0; chasShadow()) { qDebug() << "PLASMA THEME, calculating roundness from shadows..."; updateRoundnessFromShadows(svg); } else { diff --git a/app/plasma/extended/panelbackground.h b/app/plasma/extended/panelbackground.h index 4eb5b1ede..75bc37f38 100644 --- a/app/plasma/extended/panelbackground.h +++ b/app/plasma/extended/panelbackground.h @@ -28,6 +28,12 @@ #include #include +namespace Latte { +namespace PlasmaExtended { +class Theme; +} +} + namespace Latte { namespace PlasmaExtended { @@ -44,7 +50,7 @@ class PanelBackground: public QObject Q_PROPERTY(float maxOpacity READ maxOpacity NOTIFY maxOpacityChanged) public: - PanelBackground(Plasma::Types::Location edge, QObject *parent); + PanelBackground(Plasma::Types::Location edge, Theme *parent); ~PanelBackground(); int paddingTop() const; @@ -65,8 +71,6 @@ signals: void maxOpacityChanged(); private: - bool hasVisibleShadow(Plasma::Svg *svg) const; - QString prefixed(const QString &id); QString element(Plasma::Svg *svg, const QString &id); @@ -89,6 +93,7 @@ private: Plasma::Types::Location m_location{Plasma::Types::BottomEdge}; + Theme *m_parentTheme{nullptr}; }; } diff --git a/app/plasma/extended/theme.cpp b/app/plasma/extended/theme.cpp index 4c65b27de..6d2942903 100644 --- a/app/plasma/extended/theme.cpp +++ b/app/plasma/extended/theme.cpp @@ -82,7 +82,6 @@ Theme::Theme(KSharedConfig::Ptr config, QObject *parent) : connect(this, &Theme::compositingChanged, this, &Theme::updateBackgrounds); connect(this, &Theme::outlineWidthChanged, this, &Theme::saveConfig); - connect(&m_theme, &Plasma::Theme::themeChanged, this, &Theme::hasShadowChanged); connect(&m_theme, &Plasma::Theme::themeChanged, this, &Theme::load); connect(&m_theme, &Plasma::Theme::themeChanged, this, &Theme::themeChanged); } @@ -103,7 +102,7 @@ Theme::~Theme() bool Theme::hasShadow() const { - return PanelShadows::self()->hasShadows(); + return m_hasShadow; } bool Theme::isLightTheme() const @@ -310,12 +309,46 @@ void Theme::updateReversedSchemeValues() void Theme::updateBackgrounds() { + updateHasShadow(); + m_backgroundTopEdge->update(); m_backgroundLeftEdge->update(); m_backgroundBottomEdge->update(); m_backgroundRightEdge->update(); } +void Theme::updateHasShadow() +{ + Plasma::Svg *svg = new Plasma::Svg(this); + svg->setImagePath(QStringLiteral("widgets/panel-background")); + svg->resize(); + + QString cornerId = "shadow-topleft"; + QImage corner = svg->image(svg->elementSize(cornerId), cornerId); + + int fullTransparentPixels = 0; + + for(int c=0; cdeleteLater(); +} + void Theme::loadThemePaths() { m_themePath = Layouts::Importer::standardPath("plasma/desktoptheme/" + m_theme.themeName()); diff --git a/app/plasma/extended/theme.h b/app/plasma/extended/theme.h index 3b5bd3105..42ca9fd99 100644 --- a/app/plasma/extended/theme.h +++ b/app/plasma/extended/theme.h @@ -110,6 +110,7 @@ private: void updateBackgrounds(); void setOriginalSchemeFile(const QString &file); + void updateHasShadow(); void updateDefaultScheme(); void updateDefaultSchemeValues(); void updateReversedScheme(); @@ -118,6 +119,7 @@ private: void qmlRegisterTypes(); private: + bool m_hasShadow{false}; bool m_isLightTheme{false}; bool m_compositing{true}; diff --git a/shell/package/contents/configuration/pages/AppearanceConfig.qml b/shell/package/contents/configuration/pages/AppearanceConfig.qml index edfc7ee1f..5a0495363 100644 --- a/shell/package/contents/configuration/pages/AppearanceConfig.qml +++ b/shell/package/contents/configuration/pages/AppearanceConfig.qml @@ -1035,7 +1035,7 @@ PlasmaComponents.Page { text: i18n("Shadows") checked: plasmoid.configuration.panelShadows checkable: true - enabled: showBackground.checked && LatteCore.WindowSystem.compositingActive + enabled: showBackground.checked && LatteCore.WindowSystem.compositingActive && themeExtended.hasShadow tooltip: i18n("Background shows its shadows") onClicked: {