Plasma/shellPackage: Difference between revisions

From KDE Community Wiki
Line 64: Line 64:


=Applet geometry manipulation from scripts=
=Applet geometry manipulation from scripts=
==QML part==
Item {
    property int appletPlacementStrategy: “indexed”


Item {
    Connections {
property int appletPlacementStrategy: “indexed”
      target: parent
 
    onIndexedPlacementRequest: {
Connections {
                parameters: applet, index
target: parent
            }
onIndexedPlacementRequest: applet, index
    onGridPlacementRequest: {
onGridPlacementRequest: applet, x, y
                parameters: applet, x, y
onFreePlacementRequest: applet, point
            }
}
    onFreePlacementRequest: {
 
                parameters: applet, point
 
            }
    }
}
}


==C++ part in ScriptEngine==
PlacementStrategy ContainmentInterface::placementStrategy() const
PlacementStrategy ContainmentInterface::placementStrategy() const
{
{
 // look up the appletPlacementStrategy property and return it
     // look up the appletPlacementStrategy property and return it
}
}
 
[...]
void ContainmentInterface::requestIndexedPlacement(Applet *applet, int index)
void ContainmentInterface::requestIndexedPlacement(Applet *applet, int index)
{
{
if (placementStrategy() == IndexedStrategy) {
if (placementStrategy() == IndexedStrategy) {
emit indexedPlacementRequest(applet, index);
emit indexedPlacementRequest(applet, index);
}
}
}
}

Revision as of 19:23, 4 March 2013

Package filesystem

Package Type in desktop file: Plasma/Shell

contents/components/
contents/views/
contents/layout.js -> file
contents/defaults ->file

contents/components/

Shell UI components - named files AppletError.qml CompactApplet.qml Configuration.qml WidgetExplorer.qml

contents/views/

Each view (panel view or desktop view) will load a qml file that will "contain the containment", it will have the form <containment type>.qml Where <containment type> is allowed to be Desktop or Panel

contents/layout.js

The default layout JavaScript file supports a similar API to Plasma1 desktop scripting. The manipulation of Applet geometry will change a bit, see Applet geometry manipulation from scripts

contents/defaults

Default settings ContainmentActions Default containment for each type Default toolbox

Example defaults config file

[Desktop]
ContainmentPlugin=org.kde.desktop
ToolBox=org.kde.standardtoolbox
[Desktop][ContainmentActions]
Ctrl;LeftButton=org.kde.standardmenu
MiddleButton=org.kde.paste
 
[Panel]
ContainmentPlugin=org.kde.panel
ToolBox=org.kde.standardtoolbox
[Panel][ContainmentActions]
Ctrl;LeftButton=org.kde.standardmenu

[Theme]
Theme=air-mobile

Layout package details In metadata.desktop: X-Plasma-ContainmentCategories=<containment type>

Applet geometry setting Containment geometry strategies: * None * Indexed * Grid * Free * Grouped



Applet geometry manipulation from scripts

QML part

Item {
    property int appletPlacementStrategy: “indexed”
    Connections {
  	    target: parent

onIndexedPlacementRequest: {

               parameters: applet, index
           }

onGridPlacementRequest: {

               parameters: applet, x, y
           }

onFreePlacementRequest: {

               parameters: applet, point
           }
    }

}

C++ part in ScriptEngine

PlacementStrategy ContainmentInterface::placementStrategy() const

{
     // look up the appletPlacementStrategy property and return it
}
[...]
void ContainmentInterface::requestIndexedPlacement(Applet *applet, int index)
{

if (placementStrategy() == IndexedStrategy) { emit indexedPlacementRequest(applet, index); }

}