From 4535ee03c2b63389aa0e851ae5a73d38c82c5f5b Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 14 Jun 2019 16:21:46 +0300 Subject: [PATCH] REAL maxOpacity from plasma panel backgrounds --Plasma::ExtendedTheme class now provides maximum opacity provided by panel backgrounds --- app/plasma/extended/theme.cpp | 36 ++++++++++++++++++++++++++++++----- app/plasma/extended/theme.h | 17 +++++++++++++---- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/app/plasma/extended/theme.cpp b/app/plasma/extended/theme.cpp index 021ef2bb4..1792e3fe5 100644 --- a/app/plasma/extended/theme.cpp +++ b/app/plasma/extended/theme.cpp @@ -144,9 +144,24 @@ void Theme::setOutlineWidth(int width) emit outlineWidthChanged(); } -float Theme::backgroundMaxOpacity() const +float Theme::bottomEdgeMaxOpacity() const { - return m_backgroundMaxOpacity; + return m_bottomEdgeMaxOpacity; +} + +float Theme::leftEdgeMaxOpacity() const +{ + return m_leftEdgeMaxOpacity; +} + +float Theme::topEdgeMaxOpacity() const +{ + return m_topEdgeMaxOpacity; +} + +float Theme::rightEdgeMaxOpacity() const +{ + return m_rightEdgeMaxOpacity; } WindowSystem::SchemeColors *Theme::defaultTheme() const @@ -315,6 +330,16 @@ int Theme::roundness(const QImage &svgImage, Plasma::Types::Location edge) int maxOpacity = qMin(qAlpha(svgImage.pixel(49,0)), 200); + if (edge == Plasma::Types::BottomEdge) { + m_bottomEdgeMaxOpacity = (float)maxOpacity / (float)255; + } else if (edge == Plasma::Types::LeftEdge) { + m_leftEdgeMaxOpacity = (float)maxOpacity / (float)255; + } else if (edge == Plasma::Types::TopEdge) { + m_topEdgeMaxOpacity = (float)maxOpacity / (float)255; + } else if (edge == Plasma::Types::RightEdge) { + m_rightEdgeMaxOpacity = (float)maxOpacity / (float)255; + } + if (edge == Plasma::Types::BottomEdge || edge == Plasma::Types::RightEdge || edge == Plasma::Types::TopEdge) { //! TOPLEFT corner //! first LEFT pixel found @@ -412,6 +437,7 @@ void Theme::loadRoundness() { loadCompositingRoundness(); + emit maxOpacityChanged(); emit roundnessChanged(); } @@ -564,12 +590,12 @@ void Theme::parseThemeSvgFiles() } } - m_backgroundMaxOpacity = opacity * fillOpacity; + // m_backgroundMaxOpacity = opacity * fillOpacity; - qDebug() << "plasma theme opacity :: " << m_backgroundMaxOpacity << " from : " << opacity << " * " << fillOpacity; + // qDebug() << "plasma theme opacity :: " << m_backgroundMaxOpacity << " from : " << opacity << " * " << fillOpacity; } - emit backgroundMaxOpacityChanged(); + // emit backgroundMaxOpacityChanged(); } void Theme::loadThemeLightness() diff --git a/app/plasma/extended/theme.h b/app/plasma/extended/theme.h index ace3efb81..c73522993 100644 --- a/app/plasma/extended/theme.h +++ b/app/plasma/extended/theme.h @@ -60,7 +60,10 @@ class Theme: public QObject Q_PROPERTY(int outlineWidth READ outlineWidth NOTIFY outlineWidthChanged) - Q_PROPERTY(float backgroundMaxOpacity READ backgroundMaxOpacity NOTIFY backgroundMaxOpacityChanged) + Q_PROPERTY(float bottomEdgeMaxOpacity READ bottomEdgeMaxOpacity NOTIFY maxOpacityChanged) + Q_PROPERTY(float leftEdgeMaxOpacity READ leftEdgeMaxOpacity NOTIFY maxOpacityChanged) + Q_PROPERTY(float topEdgeMaxOpacity READ topEdgeMaxOpacity NOTIFY maxOpacityChanged) + Q_PROPERTY(float rightEdgeMaxOpacity READ rightEdgeMaxOpacity NOTIFY maxOpacityChanged) Q_PROPERTY(Latte::WindowSystem::SchemeColors *defaultTheme READ defaultTheme NOTIFY themeChanged) Q_PROPERTY(Latte::WindowSystem::SchemeColors *lightTheme READ lightTheme NOTIFY themeChanged) @@ -82,7 +85,10 @@ public: int outlineWidth() const; void setOutlineWidth(int width); - float backgroundMaxOpacity() const; + float bottomEdgeMaxOpacity() const; + float leftEdgeMaxOpacity() const; + float topEdgeMaxOpacity() const; + float rightEdgeMaxOpacity() const; WindowSystem::SchemeColors *defaultTheme() const; WindowSystem::SchemeColors *lightTheme() const; @@ -91,9 +97,9 @@ public: void load(); signals: - void backgroundMaxOpacityChanged(); void compositingChanged(); void hasShadowChanged(); + void maxOpacityChanged(); void outlineWidthChanged(); void roundnessChanged(); void themeChanged(); @@ -128,7 +134,10 @@ private: int m_outlineWidth{1}; - float m_backgroundMaxOpacity{1}; + float m_bottomEdgeMaxOpacity{1}; + float m_leftEdgeMaxOpacity{1}; + float m_topEdgeMaxOpacity{1}; + float m_rightEdgeMaxOpacity{1}; QString m_themePath; QString m_themeWidgetsPath;