Thursday, 27 June 2013

QML: Faking an SQLResultSet Object with JavaScript

A few days ago while hunting down an elusive bug in the way the Silica ContextMenu component work I decided to produce a radically stripped down version of LandedSettings. The idea was to prove that the strange behaviour was still present in a pure Sailfish project, and make things much more readable by removing anything from the project not directly related to the issue.

Now LandedSettings is ultimately a front end to an SQLite database. But in my simplified project I only needed data from one table, basically a list which is returned from the Javascript handling SQLite as a JavaScript rs object.

I was keen to remove all the code concerned with database setup and access, yet did not want to change the code deep in my app that processes the resultset. 

So would it be possible to produce a JavaScript object equivalent to that returned from SQLite? This object would return the same data (a list of 6 items), and would have to have the same structure as its SQLite equivalent.

In effect, could I replace the whole database access code with a simple javascript method returning a javascript object?

As we will see, not only is it possible, but it is actually very simple, elegant and easy to achieve. (But as is often the case, working out how to do this was not so easy …)

Sunday, 23 June 2013

Playing around with the guts of Sailfish Silica Components

Have you ever felt the need to dig around in the guts of the Sailfish Silica provided QML components to work out how things are done? This article explains how you can do this.

Recently I decided to change the way my LandedSettings app allows the user to create, edit and delete entries in the settings database.

Under the existing solution, when the user double-clicked an item in a view (and I have four views), the view delegate would push an appropriate configuration page. This page was festooned with new, edit and delete buttons. Each of these would push a further page allowing that action to be carried out.

I was never entirely happy with this solution. It always struck me as more than a little clumsy and very "desktop", but as LandedSettings was a secondary app supporting the main app Landed I stuck with it.

Then I started porting to Sailfish Silica. Using the Sailfish ComponentsGallery as a reference (click on the propeller on the home screen) I found that under Silica, when a view entry is pressed and held, a context menu drops down.

This seemed to be a much better solution to offer new, copy, edit and delete options, so I set about changing LandedSettings to use this type of context menu.

Thursday, 20 June 2013

Connecting to the Harmattan QEMU: Learning from Sailfish!

A few days ago I wanted to compare some differences in behavior between the Sailfish Emulator, and the old Harmattan Equivalent QEMU.

These are two very different beasts, with the QEMU being so slow and unresponsive as to be just barely usable, while the Sailfish Emulator is a much snappier affair. But that is not the point of this post.

On starting up on the QEMU I realized that I had not installed my AbstractUI library on QEMU, and even more surprisingly that I had never connected to the thing via SSH for a peak inside.

A quick google found this link:


So we can connect like this:


ssh -p6666 root@localhost


no password required!

Thursday, 13 June 2013

Menu Abstraction with AbstractUI Part 2

Hi all

In a post some days ago I pointed out that menu handling is substantially different between Harmattan and Sailfish Silica. I may even have mentioned jumping through flaming hoops ...

Well the solution I now have is not perfect. I would still categorize it as a workaround, but it is one that I can live with as it fits my needs, and I am aware of the weaknesses.

From a user's point of view (and we should never forget our users) the differences in Menu Handling are these:

1) Launching

A Harmattan menu is launched from the Toolbar which sits at the bottom of the screen occupying valuable screen real-estate.

The Silica Menu is launched by swiping the screen (up in the case of a PushUpMenu, down in the case of a PullDownMenu). While no screen real-estate is consumed by a ToolBar, the menu is indicated by a MenuIndicator. The trouble is that the new user will naturally try and open the menu by the indicator: that's the intuitive thing to do: but it is the part of the screen that cannot be used to open the menu: if you drag there you will slide the whole app away!

2) Behaviour on Opening

When the Harmattan Menu opens, it slides over other content on the page, without any programmer intervention, and as the menu is non-transparent, there is no "interference" between menu items and components now under the open menu.

The Silica Menu, at least in the demo new project, causes other page content (page childs) to slide away with the menu as it opens

So how do these affect us as programmers? Read on:


Connecting to a Nokia N9 with a RSA Key File: Learning from Sailfish!

I recently had to reflash my Nokia N9 because Bluetooth would no longer start. The reflashing itself is a story for another time (and maybe another blog post), but the process of restoring apps and stuff after the reflash made me think about how I interact with the N9 as a developer.

Until now when I have needed to move files onto the N9 I have connected via SSH using the password prompted in the N9's SDK Connectivity App. While this works well it is a bit cumbersome.

Then I reflected on how we interact with the Sailfish SDK and Emulator. Here we authenticate via RSA key files. No password needed. Much nicer, yet equally secure.

So this raised the question: can we apply the same technique to the N9? Can we connect to the N9 with a RSA key file?

After a little bit of googling and experimentation, the answer is a resounding yes; and it proves to be very easy.

I found the basic idea here: So thanks to Greygoo the author. My post takes a slightly simpler approach, and is specific to the N9.

Sunday, 9 June 2013

Where is my SQLite DB on the Sailfish Emulator ?

Note: This post will be updated for the Qt5 Alpha shortly!

By default, SQLite Database files are stored here on the Emulator:


Landed Project Source Posted to Github

I have hinted in previous posts at my core app Landed, which started over a year ago on Harmattan, and is now up and running on Sailfish as well. Getting Landed running on both platforms was the motivation for creating the AbstractUI abstraction library.

For sometime I have been mulling over the idea of publishing the source of Landed, but it was never quite ready enough: there was always something else to correct, improve or add, and the migration to Sailfish (and abstract) proved to be a distraction.

It was not until I realized that this is likely to always be the case: there will always be something to improve or tweak, or a cleaner way of doing things, that to quote the Duke of Wellington I decided to "Publish and be Dammed!".

So both Landed, and its sidekick LandedSettings are now posted to:

See the file for an explanation of what Landed does, requirements, how to setup etc.

I make no apologies for the fact that Landed and LandedSettings are at the time of this post not finished. Most of the functionality works, but some does not. The abstract still throws lots of errors to the output, but am I working on the that.

Now for some food (cold fillet steak from last night), and some ale, then back to programming ….

Saturday, 1 June 2013

Menu Abstraction with AbstractUI

I have been doing more work migrating my core apps to Sailfish using AbstractUI, extending this library as I find problems.

One of major stumbling blocks so far is Menu handling. Not only do Harmattan and Silica Menus look and behave a little bit differently (not really a problem), they also interact differently with other associated components (Page, MenuLayout etc.).

This means that the Harmattan and Sailfish versions of these abstraction controls have to differ substantially, yet still provide a common interface which can be used from one code base to target both platforms.

I will go into the differences and the flaming hoops I jumped through to address them in a second post later this weekend. For now I want to point out 4 demo menu handling projects that I have posted to Github last night to demonstrate menu handling, with and without AbstractUI.

Each of these projects offers a menu with two options. One increments a counter on the page, the other decrements it. Each is based on a stripped down version of the "new project" created by the Harmattan and Sailfish QtCreators.

The HarmattanMenuDemo shows native Harmattan menu handling: A ToolBar at the bottom of the screen, with a ToolIcon, which when pressed opens or closes the menu.

The SilicaMenuDemo is the Silica equivalent, with a native Silica PulldownMenu which is accessed by dragging down on anywhere on the screen other than the glowy MenuIndicator at the top. (This is a bit counter intuitive at first).

The HarmattanAbstractMenuDemo is a copy of the HarmattanMenuDemo, but with the native controls abstracted out via the Harmattan flavour of AbstractUI.

The SilicaAbstractMenuDemo is the Silica equivalent, using the Silica flavour of AbstractUI.

There are some minor differences between the native and abstracted handling / look and feel, but I should be able to iron those out later.

For these demos I started with separate Harmattan and Silica projects a) to show the implementation(s) as natively as possible, and b) because I could not get a new Sailfish project to start up on Harmattan (the reverse should work), and I did not want to get side tracked into that issue…

In a later post I will dive deeper into the implementation.

Update: 2013.06.01 14:03

The Sailfish native implementation has all Page child items in a Flickable control sized to the Page, so all items move down when the menu opens


My current AUI implementation does not do this, so while the menu opens, other page controls stay in place, and the menu may open behind them, rendering it not very useful!

Update: 2013.06.09 17:05

The Sailfish flavour of  AUIPageWithMenu, now changes the z: axis of the menu to high when the menu is active (i.e. open) and low when not active (closed). Also when the menu opens, the opacity of all page childs is reduced (fading these out), so while they are still visible behind the menu, the menu is readable.