Make KDE applets with KDevelop

In previous tutorial I gave a short introduction how you create an KDE applet. Of course I explained how you do it manually. Because you develop Java programs with Eclipse or Netbeans, it’s obviously to have some sort of IDE to create KDE applets. I suggest you use KDevelop, it’s a powerfull IDE for C++ coding. Okej let’s start creating an small KDE applet.

Installation

You have to install two things to start with KDevelop:

  • KDevelop
  • kde4-kapptemplate
  • G++ (compiler)
  • CMake

With a package manager this job should be easy.

Let’s start!

Open KDevelop. In the menu “Project” select “New from template”. Then you get a window like this.

Choose “Plasma Applate Template” from the category “C++ | KDE”. Give it a name and a location. Press “Next”. If you want a CVS system managing your files, you should select one. Press “Finish”.
It will ask where the “cmake” executable is located, normally it’s in /usr/bin/cmake. When you build your code, it needs a build directory where it can dump all make files, the executable and some log files. The other two fields are optional, so I leave them blank.

Under the “Projects” window you find your project. Is the “Projects” window not visible, activate it by clicking on the “Window” menu and then select “Tool views | Projects”. Under the project you find a lot of files like README, Messages.sh, … There are four important files for you KDE widget:

  • CMakeLists.txt: the make file to make the binairy
  • plasma-applet-tutorial.desktop: the widget desktop file
  • tutorial.cpp: source code
  • tutorial.h: header file

If you open “tutorial.cpp” you find some C++ code. This is you main file for your widget. You can see this because it extends from the class “Plasma::Applet”. In the CMakeLists.txt you find what files you need to compile, what libraries the code depends on, what it requires. If you get an build error and your code is fine, it’s because somethings wrong in this file. The desktop file is needed to find you widget and to put the widget on your desktop. It contains various information of the widget (name, author, category, …).

Build and install

Now we’re going to build the project. If you press F8 or right click on the project and choose “Build”, it starts building. It create some files in the “build” sub-directory of your project. When you don’t have red text in your build console and only green (you get a warning about an unused parameter option, ignore it), your build is successful.

In KDevelop you can “Install” the project by right click on the project and choose “Install”. In my case it fails because you need to be root. So the installation part should be done manually. Just execute the follow shell lines:

cd /path/project
cd build/
sudo make install

When you get the output similar on the screenshot, you’re installation succeeded.

Run your applet

Keep your console open and type the follow command:

plasmoidviewer -c desktop tutorial

Congratz, you created your first KDE widget trough KDevelop.

Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit / Bijwerken )

Twitter-afbeelding

Je reageert onder je Twitter account. Log uit / Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit / Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit / Bijwerken )

Verbinden met %s

%d bloggers op de volgende wijze: