Every indicator main qml file must use <code>LatteComponents.IndicatorItem</code> at its root

+

<p align='justify'>

+

Every indicator's main qml file must use <code>LatteComponents.IndicatorItem</code> at its root

+

</p>

−

{{Input|<syntaxhighlight lang="C" line>

+

{{Input|<syntaxhighlight lang="QML" line>

import QtQuick 2.0

import QtQuick 2.0

import org.kde.latte 0.2 as Latte

import org.kde.latte 0.2 as Latte

import org.kde.latte.components 1.0 as LatteComponents

import org.kde.latte.components 1.0 as LatteComponents

+

LatteComponents.IndicatorItem {

LatteComponents.IndicatorItem {

id: root

id: root

Line 416:

Line 419:

</syntaxhighlight>}}

</syntaxhighlight>}}

−

The <code><strong>LatteComponents.IndicatorItem</strong></code> provides options to inform Latte what requirements and capabilities this indicator provides in order to appear, function and behave properly. All <strong>IndicatorItem</strong> options are <strong>[optional]</strong>:

+

<p align='justify'>

+

The <code><strong>LatteComponents.IndicatorItem</strong></code> provides options to inform Latte what requirements and capabilities this indicator provides in order to appear, function and behave properly. All <strong>IndicatorItem</strong> options are ''[optional]'':

Technical Details

LatteDock

This is an effort to expose some of the Latte tricks and APIs that developers can use in order to leverage Latte Dock capabilities. Two major sections are currently provided, Applets and Indicators. In the Applets section you will understand how a Plasma QML applet can obtain information from Latte and how it can be implemented properly in order to work just fine with parabolic effect. In Indicators section you will learn how you can create your own Latte Indicators.

NOTE: All mentioned APIs are provided since [v0.9.0] and if new properties or functions are added; a relevant reference will be presented, for example [v0.9.4]

Applets

Can a Plasma Applet access Latte Information?

Most definitely! This is very simple. The only thing you need to add in your applet main QML file is:

The latteBridge object is assigned from Latte when applet is loaded and it is the “ONE to rule them ALL” way to communicate with Latte. Important thing to mention is that if your applet is using both Compact and FullRepresentation(s) then the relevant code should be placed in CompactRepresentation.

After adding latteBridge property it is straightforward to identify when your applet is inside a Latte panel/dock or not with:

readonly property bool inLatte: latteBridge !== null

Can a plasma applet behave properly with parabolic effect?

Parabolic effect is not working properly when applets provide different lengths. Applets with large lengths decrease the animations speed and the applets with small lengths increase it. The best way for parabolic effect to work is for all applets to provide a squared layout that does not update its content positioning when zoomed. In order to make things easy for developers Latte can provide you with the best layout to achieve this without needing from you to make any calculations. To do this, you need to set it up as such:

In the above example you can see that when the applet is not providing any information for its Layout [-1 case] then Latte has the freedom to set it in the best appropriate.

latteBridge

latteBridge <properties>

After the latteBridge Object has been set from Latte you can access the following properties:

version[int] (readonly) : Shows the latteBridge version which coincides with the Latte Dock version. For example, Latte 0.9.0 produces a unique integer that can be used for numeric comparisons for greater than, lower than etc. If you want to make a version comparison, you can try the following in your code.

latteBridge.version >= latteBridge.actions.makeVersion(0,9,2)

applyPalette [bool] (readonly) : true when Latte is advising the applet to use the Latte colors palette in order to draw its contents with proper contrast

windowsTracker [QtObject] (readonly) : all windows tracking information that can be used from applets to update their contents. This is explained in detail in the latteBridge.windowsTracker section. Important:You need to enable windowsTrackingEnabled first through latteBridge.actions object.

latteBridge <signals>

broadcasted(string action, variant value)

Applets in Latte can create their own protocols in order to communicate with their neighbour applets. When such signal is received from your applet it means that some other applet is requesting from you to execute “action” with parameter “value”. A good example are the Window Title and Window AppMenu applets. These applets need to communicate with each other in order to hide or show themselves in Unity Mode. Window Title is shown when there is no mouse hovering and Window AppMenu when there is one. All this is orchestrated through applets without Latte taking any responsibility except broadcasting the requested actions to appropriate recipients. How applets are sending such actions through latteBridge.actions is explained in detail at the relevant section. In you want to track this broadcasted signal you can use:

It is used to produce a unique integer based on major, minor and patch versions in order to compare different versions, for example:

latteBridge.version >= latteBridge.actions.makeVersion(0,9,2)

latteBridge.actions <applet characteristics>

Applets can have different demands and characteristics that can be set and accessed through setProperty and getProperty functions.

activeIndicatorEnabled [bool] : false means Latte will not draw any indicator for this applet, a good example being the Global Menu plasmoid.

latteIconOverlayEnabled [bool] : false means Latte will never try to identify the central icon used in order to make this applet draw itself correctly with parabolic effect. Most applets are using PlasmaCore.IconItem in order to draw the CompactRepresentation icon when they are in a panel, but plasma iconitem does not play nice with parabolic effect. This is why Latte is trying to handle the case and take resposibility by hiding the PlasmaCore.IconItem and draw a LatteComponents.IconItem instead. If you dont want this to happen then you must set this property to false.

latteSideColoringEnabled [bool] : false means Latte will never overlay any color over this applet because applet takes responsibility for painting itself at all cases.

lengthMarginsEnabled [bool] : false means means Latte will not draw any margins around this applet comparing to its neighbours. Good example is the spacer plasmoid that in panel mode does not need any extra margins around it.

latteBridge.windowsTracker

WindowTracker provides two major objects currentScreen and allScreens in order to filter windows and provide window states information.

latteBridge.windowsTracker.currentScreen <properties>

activeWindowMaximized [bool] (readonly) : true when there is an active and at the same time maximized window in current screen

activeWindowTouching [bool] (readonly) : true when there is an active window in current screen and that window is also touching the Latte dock/panel.

existsWindowActive [bool] (readonly) : true when there is an active window in current screen.

existsWindowMaximized [bool] (readonly) : true when there is a maximized window in current screen independent if it is active or not.

existsWindowTouching [bool] (readonly) : true where there is a window in current screen that is touching the Latte dock/panel independent if it is active or not

activeWindowScheme[SchemeColors *QtObject] (readonly) : color scheme object for window that is touching Latte dock/panel in current screen and null if there is none. Properties provided by scheme objects can be found at schemecolors.h

lastActiveWindow[LastActiveWindow *QtObject] (readonly) : last active window that is still present and shown in the current screen. Properties provided from lastActiveWindow can be found at lastactivewindow.h

latteBridge.windowTracker.allScreens <properties>

activeWindowMaximized [bool] (readonly) : true when there is an active maximized window in any screen.

existsWindowActive [bool] (readonly) : true when there is an active window in any screen.

existsWindowMaximized [bool] (readonly) : true when there is a maximized window in any screen independent if it is active or not.

activeWindowScheme[SchemeColors *QtObject] (readonly) : color scheme object for active window in any screen, and null if there is none. Properties available for color scheme objects are provided through schemecolors.h

lastActiveWindow[LastActiveWindow *QtObject] (readonly) : last active window that is still present and shown in any screen.Properties provided from lastActiveWindow can be found at lastactivewindow.h

Applet Examples

Indicators

Introduction

In Latte v0.9 every indicator style has its own standalone qml implementation that can be found in its own package, just like Plasma qml-only applets. In that way every indicator style can support its own specific user settings and also abstract its implementation from the main Latte development. Online Indicators can be found at the kde store and can be installed through Latte → Effects page without needing from the users any special actions to accomplish the task.

X-KDE-ServiceTypes : it is required with value Latte/Indicator otherwise the indicator can not be installed and loaded

X-Latte-MainScript: it is required and defines the main qml file for the indicator implementation

X-Latte-ConfigXml : defines the xml settings that are going to be used from indicator implementation and user settings. It is optional and a package may not include it

X-Latte-ConfigUI : defines the qml settings user interface. It is optional and is provided only when the indicator has settings that the user can choose from in order to adjust the indicate apprearance and behaviour

QML Implementation

package/ui/main.qml

Every indicator's main qml file must use LatteComponents.IndicatorItem at its root

The LatteComponents.IndicatorItem provides options to inform Latte what requirements and capabilities this indicator provides in order to appear, function and behave properly. All IndicatorItem options are [optional]:

LatteComponents.IndicatorItem [properties]

needsIconColors [bool] : true when current icon main colors are needed. For example the Unity Indicator draws a background and glow that are provided from current icon colors.

needsMouseEventCoordinates [bool] : true when mouse even coordinates are neded. An example is the click animation in android style that provides the Plasma Indicator.

providerFrontLayer [bool] : true when a front layer is provided in order to draw contents above the current item/icon.

providesHoveredAnimation [bool] : true if the Latte built-in hovered animation must be disabled

provideClickAnimation [bool] : true if the Latte built-in clicked animation must be disabled

extraMaskThickness [int] : How many pixels are needed above the indicator in order to be drawn correctly. Example: The Latte indicator in reverse mode can support glow, but that glow is drawn externally. Latte must be informed for this in order to not visually subtract that glow.

minThicknessPadding [int] : The minimum thickness padding that is needd for the indicator

1 minThicknessPadding:0.2//20% of current icon size

svgImagePaths [Array (strings)] : Plasma::SVG files must be loaded from Latte in order to avoid high memory consumption

1 svgImagePaths:[‘widgets/panel-background’,‘../icons/separator.svg’]

The first SVG icon is provided from current plasma theme, and the second is located relevant to the package/ui

Tasks/Applets Information

As long as IndicatorItem has been set for the main qml file then the entire indicator qml implementation gains two different objects ( level and indicator ) in order to access tasks/applets and general information

<level> object [properties]

<level>object [properties]

isBackground [bool] (readonly) : true when the indicator background needs to be painted below the current icon/applet.

isForeground [bool] (readonly) : true when the indicator foreground needs to be painted above the current icon/applet

<level> object [signals]

mousePressed(int x, int y, int button) : can be tracked when needMouseEventSignals property has been enabled in IndicatorItem in order to get mouse x,y coordinates and which mouse button was released.

< indicator > object [properties]

isTask [bool] (readonly) : true when main item is actually a task
isApplet [bool] : true when main item is actually an applet

isLauncher [bool] (readonly) : true when main item is a task in launcher state
isStartup [bool] (readonly) : true when main item is a task in startup state
isWindow [bool] (readonly) : true when main item is a task in window state

isActive [bool] (readonly) : true when main item is active
isGroup [bool] (readonly) : true when main item is a group of tasks
isHovered [bool] (readonly) : true when main item is hovered
isMinimized [bool] (readonly) : true when main item is a task in minimized state
isPressed [bool] (readonly) : true when main item is pressed
inAttention [bool] (readonly) : true when main item requires attention
inRemoving [bool] (readonly) : true when main item in remove stage

isSquare [bool] (readonly) : true when main item is has a squared layout

hasActive [bool] (readonly) : true when a group of tasks has an active item
hasMinimized [bool] (readonly) : true when a group of tasks has at least one minimized window
hasShown [bool] (readonly) : true when a group of tasks has at least one shown (not minimimed) window

animationsEnabled [bool] (readonly) : true when animations are enabled
durationTime [real] (readonly) : current duration time for animation. It is a multiplier that can be used for animations in order to respect user preference concerning animations speed

Config UI

If you want the users to be able to adjust settings from config xml file then you need to provide a qml interface which is going to be loaded in Latte Effects page when your indicator is active. As such it is proposed to try to use QML components that dont break consistency and behavior of Latte Settings different pages. LatteComponents are used in most settings pages but nothing forbids you to choose something else. The config ui does not belong to any applet or task and as such it provides different options for the config user interface.