Skip to content

Plugins

Olaf Japp edited this page Feb 11, 2021 · 8 revisions

From version 1.1.0 on you are able to create and load plugins to SHIFT. This possibility is a real amazing feature you can have because QML is really awesome ;-) At the moment there is only one function that we can call on the backend.

void HttpGet(QString url);

Where the result is stored into:

backend.result

Let us know if you require more native methods.

To create a plugin you have to create a new folder under the data directory /storage/emulated/0/crowdware/shift/plugins. In the following case I have created a folder named Diaspora. Inside of this directory I have created a plugin-description file named plugin.qml (this file should exactly be named like this).

import at.crowdware.backend 1.0

Plugin 
{
    title: "Diaspora"
    source: "file:///storage/emulated/0/crowdware/shift/plugins/Diaspora/diaspora.qml"
}

The plugin itself will also be stored in a QML file. I named it diaspora.qml for this example.

import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
import at.crowdware.backend 1.0

Page 
{
	id: page
	title: "Diaspora"

	Connections
	{
		target: backend
		onResultChanged: 
		{
			caption.text = backend.result;
		}
	}

	Text 
	{	
		id: caption	
		anchors.top: parent.top
		anchors.left: parent.left
		anchors.right: parent.right
	   	text: "DIASPORA is a sample plugin."
	   	font.pixelSize: page.height / 40
		anchors.topMargin: page.width / 20
		anchors.leftMargin: page.width / 10
		anchors.rightMargin: page.width / 10
		wrapMode: Text.WordWrap
	}

	Button
	{
		anchors.bottom: parent.bottom
                font.pointSize: 20
		anchors.leftMargin: page.width / 10
		anchors.rightMargin: page.width / 10
		anchors.bottomMargin: page.width / 20
     	        anchors.left: parent.left
                anchors.right: parent.right
		height: page.height / 8
                text: "CLICK ME"
		Material.background: Material.Blue
		
		onClicked: backend.HttpGet("http://artanidosatcrowdwareat.pythonanywhere.com/")
	}
}

Clone this wiki locally