Development/Tutorials/Plasma4/QML/API: Difference between revisions

    From KDE TechBase
    No edit summary
    Line 17: Line 17:
    What follows is a description of the Plasma declarative classes instantiable from QML.
    What follows is a description of the Plasma declarative classes instantiable from QML.


    == DataEngines ==
    == Data engines ==
    While it's possible to fetch data from a Plasma DataEngine in the same way as the [http://techbase.kde.org/Development/Tutorials/Plasma/JavaScript/API#DataEngine JavaScript API], however it is preferrable to use the following declarative classes:


    === DataSource ===
    === DataSource ===
    DataSource is a receiver for a dataEngine and can be declared inside QML:
    <code>
    DataSource {
        id: dataSource
        engine: "time"
        connectedSources: ["Local"]
        interval: 500
    }
    </code>
    It has the following properties:
    * bool '''valid''': true when the DataSource is successfully connected to a data engine
    * int '''interval''': interval of polling of the dataengine, if 0 no polling will be executed
    * string '''engine''': the plugin name of the dataengine to load
    * Array(string) '''connectedSources''': all the sources of the dataengine we are connected to (and whose data will appear in the '''data''' property)
    * Array(string) '''sources''': all the sources available from the dataengine


    === DataModel ===
    === DataModel ===

    Revision as of 19:02, 15 June 2011

    Introduction to the Plasmoid QML Declarative API

    This document provides an overview/reference of the Declarative QML API for Plasmoids. It isn't a full binding to all of Qt or KDE's libraries, but a focused set of bindings designed to make writing Plasmoids fast and easy, while remaining powerful.

    The API in this documentation covers the API of the Plasma specific QML components, so only the Declarative part of the API.

    The QML ScriptEngine is bassed upon the Plasma JavaScript engine, making the API of the JavaScript part identical to the one of the JavaScript plasmoids engine. To see the api of the global Plasmoid object, see the JavaScript API documentation. (TODO: the JavaScript api paged should probably be copied and stripped down the imperative bits not present there, it would make harder to update tough)

    What Is A Simplified JavaScript Plasmoid?

    To denote that this Plasmoid is a Declarative widget, ensure that in the metadata.desktop file there is this line:

    X-Plasma-API=declarativeappletscript

    What follows is a description of the Plasma declarative classes instantiable from QML.

    Data engines

    While it's possible to fetch data from a Plasma DataEngine in the same way as the JavaScript API, however it is preferrable to use the following declarative classes:

    DataSource

    DataSource is a receiver for a dataEngine and can be declared inside QML:

    DataSource {
        id: dataSource
        engine: "time"
        connectedSources: ["Local"]
        interval: 500
    }
    

    It has the following properties:

    • bool valid: true when the DataSource is successfully connected to a data engine
    • int interval: interval of polling of the dataengine, if 0 no polling will be executed
    • string engine: the plugin name of the dataengine to load
    • Array(string) connectedSources: all the sources of the dataengine we are connected to (and whose data will appear in the data property)
    • Array(string) sources: all the sources available from the dataengine

    DataModel

    Plasma Themes

    Theme

    Svg

    SvgItem

    FrameSvgItem

    Top Level windows

    Dialog

    ToolTip