From da6b8c10c1d61db004b6d616fca22bde4c1aae6f Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 3 Dec 2020 13:53:40 +0000 Subject: [PATCH] properly forward containmentDisplayHintsChanged make possible to write containmentDisplayHintsChanged from ContainmentInterface QML when containmentDisplayHintsChanged, the containment forwards to all its applets --- src/plasma/containment.cpp | 2 ++ src/scriptengines/qml/plasmoid/containmentinterface.cpp | 6 ++++++ src/scriptengines/qml/plasmoid/containmentinterface.h | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index 2e899531c..c446c2f88 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -407,6 +407,7 @@ void Containment::addApplet(Applet *applet) emit currentContainment->appletRemoved(applet); disconnect(applet, nullptr, currentContainment, nullptr); + connect(currentContainment, nullptr, applet, nullptr); KConfigGroup oldConfig = applet->config(); currentContainment->d->applets.removeAll(applet); applet->setParent(this); @@ -449,6 +450,7 @@ void Containment::addApplet(Applet *applet) connect(applet, SIGNAL(appletDeleted(Plasma::Applet*)), this, SLOT(appletDeleted(Plasma::Applet*))); connect(applet, SIGNAL(statusChanged(Plasma::Types::ItemStatus)), this, SLOT(checkStatus(Plasma::Types::ItemStatus))); connect(applet, &Applet::activated, this, &Applet::activated); + connect(this, &Containment::containmentDisplayHintsChanged, applet, &Applet::containmentDisplayHintsChanged); if (!currentContainment) { const bool isNew = applet->d->mainConfigGroup()->entryMap().isEmpty(); diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 78ea7e41d..badb3ad8b 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -872,6 +872,12 @@ QList ContainmentInterface::actions() const return actionList; } +void ContainmentInterface::setContainmentDisplayHints(Plasma::Types::ContainmentDisplayHints hints) +{ + m_containment->setContainmentDisplayHints(hints); +} + + //PROTECTED-------------------- void ContainmentInterface::mouseReleaseEvent(QMouseEvent *event) diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h index 97ab02ca7..e891a2e99 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.h +++ b/src/scriptengines/qml/plasmoid/containmentinterface.h @@ -75,6 +75,8 @@ class ContainmentInterface : public AppletInterface */ Q_PROPERTY(bool editMode READ isEditMode WRITE setEditMode NOTIFY editModeChanged) + Q_PROPERTY(Plasma::Types::ContainmentDisplayHints containmentDisplayHints READ containmentDisplayHints WRITE setContainmentDisplayHints NOTIFY containmentDisplayHintsChanged) + public: ContainmentInterface(DeclarativeAppletScript *parent, const QVariantList &args = QVariantList()); @@ -100,6 +102,8 @@ public: QList actions() const; + void setContainmentDisplayHints(Plasma::Types::ContainmentDisplayHints hints); + /** * Process the mime data arrived to a particular coordinate, either with a drag and drop or paste with middle mouse button */