calamares / calamares-extensions

Examples of Calamares branding
39 stars 24 forks source link

Calamares Branding and Module Examples

A branding component in Calamares is a description of the product (i.e. distribution) being installed along with a "slideshow" that is displayed during the installation phase of Calamares. This shapes the look of your installation.

A module adds functionality to Calamares; modules may be written in C++ or Python, using Qt Widgets or QML for the UI (with C++) if there is one. Both C++ and Python allow a full control over the target system during the installation.

This repository contains complete examples of branding and some modules for Calamares.

Branding

Branding shapes the look of Calamares to your distro

Calamares ships with (just) one default branding component which can be used for testing. The examples here show what can be done with QML in the context of Calamares branding, and provide examples and documentation for the framework that Calamares ships with.

Writing your own Branding

Testing a Branding Component

If Calamares is installed, then the Calamares QML support files are also installed; usually under /usr/local/share/calamares/qml/. Some branding components need those support files, although a branding component is free to do whatever is interesting in QML.

The tool for quickly viewing QML files is qmlscene, which is included with the Qt development tools. It can be used to preview a Calamares branding component (slideshow) without starting Calamares. If the component uses translations, you will need to build the translations first (using Qt Linguist lrelease, or by using the normal build system for branding components).

Suppose we want to test the Calamares branding component fancy, which has a root QML file fancy/show.qml. Translations have been built and are in build/calamares-fancy_nl.qm. Calamares is installed in the usual location. Then we can run

qmlscene \
    -translation build/calamares-fancy_nl.qm \
    -I /usr/local/share/calamares/qml \
    -geometry 600x400 \
    fancy/show.qml

This starts the viewer with the Dutch (nl) translation, using the support files already installed, in a 600x400 pixel window. By doing so, the slideshow can be developed much more quickly (and with more fancy effects) than by going through the Calamares install process every time.

Note that running a QML slideshow inside Calamares is slightly different. Calamares internally can call functions in the slideshow, and can set a property in the slideshow, to indicate that the show is now visible and should start.

Calamares Branding API

The slideshow which is configured in the branding files can have one of two "API styles".

If the slideshow QML defines functions onActivate() and onLeave() then those functions are called when the slideshow becomes visible and when the installation is finished. These can be used to start and stop timers or sound effects or whatever.

In addition, if the slideshow QML defines a property activatedInCalamares then it is set to true when the slideshow becomes visible, and to false when the installation is finished. This can also be used to start timers, etc. The standard Presentation.qml included with Calamares has such a property.

A slideshow (show.qml) can be entirely independent, with bespoke code, or it can make use of files shipped as part of Calamares: a Presentation and a Slide element (and some others). There are also Calamares internals which can be used from QML:

Modules

Modules extend the functionality of Calamares for your distro

This repository contains examples of a C++ job module (no UI, runs in the exec phase) and a C++ view module (with UI if listed in the show phase, and may run jobs if listed in the exec phase) and a Python job module (no UI, runs in the exec phase).

Example Modules

Functional Modules

CMake Preparation

The single macro calamares_add_module_subdirectory() does all the work. A C++ module will be recognized by the presence of a CMakeLists.txt in the subdirectory, while a Python module has a module.desc file.

C++ Modules

A C++ module can use the CMake macro calamares_add_plugin() to list sources, resources, UI files, libraries to link, etc. This supports both job modules and view modules through the TYPE parameter of the macro.

The API is documented in the Job.h and ViewModule.h (there are subclasses for specific kinds of viewmodules) header files, and in the developer guide.

Python Modules

The Python module needs a module.desc and a Python file, usually called main.py which defines a run() function.

The API is loosely documented in the developer guide.

Join the Conversation

GitHub Issues are one place for discussing Calamares (and Calamares Extensions) if there are concrete problems or a new feature to discuss. Issues are not a help channel. Visit Matrix for help with configuration or compilation.

Regular Calamares development chit-chat happens in a Matrix room, #calamares:kde.org. Responsiveness is best during the day in Europe, but feel free to idle. Matrix is persistent, and we'll see your message eventually.