make the plasmoid object accessible

This commit is contained in:
Marco Martin 2013-02-04 20:28:41 +01:00
parent feec1a5b40
commit b4669ab783
6 changed files with 28 additions and 8 deletions

View File

@ -24,6 +24,8 @@
#include <QAction>
#include <QDir>
#include <QFile>
#include <QQmlEngine>
#include <QQmlComponent>
#include <QScriptEngine>
#include <QSignalMapper>
#include <QTimer>
@ -46,6 +48,7 @@ AppletInterface::AppletInterface(AbstractJsAppletScript *parent)
m_appletScriptEngine(parent),
m_actionSignals(0)
{
qmlRegisterType<AppletInterface>();
connect(this, SIGNAL(releaseVisualFocus()), applet(), SIGNAL(releaseVisualFocus()));
connect(this, SIGNAL(configNeedsSaving()), applet(), SIGNAL(configNeedsSaving()));
connect(applet(), SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)), this, SIGNAL(immutableChanged()));
@ -388,6 +391,7 @@ ContainmentInterface::ContainmentInterface(AbstractJsAppletScript *parent)
: APPLETSUPERCLASS(parent),
m_movableApplets(true)
{
qmlRegisterType<ContainmentInterface>();
connect(containment(), SIGNAL(appletRemoved(Plasma::Applet *)), this, SLOT(appletRemovedForward(Plasma::Applet *)));
connect(containment(), SIGNAL(appletAdded(Plasma::Applet *, const QPointF &)), this, SLOT(appletAddedForward(Plasma::Applet *, const QPointF &)));

View File

@ -278,6 +278,8 @@ ScriptEnv *DeclarativeAppletScript::scriptEnv()
void DeclarativeAppletScript::setupObjects()
{
m_qmlObject->engine()->rootContext()->setContextProperty("plasmoid", m_interface);
#if 0
TODO: make this work with QQmlEngine
m_engine = m_qmlObject->scriptEngine();

View File

@ -53,9 +53,9 @@ void DesktopCorona::loadDefaultLayout()
Plasma::Containment *cont = addContainment("org.kde.testcontainment");
cont->setScreen(0);
qDebug() << containmentForScreen(0);
//Plasma::Applet *appl = cont->addApplet("foo");
Plasma::Applet *appl = cont->addApplet("foo");
qDebug() << "Containment:" << cont << cont->name();
//qDebug() << "Applet:" << appl->name() << appl;
qDebug() << "Applet:" << appl->name() << appl;
}
void DesktopCorona::checkScreens(bool signalWhenExists)

View File

@ -36,5 +36,7 @@ Rectangle {
containment.anchors.fill = root
}
Component.onCompleted: print("View QML loaded")
Component.onCompleted: {
print("View QML loaded")
}
}

View File

@ -55,10 +55,15 @@ Rectangle {
//Behavior on y { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } }
Behavior on height { PropertyAnimation { easing.type: Easing.InOutDouble; duration: 300 } }
Text {
id: txt
text: "Click or Drag";
Column {
anchors.centerIn: parent
Text {
id: txt
text: "Click or Drag";
}
Text {
text: plasmoid
}
}
PlasmaCore.SvgItem {
svg: actionssvg
@ -88,5 +93,11 @@ Rectangle {
Rectangle { color: "white"; opacity: 0.2; anchors.fill: parent; }
}
Component.onCompleted: print("Test Containment loaded")
Component.onCompleted: {
print("Test Containment loaded")
print(plasmoid)
for (var i in plasmoid) {
print(i+" "+plasmoid[i])
}
}
}

View File

@ -20,6 +20,7 @@
#include <QDebug>
#include <QQuickItem>
#include <QQmlContext>
#include <QTimer>
#include "plasma/pluginloader.h"
@ -35,7 +36,7 @@ View::View(QWindow *parent)
setResizeMode(View::SizeRootObjectToView);
setSource(QUrl::fromLocalFile(m_package.filePath("mainscript")));
show();
show();rootContext()->setContextProperty("plasmoid", this);
}
View::~View()