Make it possible for an applet to offer a test object
Makes it possible for plasmoids to test themselves in the different shells by providing API to extract the object that will test the plasmoid instance. REVIEW: 127345
This commit is contained in:
parent
23d020c797
commit
c23f2415bb
@ -43,6 +43,7 @@ namespace Plasma
|
|||||||
void ChangeableMainScriptPackage::initPackage(KPackage::Package *package)
|
void ChangeableMainScriptPackage::initPackage(KPackage::Package *package)
|
||||||
{
|
{
|
||||||
package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml"), i18n("Main Script File"));
|
package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml"), i18n("Main Script File"));
|
||||||
|
package->addFileDefinition("test", QStringLiteral("tests/test.qml"), i18n("Tests"));
|
||||||
package->setRequired("mainscript", true);
|
package->setRequired("mainscript", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,6 +645,21 @@ QQmlComponent *AppletQuickItem::fullRepresentation()
|
|||||||
return d->fullRepresentation;
|
return d->fullRepresentation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject *AppletQuickItem::testItem()
|
||||||
|
{
|
||||||
|
if (!d->testItem) {
|
||||||
|
const QUrl url = QUrl::fromLocalFile(d->appletPackage.filePath("test"));
|
||||||
|
if (url.isEmpty()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->testItem = d->qmlObject->createObjectFromSource(url, QtQml::qmlContext(rootItem()));
|
||||||
|
d->testItem->setProperty("plasmoidItem", QVariant::fromValue<QObject*>(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
return d->testItem;
|
||||||
|
}
|
||||||
|
|
||||||
void AppletQuickItem::setFullRepresentation(QQmlComponent *component)
|
void AppletQuickItem::setFullRepresentation(QQmlComponent *component)
|
||||||
{
|
{
|
||||||
if (d->fullRepresentation == component) {
|
if (d->fullRepresentation == component) {
|
||||||
|
@ -105,6 +105,7 @@ public:
|
|||||||
QQuickItem *compactRepresentationItem();
|
QQuickItem *compactRepresentationItem();
|
||||||
QQuickItem *fullRepresentationItem();
|
QQuickItem *fullRepresentationItem();
|
||||||
QObject *rootItem();
|
QObject *rootItem();
|
||||||
|
QObject *testItem();
|
||||||
|
|
||||||
////PROPERTY ACCESSORS
|
////PROPERTY ACCESSORS
|
||||||
int switchWidth() const;
|
int switchWidth() const;
|
||||||
|
@ -90,6 +90,7 @@ public:
|
|||||||
QPointer<QQuickItem> fullRepresentationItem;
|
QPointer<QQuickItem> fullRepresentationItem;
|
||||||
QPointer<QQuickItem> compactRepresentationExpanderItem;
|
QPointer<QQuickItem> compactRepresentationExpanderItem;
|
||||||
QPointer<QQuickItem> currentRepresentationItem;
|
QPointer<QQuickItem> currentRepresentationItem;
|
||||||
|
QPointer<QObject> testItem;
|
||||||
|
|
||||||
//Attached layout objects: own and the representation's one
|
//Attached layout objects: own and the representation's one
|
||||||
QPointer<QObject> representationLayout;
|
QPointer<QObject> representationLayout;
|
||||||
|
Loading…
Reference in New Issue
Block a user