diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index a2d5a5719..910adc637 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -80,6 +80,10 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *pa connect(m_appletScriptEngine, &DeclarativeAppletScript::contextChanged, this, &AppletInterface::contextChanged); + if (applet()->containment()) { + connect(applet()->containment(), &Plasma::Containment::screenChanged, + this, &ContainmentInterface::screenChanged); + } m_qmlObject = new QmlObject(this); m_qmlObject->setInitializationDelayed(true); @@ -597,6 +601,15 @@ Plasma::Types::ItemStatus AppletInterface::status() const return applet()->status(); } +int AppletInterface::screen() const +{ + if (applet()->containment()) { + return applet()->containment()->screen(); + } + + return -1; +} + QString AppletInterface::downloadPath(const QString &file) { const QString downloadDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/Plasma/" + applet()->pluginInfo().pluginName() + '/'; diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index 74a6cb4de..99ea927b1 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -71,6 +71,12 @@ class AppletInterface : public QQuickItem Q_PROPERTY(Plasma::Types::ItemStatus status READ status WRITE setStatus NOTIFY statusChanged) Q_PROPERTY(QString associatedApplication WRITE setAssociatedApplication READ associatedApplication) + // TODO: This was moved up from ContainmentInterface because it is required by the + // Task Manager applet (for "Show only tasks from this screen") and no Qt API exposes + // screen numbering. An alternate solution that doesn't extend the applet interface + // would be preferrable if found. + Q_PROPERTY(int screen READ screen NOTIFY screenChanged) + //Size hints Note that the containments may chose to not respect them. Q_PROPERTY(qreal minimumWidth READ minimumWidth NOTIFY minimumWidthChanged) Q_PROPERTY(qreal minimumHeight READ minimumHeight NOTIFY minimumHeightChanged) @@ -149,6 +155,8 @@ public: void setStatus(const Plasma::Types::ItemStatus &status); Plasma::Types::ItemStatus status() const; + int screen() const; + QString activeConfig() const; void setActiveConfig(const QString &name); @@ -179,6 +187,7 @@ Q_SIGNALS: void backgroundHintsChanged(); void busyChanged(); void expandedChanged(); + void screenChanged(); void minimumWidthChanged(); void minimumHeightChanged(); diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index b90bada74..814cc20ea 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -63,8 +63,6 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent) this, &ContainmentInterface::appletRemovedForward); connect(containment(), &Plasma::Containment::appletAdded, this, &ContainmentInterface::appletAddedForward); - connect(containment(), &Plasma::Containment::screenChanged, - this, &ContainmentInterface::screenChanged); connect(containment(), &Plasma::Containment::activityChanged, this, &ContainmentInterface::activityChanged); connect(containment(), &Plasma::Containment::wallpaperChanged, @@ -127,11 +125,6 @@ void ContainmentInterface::setContainmentType(Plasma::Types::ContainmentType typ m_appletScriptEngine->setContainmentType(type); } -int ContainmentInterface::screen() const -{ - return containment()->screen(); -} - void ContainmentInterface::lockWidgets(bool locked) { containment()->setImmutability(!locked ? Plasma::Types::Mutable : Plasma::Types::UserImmutable); diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h index 81cc7ae83..4a2f3d85c 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.h +++ b/src/scriptengines/qml/plasmoid/containmentinterface.h @@ -40,7 +40,6 @@ class ContainmentInterface : public AppletInterface Q_PROPERTY(QList applets READ applets NOTIFY appletsChanged) Q_PROPERTY(bool drawWallpaper READ drawWallpaper WRITE setDrawWallpaper) Q_PROPERTY(Plasma::Types::ContainmentType containmentType READ containmentType WRITE setContainmentType) - Q_PROPERTY(int screen READ screen NOTIFY screenChanged) Q_PROPERTY(QString activity READ activity NOTIFY activityChanged) public: @@ -57,7 +56,6 @@ public: bool drawWallpaper(); Plasma::Types::ContainmentType containmentType() const; void setContainmentType(Plasma::Types::ContainmentType type); - int screen() const; QString activity() const; @@ -78,7 +76,6 @@ protected: Q_SIGNALS: void appletAdded(QObject *applet, int x, int y); void appletRemoved(QObject *applet); - void screenChanged(); void activityChanged(); void availableScreenRegionChanged(); void appletsChanged();