From bdf92099bbc6f4262dd05915088c8185450dc799 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 25 Jun 2022 10:00:13 +0300 Subject: [PATCH] plasmatheme:for defaults settings use real mask --follow the new panel background way to access its mask and use it also for both the blur area and mask area when they are really needed. Such a case in only when the user has requested for plasma theme default settings BUG:455567 --- app/view/effects.cpp | 69 ++++++++----------- app/view/effects.h | 11 ++- .../package/contents/ui/BindingsExternal.qml | 7 ++ .../contents/ui/background/MultiLayered.qml | 3 + 4 files changed, 48 insertions(+), 42 deletions(-) diff --git a/app/view/effects.cpp b/app/view/effects.cpp index d82732f67..ffb80ad8a 100644 --- a/app/view/effects.cpp +++ b/app/view/effects.cpp @@ -91,17 +91,6 @@ void Effects::init() connect(m_view, &Latte::View::layoutChanged, this, &Effects::onPopUpMarginChanged); connect(&m_theme, &Plasma::Theme::themeChanged, this, [&]() { - auto background = m_background; - m_background = new Plasma::FrameSvg(this); - - if (background) { - background->deleteLater(); - } - - if (m_background->imagePath() != "widgets/panel-background") { - m_background->setImagePath(QStringLiteral("widgets/panel-background")); - } - updateBackgroundContrastValues(); updateEffects(); }); @@ -353,21 +342,28 @@ void Effects::setAppletsLayoutGeometry(const QRect &geom) emit appletsLayoutGeometryChanged(); } -void Effects::onPopUpMarginChanged() +QQuickItem *Effects::panelBackgroundSvg() const { - m_view->setProperty("_applets_popup_margin", QVariant(popUpMargin())); + return m_panelBackgroundSvg; } -void Effects::forceMaskRedraw() +void Effects::setPanelBackgroundSvg(QQuickItem *quickitem) { - if (m_background) { - delete m_background; + if (m_panelBackgroundSvg == quickitem) { + return; } - m_background = new Plasma::FrameSvg(this); - m_background->setImagePath(QStringLiteral("widgets/panel-background")); - m_background->setEnabledBorders(m_enabledBorders); + m_panelBackgroundSvg = quickitem; + emit panelBackgroundSvgChanged(); +} + +void Effects::onPopUpMarginChanged() +{ + m_view->setProperty("_applets_popup_margin", QVariant(popUpMargin())); +} +void Effects::forceMaskRedraw() +{ updateMask(); } @@ -499,21 +495,14 @@ void Effects::updateMask() //! rounded corners to be shown correctly //! the enabledBorders check was added because there was cases //! that the mask region wasn't calculated correctly after location changes - if (!m_background) { - if (m_background && m_background->enabledBorders() != m_enabledBorders) { - delete m_background; - } - - m_background = new Plasma::FrameSvg(this); + if (!m_panelBackgroundSvg) { + return; } - if (m_background->imagePath() != "widgets/panel-background") { - m_background->setImagePath(QStringLiteral("widgets/panel-background")); + const QVariant maskProperty = m_panelBackgroundSvg->property("mask"); + if (static_cast(maskProperty.type()) == QMetaType::QRegion) { + fixedMask = maskProperty.value(); } - - m_background->setEnabledBorders(m_enabledBorders); - m_background->resizeFrame(maskRect.size()); - fixedMask = m_background->mask(); } fixedMask.translate(maskRect.x(), maskRect.y()); @@ -564,18 +553,18 @@ void Effects::updateEffects() //! this is used when compositing is disabled and provides //! the correct way for the mask to be painted in order for //! rounded corners to be shown correctly - if (!m_background) { - m_background = new Plasma::FrameSvg(this); + if (!m_panelBackgroundSvg) { + return; } - if (m_background->imagePath() != "widgets/panel-background") { - m_background->setImagePath(QStringLiteral("widgets/panel-background")); + if (m_rect == VisibilityManager::ISHIDDENMASK) { + clearEffects = true; + } else { + const QVariant maskProperty = m_panelBackgroundSvg->property("mask"); + if (static_cast(maskProperty.type()) == QMetaType::QRegion) { + backMask = maskProperty.value(); + } } - - m_background->setEnabledBorders(m_enabledBorders); - m_background->resizeFrame(m_rect.size()); - - backMask = m_background->mask(); } //! adjust mask coordinates based on local coordinates diff --git a/app/view/effects.h b/app/view/effects.h index 4a2bde1d1..814cd57b4 100644 --- a/app/view/effects.h +++ b/app/view/effects.h @@ -52,6 +52,8 @@ class Effects: public QObject Q_PROPERTY(Plasma::FrameSvg::EnabledBorders enabledBorders READ enabledBorders NOTIFY enabledBordersChanged) + Q_PROPERTY(QQuickItem *panelBackgroundSvg READ panelBackgroundSvg WRITE setPanelBackgroundSvg NOTIFY panelBackgroundSvgChanged) + public: Effects(Latte::View *parent); virtual ~Effects(); @@ -102,6 +104,9 @@ public: Plasma::FrameSvg::EnabledBorders enabledBorders() const; + QQuickItem *panelBackgroundSvg() const; + void setPanelBackgroundSvg(QQuickItem *quickitem); + public slots: Q_INVOKABLE void forceMaskRedraw(); Q_INVOKABLE void setSubtractedMaskRegion(const QString ®ionid, const QRegion ®ion); @@ -130,6 +135,7 @@ signals: void maskChanged(); void innerShadowChanged(); void inputMaskChanged(); + void panelBackgroundSvgChanged(); void popUpMarginChanged(); void rectChanged(); @@ -185,12 +191,13 @@ private: PlasmaExtended::CornerRegions m_cornersMaskRegion; Plasma::Theme m_theme; - //only for the mask on disabled compositing, not to actually paint - Plasma::FrameSvg *m_background{nullptr}; //only for the mask, not to actually paint Plasma::FrameSvg::EnabledBorders m_enabledBorders{Plasma::FrameSvg::AllBorders}; + //assigned from qml side in order to access the official panel background svg + QQuickItem *m_panelBackgroundSvg{nullptr}; + //! Subtracted and United Mask regions QHash m_subtractedMaskRegions; QHash m_unitedMaskRegions; diff --git a/containment/package/contents/ui/BindingsExternal.qml b/containment/package/contents/ui/BindingsExternal.qml index 328457ad1..fb83d41c4 100644 --- a/containment/package/contents/ui/BindingsExternal.qml +++ b/containment/package/contents/ui/BindingsExternal.qml @@ -224,6 +224,13 @@ Item { value: background.shadows.headThickness } + Binding{ + target: latteView && latteView.effects ? latteView.effects : null + property: "panelBackgroundSvg" + when: latteView && latteView.effects + value: background.panelBackgroundSvg + } + Binding{ target: latteView && latteView.effects ? latteView.effects : null property:"appletsLayoutGeometry" diff --git a/containment/package/contents/ui/background/MultiLayered.qml b/containment/package/contents/ui/background/MultiLayered.qml index 608a4ab39..6efed163c 100644 --- a/containment/package/contents/ui/background/MultiLayered.qml +++ b/containment/package/contents/ui/background/MultiLayered.qml @@ -22,6 +22,8 @@ import "../colorizer" as Colorizer BackgroundProperties{ id:barLine + readonly property alias panelBackgroundSvg: solidBackground + //! Layer 0: Multi-Layer container in order to provide a consistent final element that acts //! as a single entity/background width: root.isHorizontal ? totals.visualLength : 16 @@ -312,6 +314,7 @@ BackgroundProperties{ onXChanged: solidBackground.updateEffectsArea(); onYChanged: solidBackground.updateEffectsArea(); + onScreenEdgeMarginChanged: solidBackground.updateEffectsArea(); //! Layer 1: Shadows that are drawn around the background but always inside the View window (these are internal drawn shadows). //! When the container has chosen external shadows (these are shadows that are drawn out of the View window from the compositor)