diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index b8e1002ad..075fca70f 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -51,8 +51,9 @@ Q_DECLARE_METATYPE(AppletInterface *) -AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *parent) +AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariantList &args, QQuickItem *parent) : AppletQuickItem(script->applet(), parent), + m_args(args), m_actionSignals(0), m_appletScriptEngine(script), m_backgroundHints(Plasma::Types::StandardBackground), @@ -86,8 +87,9 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *pa } } -AppletInterface::AppletInterface(Plasma::Applet *a, QQuickItem *parent) +AppletInterface::AppletInterface(Plasma::Applet *a, const QVariantList &args, QQuickItem *parent) : AppletQuickItem(a, parent), + m_args(args), m_actionSignals(0), m_appletScriptEngine(0), m_backgroundHints(Plasma::Types::StandardBackground), @@ -151,6 +153,12 @@ void AppletInterface::init() i->forceActiveFocus(Qt::ShortcutFocusReason); } }); + + if (m_args.count() == 1) { + emit externalData(QString(), m_args.first()); + } else if (m_args.count() > 0) { + emit externalData(QString(), m_args); + } } Plasma::Types::FormFactor AppletInterface::formFactor() const diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index f839825d7..1092f0bce 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -166,8 +166,8 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem Q_PROPERTY(QKeySequence globalShortcut READ globalShortcut WRITE setGlobalShortcut NOTIFY globalShortcutChanged) public: - AppletInterface(DeclarativeAppletScript *script, QQuickItem *parent = 0); - AppletInterface(Plasma::Applet *applet, QQuickItem *parent = 0); + AppletInterface(DeclarativeAppletScript *script, const QVariantList &args = QVariantList(), QQuickItem *parent = 0); + AppletInterface(Plasma::Applet *applet, const QVariantList &args = QVariantList(), QQuickItem *parent = 0); ~AppletInterface(); //API not intended for the QML part @@ -332,6 +332,7 @@ private: QString m_toolTipMainText; QString m_toolTipSubText; + QVariantList m_args; Plasma::Types::BackgroundHints m_backgroundHints; bool m_busy : 1; bool m_hideOnDeactivate : 1; diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 481855899..69f8b20a9 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -52,8 +52,8 @@ #include "kdeclarative/configpropertymap.h" #include -ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent) - : AppletInterface(parent), +ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent, const QVariantList &args) + : AppletInterface(parent, args), m_wallpaperInterface(0), m_activityInfo(0) { @@ -505,7 +505,7 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet) << "Applet: " << applet << applet->title() << appletGraphicObject; if (!appletGraphicObject) { - appletGraphicObject = new AppletInterface(applet, this); + appletGraphicObject = new AppletInterface(applet, QVariantList(), this); applet->setProperty("_plasma_graphicObject", QVariant::fromValue(appletGraphicObject)); static_cast(appletGraphicObject)->init(); } diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h index cca5cfb04..d8f818f18 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.h +++ b/src/scriptengines/qml/plasmoid/containmentinterface.h @@ -70,7 +70,8 @@ class ContainmentInterface : public AppletInterface Q_PROPERTY(QList actions READ actions NOTIFY actionsChanged) public: - ContainmentInterface(DeclarativeAppletScript *parent); + ContainmentInterface(DeclarativeAppletScript *parent, const QVariantList &args = QVariantList()); + //Not for QML Plasma::Containment *containment() const { diff --git a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp index faf617449..04273e97d 100644 --- a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp +++ b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp @@ -82,19 +82,14 @@ bool DeclarativeAppletScript::init() Plasma::Containment *pc = qobject_cast(a); if (pc && pc->isContainment()) { - m_interface = new ContainmentInterface(this); + m_interface = new ContainmentInterface(this, m_args); //fail? so it's a normal Applet } else { - m_interface = new AppletInterface(this); + m_interface = new AppletInterface(this, m_args); } m_interface->setParent(this); - if (m_args.count() == 1) { - emit m_interface->externalData(QString(), m_args.first()); - } else if (m_args.count() > 0) { - emit m_interface->externalData(QString(), m_args); - } return true; }