Development/Tutorials/Plasma/JavaScript/DataEngineAPI

< Development‎ | Tutorials‎ | Plasma
Revision as of 06:37, 6 August 2010 by Aseigo (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Introduction to the DataEngine JavaScript API

  • What is a DataEngine

QtScript

noframe
 
This section needs improvements: Please help us to

cleanup confusing sections and fix sections which contain a todo


The example used is from the Plasmoids, and isn't relevant to DataEngines as it uses PushButton, etc. A new example should be written that uses the DataEngine API

The Simplified JavaScript API is powered by Qt's QtScript system which provides access to a full featured ECMA Script interpreter. If it works in ECMA Script, it will work in a Simplified JavaScript Plasmoid. As an interesting implementation note, QtScript uses the high performance ECMA Script interpreter from WebKit and shares this code with QtWebKit.

On top of the ECMA Script language, QtScript provides Qt integration features. Probably the most useful one in this context is the use of signals and slots which is Qt's callback mechanism. Signals may be emitted in QtScript by calling the signal method in question, a signal can be connected to a slot by using the connect() method (and disconnected with disconnect()) and any function defined in the Plasmoid may be used as a slot. For example: function onClick() {

   print("We got clicked!")

}

function onFirstClick() {

   print("First click!")
   button.clicked.disconnect(onFirstClick)

}

button = new PushButton button.clicked.connect(onClick) button.clicked.connect(onFirstClick) button.clicked() This will print out:

We got clicked! First click!

on the console when the Plasmoid starts, and the "We got clicked!" again whenever the button is clicked by the user.

The object that emitted the signal that caused a slot to be called can be retrieved using the QObject sender read-only property of the global plasmoid object.

Global functions

The Global engine Object

Events

Services

Other Functions and Classes

Addons

noframe
 
This section needs improvements: Please help us to

cleanup confusing sections and fix sections which contain a todo


This section can be copy and pasted from the Plasmoid API page

Extensions

noframe
 
This section needs improvements: Please help us to

cleanup confusing sections and fix sections which contain a todo


This section can be copy and pasted from the Plasmoid API page

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal