diff --git a/src/declarativeimports/core/colorscope.cpp b/src/declarativeimports/core/colorscope.cpp index 0726d71f5..98ff3abe7 100644 --- a/src/declarativeimports/core/colorscope.cpp +++ b/src/declarativeimports/core/colorscope.cpp @@ -34,9 +34,10 @@ ColorScope::ColorScope(QQuickItem *parent, QObject *parentObject) { connect(&m_theme, &Plasma::Theme::themeChanged, this, &ColorScope::colorsChanged); - if (parent) { - connect(parent, &QQuickItem::parentChanged, this, &ColorScope::colorGroupChanged); - connect(parent, &QQuickItem::parentChanged, this, &ColorScope::colorsChanged); + QQuickItem *parentItem = qobject_cast(parentObject); + if (parentItem) { + connect(parentItem, &QQuickItem::parentChanged, this, &ColorScope::colorGroupChanged); + connect(parentItem, &QQuickItem::parentChanged, this, &ColorScope::colorsChanged); } } @@ -47,18 +48,15 @@ ColorScope::~ColorScope() ColorScope *ColorScope::qmlAttachedProperties(QObject *object) { - QQuickItem *qp = qobject_cast(object); - if (ColorScope::s_attachedScopes.contains(object)) { return s_attachedScopes.value(object); } - ColorScope *s = new ColorScope(qp, object); + ColorScope *s = new ColorScope(0, object); s_attachedScopes[object] = s; - if (!qp) { - s->setParent(object); - } + s->setParent(object); + s->m_inherit = true; return s; } @@ -180,14 +178,5 @@ void ColorScope::itemChange(ItemChange change, const ItemChangeData &value) QQuickItem::itemChange(change, value); } -bool ColorScope::event(QEvent *event) -{ - if (event->type() == QEvent::ParentChange) { - emit colorGroupChanged(); - emit colorsChanged(); - } - - return QQuickItem::event(event); -} #include "moc_colorscope.cpp" diff --git a/src/declarativeimports/core/colorscope.h b/src/declarativeimports/core/colorscope.h index 696a84740..38e7cc8f8 100644 --- a/src/declarativeimports/core/colorscope.h +++ b/src/declarativeimports/core/colorscope.h @@ -79,9 +79,6 @@ public: ColorScope *findParentScope() const; void itemChange(ItemChange change, const ItemChangeData &value); -protected: - bool event(QEvent *event); - Q_SIGNALS: void colorGroupChanged(); void colorsChanged();