Skip to content

June 11, 2010

7

Qt maemo homescreen widget – package your example

After you have followed, what you have to code in order to create a simple Qt homescreen widget for maemo out of the last post, you can continue to package your example. The following instructions are based on MADDE , which is also part of the Nokia SDK. But it will as well work seamlessly for the platform SDK in Scratchbox. If you are using Windows, please use the MADDE terminal to type in the commands. The name for the example application is TestHomescreenWidget.

1) Prepare
Create a folder <application-name>-<version>, in my case:
mkdir testhomescreenwidget-0.1

Copy all the source-files (*.h, *.cpp, *.ui, *.pro) into that new folder.

2) Create a testhomescreenwidget.desktop file:
This file is needed to tell the system, where to find the binary, which will be executed to start the widget. The desktop file follows a standard, but we just need a couple of lines. Let’s go through them:

[Desktop Entry]
Name=Test Widget
Type=qt
X-Path=/opt/test-homescreen-widget/testhomescreenwidget
X-Multiple-Instances=false
X-home-applet-minwidth=250
X-home-applet-minheight=150

The first line is mandatory. The name is the one, which will be listed later, when the user wants to select this widget to be shown on the desktop. X-Path points to the executable. We don’t want to have multiple instances of the widget on the desktop, and with the last to lines we define the size. This desktop file should be placed and installed in a certain folder in the system. You can define in your *.pro file, where it should be placed later. Therefore you have to add targets to your INSTALLS value in the project file: One for the desktop (“desktop”), and one to define, where the binary should be installed (“target”). So, add the following lines in your *.pro file:

PREFIX = debian/<application-name>

INSTALLS += target desktop

desktop.path = $$PREFIX/usr/share/applications/hildon-home
desktop.files = *.desktop

target.path = $$PREFIX/opt/<application-name>/

3) Run in that folder:
mad dh_make -createorig -single -e a@example.com -c gpl

4) Configure the debian settings
In the debian folder you will find now a lot of different files. Most of them are not really interesting for you at this point. The important files are:
- control
- rules
- compat
- postinst

control file:
The control file contains all the information, which is needed by the system to build and install it. The main fields, we are looking at in this phase are the build dependencies and package dependencies. The build dependencies contains information about, which other packages are needed to compile the sources. In your case, you want to add the dev-packages of Qt and two more system packages, which are needed by the qmaemo5homescreenadaptor class. This should result in this:

Build-Depends: debhelper (>= 5),libqt4-dev, libhildon1-dev, libhildondesktop1-dev

The second important field for now is the “Depends” field. There you have to add the information, that your package depends on the homescreen-loader:

Depends: ${shlibs:Depends}, ${misc:Depends}, qt4-homescreen-loader

The rest of the control field should be configured by dh_make automatically. The main goal is at the moment to get a package to test on the device. Before you publish it, please add a description etc. there.

rules
This file determines, which steps are taken to compile the sources and build the package. Therefore you have to tell the script to run qmake before running make. This has to be done in two lines and you are set. It should be also set in the “clean” section, as this is always the first one, which is executed. This means that it looks for a Makefile there already. The easiest workaround here is to add it there too.

First place:

build-stamp: configure-stamp
dh_testdir
# Add here commands to compile the package.
qmake && $(MAKE)

Second place:

clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
# Add here commands to clean up after the build process.
qmake && $(MAKE) clean

postinst (This does not apply for Scratchbox-users)
This file has to be added to the debian folder because of a bug in MADDE, which will be fixed in the next release. The source of that problem is, that the rights are not set correctly for executable files in the /opt/-folder automatically. Therefore please add a file with the name “postinst” in the debian folder. The content is:

#!/bin/sh
chmod +x /opt/path/to/your/executable/binary

compat
Finally make sure that the value in this file is 5 and not 7.

5) Build the package
Now you can build the package with:

mad dpkg-buildpackage -us -uc

The result should be an installable package for the N900. A guide on how to install the package on the device you can find in the wiki. I hope it explained a bit what has to be done and why. For further questions, please ask me in irc or post your comments here. In the next step, I will show how to personalise your application a bit and how to use the other functionality of the qmaemo5homescreenadaptor. But for now the first steps should be done and your widget should show up on the desktop after the installation.

Read more from coding
7 Comments Post a comment
  1. zle
    Jun 30 2010

    Hi, great tutorial! Thanks alot.
    But this does not work, you need to mention that the makefile is needed too.

  2. zle
    Jun 30 2010

    Well.. the makefile totally messed it up.. I guess I did something wrong, the build worked fine after redoing all the steps. Will now try to see of a widget shows up on my homescreen :)
    Thanks again.

  3. zle
    Jun 30 2010

    Well.. after doing some more testing, I just cannot get my widget to show up on my desktop. Nothing happends.. I get my app listed in the “Add widget” screen, but thats about it..
    Can I send you my files so you can have a go?
    Or do you mind sharing your files?

    Thank you.

  4. zle
    Jun 30 2010

    OOOH! I am so sorry for spaming..
    I worked it out now! :D
    I just forgot to rename the postinst.ex file to postinst :)
    Sorry for all these posts..
    It works now, thanks a lot, hope you will write more on this topic! :)

  5. zle
    Jun 30 2010

    I found something:
    qt4-homescreen-loader and qt4-maemo5-homescreen-loader
    causes conflict on my N900

    qt4-maemo5-homescreen-loader is already installed and I cannot install qt4-homescreen-loader because of that.
    so I had to change the dependencies to: qt4-maemo5-homescreen-loader

  6. daniel wilms
    Jul 6 2010

    The package qt4-maemo5-homescreen-loader was needed, while Qt 4.6 was not part of the software release. Now as it is there, please stick to qt4-homescreen-loader. If you have the maemo5 classes installed, maybe a reflash of the device would be not too bad ;)

  7. zle
    Jul 7 2010

    Hi, thank you. I did do a reflash and that solved the problem :)
    Keep up the good work, you help a lot of people with maemo.

Share your thoughts, post a comment.

(required)
(required)

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments