Widget Properties
A rundown of the QML Properties in a widget
Plasmoid property group
As discussed in the main.qml
setup widget section, when you import org.kde.plasma.plasmoid 2.0
, the main Item
in your widget will have the Plasmoid
(with a capital) property group similar to when you import QtQuick.Layouts 1.0
. This Plasmoid
property group has properties from AppletInterface
which inherits a few properties from PlasmaQuick::AppletQuickItem
.
plasmoid context property
You can reference a property from the Plasmoid.___
property group by the root Item { id: widget }
of the widget with widget.Plasmoid.___
. An easier method is to use the global context property plasmoid
(lowercase) which is dynamically defined at runtime when the property group is imported.
contents/ui/main.qml
Plasmoid properties
Plasmoid.activationTogglesExpanded
bool
Plasmoid.apiVersion
int
Plasmoid.associatedApplication
string
Plasmoid.associatedApplicationUrls
QList<QUrl>
Plasmoid.availableScreenRect
Plasmoid.availableScreenRegion
QVariantList
Plasmoid.backgroundHints
Plasmoid.busy
bool
Draw the [BusyIndicator
]({{< ref "plasma-qml-api#busyindicator" >}}) overtop the widget.
Plasmoid.compactRepresentation
Plasmoid.compactRepresentationItem
The instance of the compactRepresentation
Component. May be null
on load if not visible.
Plasmoid.configuration
Plasmoid.configurationRequired
bool
Wither to show a Configure button on top of the compact/full representation. It may look better to create your own button that calls plasmoid.action("configure").trigger()
.
Plasmoid.configurationRequiredReason
string
Not currently implemented to do anything.
Plasmoid.constraintHints
Plasmoid.containmentDisplayHints
Plasmoid.contextualActions
QList<QObject*>
Plasmoid.currentActivity
string
Plasmoid.editMode
bool
Only available to Containments like the "panel" widget. Used to toggle the global widget editing mode.
Plasmoid.effectiveBackgroundHints
Plasmoid.expanded
bool
Plasmoid.formFactor
Plasmoid.fullRepresentation
Plasmoid.fullRepresentationItem
The instance of the fullRepresentation
Component. Since widget popup's a lazy loaded, it is null
until the popup is opened.
Plasmoid.globalShortcut
Plasmoid.hideOnWindowDeactivate
bool
Set to false
to "pin" the widget's full representation dialog open when out of focus.
Plasmoid.icon
string
Plasmoid.id
uint
This is an integer representing the widget instance. See Plasmoid.metaData.pluginId
for the widget namespace.
Plasmoid.immutability
Detect if Kiosk mode has locked the widgets, or the user Lock Widget mode from Plasma 5.18 and below.
Plasmoid.immutable
bool
true
if either UserImmutable
or SystemImmutable
.
Plasmoid.loading
bool
Always false
when widget is running.
Plasmoid.location
Location of widget on the screen.
Plasmoid.metaData
Plasmoid.metaData.authors
QVariantList
Plasmoid.metaData.category
string
Plasmoid.metaData.copyrightText
string
Plasmoid.metaData.dependencies
QStringList
Plasmoid.metaData.description
string
Plasmoid.metaData.extraInformation
string
Plasmoid.metaData.fileName
string
Plasmoid.metaData.formFactors
QStringList
Plasmoid.metaData.iconName
string
Plasmoid.metaData.initialPreference
int
Plasmoid.metaData.isEnabledByDefault
bool
Plasmoid.metaData.isHidden
bool
Plasmoid.metaData.isValid
bool
Plasmoid.metaData.license
string
Plasmoid.metaData.licenseText
string
Plasmoid.metaData.metaDataFileName
string
Plasmoid.metaData.mimeTypes
QStringList
Plasmoid.metaData.name
string
The translated widget Name
. Also see Plasmoid.title
Plasmoid.metaData.otherContributors
QVariantList
Plasmoid.metaData.pluginId
string
Plasmoid.metaData.rawData
QJsonObject
Plasmoid.metaData.serviceTypes
QStringList
Plasmoid.metaData.translators
QVariantList
Plasmoid.metaData.version
string
Reads Version
in metadata.json
or X-KDE-PluginInfo-Version
in metadata.desktop
.
Plasmoid.metaData.website
string
Plasmoid.nativeInterface
QObject
[Documentation]({{< ref "c-api.md#plasmoidnativeinterface" >}}). Provides access to C++ properties by extending Plasma::Applet
like the SystemTray.
Plasmoid.pluginName
string
Plasmoid.preferredRepresentation
Plasmoid.rootItem
QObject
Reference the widget's root item. Cannot be used in the config dialog.
Plasmoid.screen
int
Plasmoid.screenGeometry
Plasmoid.self
AppletInterface
Plasmoid.status
Plasmoid.switchHeight
int
The minimum height required to switch to fullRepresentation
.
Plasmoid.switchWidth
int
The minimum width required to switch to fullRepresentation
.
Plasmoid.title
string
The translated widget name.
Plasmoid.toolTipItem
Plasmoid.toolTipMainText
string
The mainText in the default tooltip layout.
Plasmoid.toolTipSubText
string
The subText in the default tooltip layout.
Plasmoid.toolTipTextFormat
int
Plasmoid.userBackgroundHints
Plasmoid.userConfiguring
bool
Plasmoid.compactRepresentation
The compact representation uses DefaultCompactRepresentation.qml
by default. To summarize, it:
Draws the
plasmoid.icon
using aKirigami.Icon
Defines a
MouseArea
to toggle theexpanded
property which displays the full representation.
Plasmoid.fullRepresentation
If there's enough room (more than Plasmoid.switchHeight
) then the widget's full representation can be drawn directly in the panel or on the desktop. If you want to force this behaviour you can set Plasmoid.preferredRepresentation
.
If there isn't enough room, then the widget will display Plasmoid.compactRepresentation
instead, and the full representation will be visible when plasmoid.expanded
is true
.
In a plasma widget, the full representation will be shown in a PlasmaCore.Dialog
which you cannot access directly. You can manipulate the dialog with:
Set
Layout.preferredWidth
andLayout.preferredHeight
in your full representationItem
to change to dialog size.Set
Plasmoid.hideOnWindowDeactivate
to prevent the dialog from closing. You can use this to have a configurable "pin" like the digital clock widget does.
The dialog's source code can be found in CompactApplet.qml
to see the exact behavior.
contents/ui/main.qml
Plasmoid.icon
As mentioned in [the setup widget metadata.json
section, by default the plasmoid icon is populated with the Icon
value in metadata.json
.
To set a dynamic or user configurable icon, you will need to assign an icon name to Plasmoid.icon
.
You can search for icon names in the /usr/share/icon
folder. You can also look for an icon name by right clicking your app launcher widget then editing the icon in its settings. It uses a searchable interface and lists them by category. Plasma's SDK also has the Cuttlefish app (screenshot) which you can install with sudo apt install plasma-sdk
.
Also checkout the configurable panel icon example
contents/ui/main.qml
Plasmoid.configuration
This property provides access to the values user configurable values. You can easily access config values with plasmoid.configuration.varName
. By default it populates with the keys and values in config/main.xml
. You can easily write to plasmoid.configuration.varName = "value"
to change the value for the user.
Read more about configuration and the config dialog in it's section of the tutorial.
The user's configuration is serialized to ~/.config/plasma-org.kde.plasma.desktop-appletsrc
when the plasmashell
process terminates and is only loaded at startup.
Since: KDE Frameworks 5.78, you can reference the default value of plasmoid.configuration.varName
with plasmoid.configuration.varNameDefault
.
Since: KDE Frameworks 5.89, the KDeclarative::ConfigPropertyMap
datatype was deprecated and will eventually change to KConfig's KConfigPropertyMap
.
contents/ui/main.qml
Plasmoid.backgroundHints
PlasmaCore.Types.DefaultBackground
(default) is equal toStandardBackground
.PlasmaCore.Types.TranslucentBackground
An alternate version of the background is drawn, usually more translucent.
To use ConfigurableBackground
, combine the flag with another value with the bitwise OR operator |
.
Note: For ShadowBackground
, make sure you use PlasmaCore.ColorScope.colorGroup
in your IconItem
to have the symbolic icons follow the text color.
contents/ui/main.qml
contents/ui/main.qml
metadata.json
The common metadata.json
properties are covered in the setup widget section.
metadata.desktop
is the older format while metadata.json
is the newer replacement format. The .desktop
file is simpler to script using kreadconfig5
which is the reason why this tutorial prefers it in certain places like translations.
You can read the generated C++ API Documentation for metadata.json
for the json schema. The full list of properties for the older metadata.desktop
properties for widgets is defined in the Plasma/Applet
service type.
Name, Description
These two are based on the standard XDG desktop file properties. You can also translate these properties with Name[fr]
. The translated Name
is used in the "Add Widgets" list. The Description
(previously known as Comment
in the metadata.desktop
) is only used for the default tooltip subtext when the widget is added to a panel.
metadata.json
metadata.desktop
Icon
Icon
is the icon name associated with the widget. You can search for icon names in the /usr/share/icon
folder. You can also look for an icon name by right clicking your app launcher widget then editing the icon in its settings. It uses a searchable interface and lists them by category. Plasma's SDK also has the Cuttlefish app which you can install with sudo apt install plasma-sdk
.
metadata.json
metadata.desktop
Id
The Id
(or X-KDE-PluginInfo-Name
in metadata.desktop
) needs to be a unique name, since it's used for the folder name it's installed into. You could use com.github.zren.helloworld
if you're on github, or use org.kde.plasma.helloworld
if you are planning on contributing the widget to KDE. You should consider this the widget's namespace.
To view the currently installed namespaces use:
metadata.json
metadata.desktop
Category
The Category
(or X-KDE-PluginInfo-Category
in metadata.desktop
) is used to filter widgets in the widget list.
metadata.json
metadata.desktop
Accessibility
: tools that help those with special needs or disabilities use their computerApplication Launchers
: application starters and file openers.Astronomy
: anything to do with the night sky or other celestial bodies.Date and Time
: clocks, calendars, scheduling, etcDevelopment Tools
: tools and utilities to aid software developersEducation
: teaching and educational aidesEnvironment and Weather
: add-ons that display information regarding the weather or other environmentally related dataExamples
: samples that are not meant for production systemsFile System
: anything that operates on files or the file system as its primary purpose, such as file watchers or directory listings. Simply using a file as storage does not qualify the add-on for this category.Fun and Games
: for games and amusementsGraphics
: for add-ons where displaying images, photos or graphical eye candy is the primary purposeLanguage
: add-ons whose primary purpose is language related, such as dictionaries and translators.Mapping
: geography and geographic data add-onsMultimedia
: music and video.Online Services
: add-ons that provide an interface to online services such as social networking or blogging sites. If there is another more appropriate category for the add-on given the topic (e.g. mapping if the applet's purpose is to show maps), even if the data is retrieved from the Internet prefer that other category over this one.System Information
: display and interaction with information about the computer such as network activity, hardware health, memory usage, etcUtilities
: Useful tools like calculatorsWindows and Tasks
: managers for application windows and/or tasks, such as taskbars
This list was taken from: https://techbase.kde.org/Projects/Plasma/PIG
KPackageStructure
KPackageStructure
is a string to identify the associated KPackage::PackageStructure. For a plasma widget, it should be Plasma/Applet
.
Note In desktop files, the ServiceTypes
key was defined instead. This key is however deprecated and desktop files will no longer be supported in KF6. To convert a desktop file to json, you can run the desktoptojson -i metadata.json
command. The ServiceTypes
-> KPackageStructure
change must be done manually
metadata.json
metadata.desktop
X-Plasma-API, X-Plasma-MainScript
X-Plasma-API
tells plasma what script engine to use. declarativeappletscript
is the standard QML
loader.
X-Plasma-MainScript
is the entry point of your qml code. The default value is ui/main.qml
.
Note In Plasma 6, it is no longer possible to specify a custom mainscript. Instead, `ui/main.qml` is used as the entry point. The `X-Plasma-MainScript` entry may be omitted from the metadata in both Plasma 5 and 6. `X-Plasma-API` may also be removed in KF6, but is needed in KF5.
metadata.json
metadata.desktop
X-Plasma-Provides (Alternatives)
A Plasmoid can specify the type of functionality it offers, for example whether it's a clock, an application launcher, etc. This mechanism is used to list alternative plasmoids for a certain function. When you open the context menu of the Application Launcher (aka kickoff) in the Plasma desktop panel, you'll see that a number of different Plasmoids are offered here as alternatives, like the Application Menu (aka kicker) and Application Dashboard (aka kickerdash). All three of these widgets define:
metadata.json
metadata.desktop
These "Provides" are in fact arbitrary, so you can choose your own here. The field accepts multiple values separated by a comma. Here are some possible values that are used throughout Plasma:
org.kde.plasma.launchermenu
: App Launcher Menusorg.kde.plasma.multimediacontrols
: Multimedia controlsorg.kde.plasma.time
: Clocksorg.kde.plasma.date
: Calendarsorg.kde.plasma.time,org.kde.plasma.date
: Clocks with calendars (Eg: Digital Clock)org.kde.plasma.powermanagement
: Power management (Eg: Battery and Brightness)org.kde.plasma.notifications
: Notificationsorg.kde.plasma.removabledevices
: Removable devices, auto mounter, etc.org.kde.plasma.multitasking
: Task switchersorg.kde.plasma.virtualdesktops
: Virtual desktop switcherorg.kde.plasma.activities
: Switchers for Plasma activitiesorg.kde.plasma.trash
: Trash / file deletion
You can search plasma's code for more examples:
X-Plasma-NotificationArea (System Tray)
The Media Controller widget serves as a good example since it uses most of the systemtray metadata features. Its metadata contains the following:
metadata.json
metadata.desktop
By specifying X-Plasma-NotificationArea
, this widget will be found by the systemtray widget.
EnabledByDefault
will make sure it's enabled in the systemtray by default.
It's prudent for the widget to also set the X-Plasma-NotificationAreaCategory
so that the icons are grouped together. Its allowed values are:
ApplicationStatus
: indicates that this item represents an active applicationHardware
: indicates that this item allows managing hardware (could be a battery monitor or the wifi applet)SystemServices
: indicates that this item shows information about system services, for example the status of file indexing, software updates, etc.
You can search plasma's code for more examples:
X-Plasma-DBusActivationService
X-Plasma-DBusActivationService
will load and unload widgets in the systemtray automatically when a DBus service becomes available or is stopped. This is very convenient to load widgets automatically, so the user doesn't have to explicitly go to the notification area settings and enable or remove a widget.
An example of this is the Media Controller widget, which is auto-loaded as soon as an application starts offering the org.mpris.MediaPlayer2
DBus service in the session. As you can see in its metadata.json
file, X-Plasma-DBusActivationService
accepts wildcards which makes it a bit easier to match DBus names. This key can also be very useful to avoid having a widget loaded when it's unnecessary, so it can help to avoid visual clutter and wasted memory.
metadata.json
metadata.desktop
Search plasma-workspace
for X-Plasma-DBusActivationService
for more examples.
Last updated