Jump to: navigation, search

Developing my first plasmoid

These are my personal findings in creating my first plasmoid. I plan on integrating these bits in the appropiate pages.

Learn by example

Existing plasmoids can be found in the following places:

Plasma widgets which you can use to build your plasmoid UI:

Other intesting plasma sources:

When using OpenSSL

You have to remove the FindOpenSSL cmake module supplied by KDE libs which is superseded now by the Cmake provided one. The KDE one does not link against the crypto lib.

Adding custom SVG content to your plasmoid

Normally, relative paths are used to point to items from the current desktop theme. When you have custom content that's not part of any theme yet, you can supply it with your plasmoid by installing it in the default desktop theme.

In Cmake language this translates to: install(FILES "analog_telemeter.svgz"

  DESTINATION ${DATA_INSTALL_DIR}/desktoptheme/default/widgets/ )

I discovered this by looking at the cmake files of desktop themes. Desktop themes are found in KDE/kdeartwork/desktopthemes , except for oxygen, which can be found at KDE/kdebase/runtime/desktoptheme/oxygen. DATA_INSTALL_DIR translates for example to /usr/share/kde4/apps.

A desktop theme can support your plasmoid by supplying a file with the same name. If it is not found, there is a fallback to the default theme.

Adding configuration

//todo tell something about setConfigurationRequired

The Applet class has a config() method which returns a KConfigGroup. There is a tutorial explaining the KConfig basics but here we'll explain the basics needed to persist your plasmoid settings.

Config dialog

The easiest thing to do, is create your gui using the gui designer. Add this form to your build file: kde4_add_ui_files(telemeter_SRCS telemeterConfig.ui)

Override the createConfigurationInterface(KConfigDialog *parent) method where you initialise your gui fields with the in-memory values (normally previously read from disk). You'll also want to map the accepted() signal from the KConfigDialog parent to some local slot which persists the new settings. In the end, add your form to the KConfigDialog: parent->addPage(uiConfig, i18n("General"), icon());

Enable the config gui by setHasConfigurationInterface(true) during construction.

Writing settings

KConfigGroup cfg = config(); config.writeEntry("login", m_login); Don't forget to emit configNeedsSaving() as it hints to the corona to persist your settings. This may not happen immediately but definitely at destruction time. It can also compress config changed events to minimize disk I/O hence battery drain. Never call sync() yourself!

Reading settings

KConfigGroup config = config(); m_login = config.readEntry("login", ""); Settings should not be read in the constructor, but in the init() method.

Adding an icon

This icon will be used to identify your plasmoid in the widget browser.

Read this blog post on the naming convention which are to be used for icons and how to add them to your cmake build file. Don't forget to use the correct cmake install prefix or the icons will not show up!

Taking security constraints into account

Excerpt from KDE/kdebase/workspace/plasma/design/security:

Each plasmoid's .desktop file must list what features the plasmoid requires, and be kept up to date with the code. X-Plasma-Requires-<feature> can be set to Required, Unused, or Optional. Example: X-Plasma-Requires-FileDialog=Required


You can read anything your heart desires to know about i18n in this section

Packaging and deploying

//todo [02:09] <aseigo> look in kdesdk/scripts/createtarball .. it has everythign you need :)

This page was last modified on 8 May 2011, at 20:37. Content is available under Creative Commons License SA 4.0 unless otherwise noted.