QtComponents/Miniature

Miniature is a chess game currently maintained by Michael Hasselmann and Quim Gil and targeted to Harmattan devices. See more about it on Miniature page.

I'm going to make use of this project as an example of the required changes to get it working on Fremantle

Contents

[edit] Fetch sources

Get master code from repo following intructions at Miniature/Development

[edit] Refactor QML files

QtComponents use its own namespace inside fremantle. you need to replace:

QtQuick 1.1 QtQuick 1.0
com.nokia.meego 1.0 org.maemo.fremantle 1.0
com.nokia.extras 1.0 org.maemo.extras 1.0
Qt.labs.components 1.1 Qt.labs.components 1.0

[edit] Change meego namespace by fremantle one

There is a simple script to do this task located at gitorious. invoke inside miniature directory as:

<syntaxhighlight lang="bash"> migrateTo --fremantle '*.qml' </syntaxhighlight>

[edit] Remove QtQuick 1.1 code

After that, you should lookup for QtQuick 1.1 properties. In current upstream code threre's no one. :). The easiest way to achieve this is to use QtSimulator 1.1 and try to run code inside it. See QtComponents/Simulator to know how to get QtComponents running on QtSimulator.

commit.

[edit] Handle Close events

QtComponents uses Qt.quit() event to notify application backends that user has requested to close window. Miniature doesn't handle this event on its own, so we need to add it.

First, lookup for a DeclarativeView or 'show' call inside miniature directory. A grep command point us to miniature.cc file. We add a close Slot to deal with Qt.quit() event.

<syntaxhighlight lang="diff"> diff --git a/game/frontend/miniature.cc b/game/frontend/miniature.cc index 4735a72..769f8ee 100644 --- a/game/frontend/miniature.cc +++ b/game/frontend/miniature.cc @@ -150,6 +150,9 @@ Miniature::Miniature(Dispatcher *dispatcher,

    d->ui.rootContext()->setContextProperty("localSide", &d->local_side);
    d->ui.rootContext()->setContextProperty("remoteSide", &d->remote_side);
    d->ui.rootContext()->setContextProperty("activeGame", &d->game_element);

+ + connect(d->ui.engine(), SIGNAL(quit()), this, SLOT(quit()), Qt::UniqueConnection); +

#endif

    d->command_line.setFlags(all_commands);

@@ -161,6 +164,12 @@ Miniature::Miniature(Dispatcher *dispatcher,

Miniature::~Miniature()
{}

+void Miniature::quit() +{ + Q_D(Miniature); + d->command_line.processToken(QByteArray("quit")); +} + void Miniature::show(const QUrl &ui) {

    Q_D(Miniature);

diff --git a/game/frontend/miniature.h b/game/frontend/miniature.h index c4e7e91..42f4f28 100644 --- a/game/frontend/miniature.h +++ b/game/frontend/miniature.h @@ -201,6 +201,7 @@ public:

private:    
    void sendCommand(AbstractCommand *command);
    Q_SLOT void onPositionChanged(const Position &position);

+ Q_SLOT void quit();

};

}} // namespace Game, Frontend

</syntaxhighlight>

commit

[edit] Adapt deployment to Fremantle

Some changes on how miniature is deployed are needed to match Fremantle.

[edit] Optify code

use a PREFIX config variable to change default target dir from /usr to /opt. Also update locations of desktop and icon applications

<syntaxhighlight lang="diff"> diff --git a/config.pri b/config.pri index 1c955c4..31be944 100644 --- a/config.pri +++ b/config.pri @@ -8,6 +8,13 @@ GAME_DIR = $${DIR_PREFIX}/game

SRC_DIR = $${DIR_PREFIX}/src
TESTS_DIR = $${DIR_PREFIX}/tests

+isEmpty( PREFIX ) { + PREFIX = /usr + maemo5 { + PREFIX = /opt + } +} +

enable-gui {
    DEFINES += MINIATURE_GUI_ENABLED
}
diff --git a/src/src.pro b/src/src.pro

index fca7c29..bf35139 100644 --- a/src/src.pro +++ b/src/src.pro @@ -89,7 +89,7 @@ LIBS += \

}

-target.path = /usr/games +target.path = $${PREFIX}/games

target.depends += \
    $${IN_PWD}/frontend/frontend.qrc \
    $${IN_PWD}/frontend/MainPage.qml \

@@ -104,10 +104,10 @@ target.depends += \

    $${IN_PWD}/frontend/SeekGame.qml \

desktop.files = ../miniature.desktop

-desktop.path = /usr/share/applications +desktop.path = /usr/share/applications/hildon

icon.files = $${TARGET}-n9.png

-icon.path = /usr/share/themes/base/meegotouch/icons/ +icon.path = /usr/share/icons/hicolor/64x64/

INSTALLS += \
    target \

</syntaxhighlight>

[edit] Update Desktop file

And finally, update desktop file. There's no applauncerd on fremantle, so remove invoker from Exec.

<syntaxhighlight lang="diff"> diff --git a/miniature.desktop b/miniature.desktop index dc88397..9f29209 100644 --- a/miniature.desktop +++ b/miniature.desktop @@ -4,5 +4,5 @@ Version=1.0

Terminal=false
Type=Application
Name=Miniature

-Exec=invoker --single-instance --type=d /usr/games/miniature -Icon=/usr/share/themes/base/meegotouch/icons/miniature-n9.png +Exec=/opt/games/miniature +Icon=miniature-n9 diff --git a/src/src.pro b/src/src.pro index 1b1356c..f42a6f9 100644 --- a/src/src.pro +++ b/src/src.pro @@ -95,7 +95,7 @@ LIBS += \

}

</syntaxhighlight>

commit

[edit] Update packing scripts

Now that all required changes are commited. generate patches with <syntaxhighlight lang="bash">git format-patch origin/master</syntaxhighlight> and copy generated files into debian/patches directory.

Finally, modify rules file at debian directory to merge patches. At config-stamp rule add: <syntaxhighlight lang="make">for p in debian/patches/*; do patch -p1 < $$p; done </syntaxhighlight>

And thats all. You have upstream miniature working on Maemo5