Tuesday, 6 August 2013

Alpha 2: Passing simple C++ properties from main.cpp to the QML Side with Qt5

One of the first challenges in migrating LandedSettings from the Sailfish Alpha 1 7 Qtt to Alpha 2 / Qt5 was that I pass a simple property from the main.cpp file (C++) to the QML side via a setContextProperty call.

The property was platform, and was intended to allow the Qml side to change font size etc according to the platform it was running on. I originally added this functionality to handle differences between the Nokia Simulator and the Haramattan Emulator (QEMU).

In Qt4 I was able to pass such properties via a call to setContextProperty, offered by a bit of Nokia code called the QmlApplicationViewer. As this is no longer included with the Sailfish Alpha 2, and will not run unchanged, I needed to migrate this to something different. As we will see their were a number of approaches I could have taken.

Monday, 5 August 2013

Alpha 2: Installing an Import Library on the Emulator

In a previous post I covered the code migration of my import library AbstractUI from Qt4 to Qt5.

However the greatest problem proved to be not in the code, but rather where to install my newly migrated library. Read on to find out the solution.

Alpha 2: Migrating LocalStorage from Qt4 to Qt5

This morning I successfully migrated the LocalStorage part of my app LandedSettings from the Sailfish Alpha 1 (Qt4) style to the new Sailfish Alpha 2 (Qt5) style.


In LandedSettings all the Database access functionality is encapsulated in 3 javascript files. In order to focus the migration on the LocalStorage only, I created a new throwaway project QT5TestLS, copied the 3 JavaScript files to the new project, and added just enough code to the project to setup and populate the Database.

The Full code of  QT5TestLS can be found on GitHub.



Below is a summary of the things I had to change:


Saturday, 3 August 2013

Alpha 2: Migrating an Import Library

Note: As my experience and understanding of migrating to Qt5 / Sailfish Alpha 2 increases, I will update this post if required.

Having installed the second Sailfish Alpha (which I will refer to as Alpha 2), and checked that the default "Hello Sailors" project runs on the Emulator, I jumped in feet first to try and get LandedSettings running using Qt5.

Almost at once I ran into a problem, one that should have been obvious from the start: LandedSettings depends on an import library AbstractUI, and of course this must be migrated first.

As abstractui is intended to abstract out the differences between Harmattan and Sailfish, and Sailfish is now on a higher Qt level than Harmattan this does raise the question whether this approach is still valid. But I prefer to defer that question to slightly later For the moment I want to get LandedSetttings up and running on the new Alpha, thus I need to get AbstractUI ported.

The irony of a tool that was intended to ease porting needing porting itself does not escape me.

Therefore I decided to make a throwaway demo import library native to Qt5, and a throwaway QML project to import it. I could then compare the throwaway library to AbstractUI, and identify what needs changing.

The first pleasant surprise is that there is now a project template for Libraries. I chose "New Project / Libraries / Qt Quick 2 Extension Plugin". In the first alpha this template was not available. if I remember correctly i actually created the project in the Qt Project SDK as a a Qt Quick 1 Extension Plugin, and adapted it for Sailfish to the point that I got it working.

Having tested that the throwaway was importable and installable (more on this in a follow-up post) it was time to start porting abstractui.

As the original Sailfish flavour of the abstractui library was not created in the Sailfish SDK (but now could be), I decided to start from fresh, creating a new project in the Saillfish QtCreator, and would then merge in the bits of code required from the old version of the library.


Update after the Sailfish Qt5 Alpha

Hi all

This is just a quick update to say what I am up to, and the changes I hope to make to this blog over the next few days and weeks.

The announcement of the second Sailfish Alpha: this one Qt5 is a tipping point. Plus the fact that the Sailfish guys were kind enough to link this blog from their official website has put a cat amongst the pigeons!

Due to the differences between Qt4 and Qt5 some of the exiting articles will no longer be relevant. Most however will be, but with small changes. So I am doing the following:

1) I have marked most posts indicating that they will be revised for the new Alpha soon.

2) Started updating posts for Qt5.

3) I have started porting my app LandedSettings so that it runs with the new Alpha. Whilst doing so I will gradually review existing posts and update these with differences. As LandedSettings currently uses the AbstractUI library this is a good "complicated" example to start with.

4) Where I encounter major differences (headaches) I will post new articles highlighting these!

5) I am pondering just how viable an abstraction library supporting Harmattan (Qt4.7.4) and Sailfish (Qt 5) remains, . I am convinced that the technique is highly relevant for different platforms on Qt 5, but less so for platforms on different Qt Versions. Once I am past the pondering stage I will post in detail on this topic.

Friday, 2 August 2013

Sailfish Qt5 Alpha Available!

Hi All

As of last night the SailfishOs Qt5 Alpha is now available for download.

The biggest and most obvious change is that the "old" alpha used Qt 4.8.3, the "new" alpha uses Qt 5.

Equally interesting, X11 has been replaced by Wayland.

Whereas Qt 4.7.4 (Harmattan) and Qt 4.8.3 (Sailfish Silica) were close enough as to make very little difference, Qt5 brings some big changes. It remains to be seen as to how this makes supporting an app with a common code base for Harmattan and Sailfish more difficult (or even impossible….)

Sailfish have added a webpage on porting from Harmattan. It can be found here.

In the meantime I have installed the Qt5 Alpha on OSX and Lubuntu 64 bit, and been able to run and deploy the default "Hello Sailor" app on both. Windows is downloading in the background as I type this.

Note that before you install the new SDK, you should first deinstall the old SDK using the SDKMaintenance tool. As I am by nature suspicious I simply renamed the original install directory and the hidden .scratchbox2 directory, so that I could easily restore these if required.

My next step is to try running Landed and LandedSettings.. I hope to bring news over the next few days of how this works.