Libsailfishapp DocsAPI Documentation
To ease development of applications for Sailfish OS and to make sure paths for the applications are set correctly and application startup time is accelerated, third party applications on Sailfish OS should use libsailfishapp. This library provides certain convenience functions within the SailfishApp namespace to set up your project, install all files into the right directories, and get important paths at runtime via convenience methods.
This document also serves to describe the functionality of libsailfishapp so that developers who cannot use it in their projects can use the info provided here as a guide for how to replicate the directory layout and paths. However, we generally recommend using libsailfishapp where possible, as it will allow applications to easily and automatically integrate well with Sailfish OS.
For more specific API documentation, see the SailfishApp namespace documentation.
How to use SailfishApp in your project
To use SailfishApp in your project:
BuildRequires: pkgconfig(sailfishapp)to your .spec file
TARGET = harbour-yourappnamein your .pro file
CONFIG += sailfishappto your .pro file
sailfishapp.hin your .cpp file
- Use the
SailfishApp::methods in your
In the rest of this document, we will refer to the value of the
TARGET variable in your .pro file as
$$TARGET (this is also how you can use the variable itself in the .pro file).
Files that get installed by libsailfishapp and have to be present in the same directory as the .pro file:
$$TARGET.png- An 86x86 pixel application icon
$$TARGET.desktop- The .desktop file for your app
qml/- A folder containing all your QML files
If you want to opt out of automatic deployment of the
qml/ folder, set
CONFIG += sailfishapp_no_deploy_qml before adding the SailfishApp configuration option. You might want to set this option if for some reason you intend to ship your QML files as Qt Resources (qrc). We recommend that you keep the default setup and install QML files in the filesystem instead.
Deploying app icons in multiple sizes
It's recommended that you provide application icons in multiple sizes, to support different device types and different screen DPI settings. You can do this with the following steps.
SAILFISHAPP_ICONS = size1 size2...to your .pro file, enumerating all available icon sizes in the form
- Ensure all icons are present as
icons/WIDTHxHEIGHT/$$TARGET.pngin the source tree
Using i18n support in your project
To use the internationalization convenience features of SailfishApp, do the following.
- In your main .pro file, add:
CONFIG += sailfishapp_i18n
If you use id based translations also add:
CONFIG += sailfishapp_i18n_idbased
make(this will create or update the file
translations/$APPNAME.tsand all files in TRANSLATIONS)
- In your RPM packaging .yaml file, add the following entry to the files section:
To add a new language to your project:
- In your main .pro file, add (with $LANG replaced with the language):
TRANSLATIONS += translations/$APPNAME-$LANG.ts}
(for example, for German, use "$APPNAME-de.ts", etc...)
If during development you want to skip building the translations every time, you can simply comment out the line
CONFIG += sailfishapp_i18n
in your qmake .pro file and the translations will not be built/updated. Be sure to re-enable the line when you do the release build.
For further information about how to use libsailfishapp, refer to the Sailfish SDK User Manual.