User:Mxttie

From KDE Community Wiki

Developing my first plasmoid

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

The Applet class has a config() method which returns a KConfigGroup. There is a tutorial explaining the KConfig basics but here we explain the plasma KConfig basics. :)

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());

Writing settings is as easy as: KConfigGroup config = this->config(); config.writeEntry("login", m_login);

Reading: KConfigGroup config = this->config(); m_login = config.readEntry("login", "");

Enable your plasma config gui by setHasConfigurationInterface(true) during construction.

Packaging and deploying

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