QtComponents/Miniature

m (New page: '''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 this ...)
m
Line 7: Line 7:
== Refactor QML files ==
== Refactor QML files ==
-
QtComponents use its own namespace inside fremantle. you need to replace  
+
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
 +
|}
=== Change meego namesapce by fremantle one ===
=== Change meego namesapce by fremantle one ===
Line 18: Line 29:
</syntaxhighlight>
</syntaxhighlight>
-
After that, you should lookup for '''QtQuick 1.1''' properties. In current upstream code threre's no one. :)
+
=== 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.
commit.
 +
== Handle Close events ==
 +
<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);
 +
+
 +
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>
-
=== Remove QtQuick 1.1  code ===
+
 
 +
<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/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 += \
 +
 +
}
 +
 +
-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 = $${PREFIX}/share/icons/hicolor/64x64/
 +
 +
INSTALLS += \
 +
    target \
 +
</syntaxhighlight>
-
== Handle Close events ==
 
== Update packing scripts ==
== Update packing scripts ==

Revision as of 15:58, 12 September 2011

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 this project as an example of the required changes to get it working on Fremantle

Contents

Fetch sources

Get master code from repo following intructions at Miniature/Development

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

Change meego namesapce 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>

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.

Handle Close events

<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); + 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>


<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/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 += \

}

-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 = $${PREFIX}/share/icons/hicolor/64x64/

INSTALLS += \
    target \

</syntaxhighlight>



Update packing scripts