From 57fdb56790817ef46c87086bc10fa7c764ee7dbc Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 29 Nov 2019 10:21:56 +0100 Subject: [PATCH] support for user removing background and automatic shadow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: add the ability for the user to override the background hints anddecide about applets having background or a shadow A new handle button will be added to manually enable/disable background for plasmoids that support it if they don't, the ImmutableBackground flag is set in the hints. PlasmaCore.ColorScope has been expanded to work more like Kirigami.Theme (which will be replaced by) even if it's oòld behavior still works. This makes the complementary colorscope in applets with shadow actually work (and at the same time gives a clearer porting path for kf6) Test Plan: Tested the functionality and correct save/restore Reviewers: #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: davidedmundson, ndavis, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D25590 --- src/declarativeimports/core/colorscope.cpp | 59 +++++++--------- src/declarativeimports/core/colorscope.h | 2 - .../breeze/widgets/configuration-icons.svg | 69 +++++++++++++++---- src/plasma/plasma.h | 6 +- .../qml/plasmoid/appletinterface.cpp | 56 +++++++++++++++ .../qml/plasmoid/appletinterface.h | 19 +++++ 6 files changed, 161 insertions(+), 50 deletions(-) diff --git a/src/declarativeimports/core/colorscope.cpp b/src/declarativeimports/core/colorscope.cpp index 9bd951807..8892d6bca 100644 --- a/src/declarativeimports/core/colorscope.cpp +++ b/src/declarativeimports/core/colorscope.cpp @@ -25,6 +25,8 @@ #include #include +#include + QHash ColorScope::s_attachedScopes = QHash(); QWeakPointer ColorScope::s_theme; @@ -47,11 +49,12 @@ ColorScope::ColorScope(QQuickItem *parent, QObject *parentObject) connect(this, &ColorScope::colorGroupChanged, this, &ColorScope::colorsChanged); - QQuickItem *parentItem = qobject_cast(parentObject); - if (parentItem) { - connect(parentItem, &QQuickItem::parentChanged, this, &ColorScope::checkColorGroupChanged); - } else if (m_parent) { - m_parent->installEventFilter(this); + if (parentObject && qobject_cast(parentObject)) { + connect(static_cast(parentObject), &QQuickItem::parentChanged, + this, &ColorScope::checkColorGroupChanged); + } else if (parent) { + connect(parent, &QQuickItem::parentChanged, + this, &ColorScope::checkColorGroupChanged); } } @@ -76,15 +79,6 @@ ColorScope *ColorScope::qmlAttachedProperties(QObject *object) return s; } -bool ColorScope::eventFilter(QObject* watched, QEvent* event) -{ - Q_ASSERT(watched == m_parent && !qobject_cast(watched)); - if (event->type() == QEvent::ParentChange) { - checkColorGroupChanged(); - } - return QQuickItem::eventFilter(watched, event); -} - void ColorScope::setParentScope(ColorScope* parentScope) { if (parentScope == m_parentScope) @@ -105,29 +99,24 @@ void ColorScope::setParentScope(ColorScope* parentScope) ColorScope *ColorScope::findParentScope() { - QObject *p = nullptr; - if (m_parent) { - QQuickItem *gp = qobject_cast(m_parent); - if (gp) { - p = gp->parentItem(); - } else { - p = m_parent->parent(); + QQuickItem *candidate = qobject_cast(parentItem()); + if (!candidate) { + candidate = qobject_cast(parent()); + } + while (candidate) { + candidate = candidate->parentItem(); + ColorScope *s = qobject_cast(candidate); + if (!s) { + // Make sure AppletInterface always has a ColorScope + s = static_cast(qmlAttachedPropertiesObject(candidate, qobject_cast(candidate))); + } + + if (s) { + setParentScope(s); + return s; } } - - if (!p || !m_parent) { - setParentScope(nullptr); - return nullptr; - } - - ColorScope *c = qobject_cast(p); - if (!c) { - c = qmlAttachedProperties(p); - } - - setParentScope(c); - - return m_parentScope; + return nullptr; } void ColorScope::setColorGroup(Plasma::Theme::ColorGroup group) diff --git a/src/declarativeimports/core/colorscope.h b/src/declarativeimports/core/colorscope.h index 3c4709aeb..4d0dcdce4 100644 --- a/src/declarativeimports/core/colorscope.h +++ b/src/declarativeimports/core/colorscope.h @@ -119,8 +119,6 @@ public: ColorScope *findParentScope(); void itemChange(ItemChange change, const ItemChangeData &value) override; - bool eventFilter(QObject * watched, QEvent * event) override; - Q_SIGNALS: void colorGroupChanged(); void colorsChanged(); diff --git a/src/desktoptheme/breeze/widgets/configuration-icons.svg b/src/desktoptheme/breeze/widgets/configuration-icons.svg index 1285f317f..bdbaa7a2f 100644 --- a/src/desktoptheme/breeze/widgets/configuration-icons.svg +++ b/src/desktoptheme/breeze/widgets/configuration-icons.svg @@ -14,8 +14,8 @@ viewBox="0 0 32.808331 13.758333" id="svg2" version="1.1" - inkscape:version="0.48.5 r10040" - sodipodi:docname="configuration-icons.svgz"> + inkscape:version="0.92.2 5c3e80d, 2017-08-06" + sodipodi:docname="configuration-icons.svg">