answered
2014-10-23 21:34:15 +0200
Warning: by following this tutorial you will drill a hole in the root filesystem, which is a security issue. Just so you know.
Here's how I do the programming (just learning QML at the moment, so I needed a procedure for very quick prototyping without the SDK). This is an example for a hypothetical application, called Oranges
. We will put its pure-QML code in a nicely accessible place, and then call it in the command-line. So here it is:
Create folder /home/nemo/Devel
. This folder will hold all your pure-QML projects. Inside /home/nemo/Devel
, create a folder Oranges
, to hold your project. Then create the following folders:
/home/nemo/Devel/Oranges/qml
/home/nemo/Devel/Oranges/qml/pages
/home/nemo/Devel/Oranges/qml/cover
Inside /home/nemo/Devel/Oranges/qml
, put the file Oranges.qml
. This is the main file of your application, and must have the same name as your application - it's a rule in SailfishOS (maybe MeeGo too?). Inside Oranges.qml
, copy this:
import QtQuick 2.0
import Sailfish.Silica 1.0
import "pages"
ApplicationWindow
{
initialPage: Component { MyFirstPage { } }
cover: Qt.resolvedUrl("cover/CoverPage.qml")
}
Of course, this is the standard ApplicationWindow
definition, like in any SailfishOS app. It's all you need. Don't forget to also create the QML files /home/nemo/Devel/Oranges/qml/pages/MyFirstPage.qml
, and /home/nemo/Devel/Oranges/qml/cover/CoverPage.qml
, and put nice things in them to impress your users.
Now the best parts:
- Open the terminal, and go root.
ln -s /home/nemo/Devel/Oranges /usr/share/Oranges
(you will do this for every project you put into your Devel
folder. This is a security hole, since any app can maliciously overwrite your files in /home/nemo/Devel/Oranges
with bad QML code, and that code will be executed by SailfishOS without discrimination) - Ctrl-D to exit root.
- Now the fruity magic:
sailfish-qml Oranges
and your app starts! Or crashes when it has bugs, and QML will log everything to the terminal, of course.
What you achieved is this: now you have the project easily editable in your home and you can run it in the proper sailfishy way. sailfish-qml
will run your QML files as if they were a real app, respecting all conventions and giving you all the privileges that a full C++ SailfishOS app would have. Well, at least all that's available through the QML API. Moreover, your source is on your phone all the time, so you can edit it easily. If you have Linux + KDE, you can transparently access the phone's filesystem through SFTP (did you know that it supports SFTP, and it's enabled by default? it's awesome! :D) like it would be mounted as a partition, thanks to KDE's awesome KIO framework. So you edit the files directly on the phone, live, with your favourite editor.
If someone could give some instructions about how to create a custom Launcher icon for Oranges
, that would be awesome.
Keep the dry side up and the wet side down!
You need to cross compile for ARM, and you need the same environment (packages etc.) that are installed on the phone. Using a VM for this is really a no-brainer, so I don't really get your point. If it's only QML, you can probably "deploy" directly (make an RPM package), though you won't be able to test without the Silica components.
dthierbach ( 2014-10-15 22:37:09 +0200 )editMartinK, could you click on "convert to answer" so I could vote for it ? :)
charlycoste ( 2014-10-19 20:38:08 +0200 )edit@charlycoste: Sure! :)
MartinK ( 2014-10-19 23:28:57 +0200 )edit