qmlFrontend/hwengine.cpp
branchqmlfrontend
changeset 10434 1614b13ad35e
parent 10432 b0abef0ee78c
child 10436 084e046f6bd5
--- a/qmlFrontend/hwengine.cpp	Sun Sep 28 21:33:14 2014 +0400
+++ b/qmlFrontend/hwengine.cpp	Tue Sep 30 00:54:04 2014 +0400
@@ -16,6 +16,8 @@
     runQuickGame_t *flibRunQuickGame;
     flibInit_t *flibInit;
     flibFree_t *flibFree;
+    getThemesList_t *flibGetThemesList;
+    freeThemesList_t *flibFreeThemesList;
 }
 
 Q_DECLARE_METATYPE(MessageType);
@@ -40,8 +42,13 @@
     flibInit = (flibInit_t*) hwlib.resolve("flibInit");
     flibFree = (flibFree_t*) hwlib.resolve("flibFree");
 
-    flibInit("/usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GC/share/hedgewars/Data", "~/.hedgewars");
+    flibGetThemesList = (getThemesList_t*) hwlib.resolve("getThemesList");
+    flibFreeThemesList = (freeThemesList_t*) hwlib.resolve("freeThemesList");
+
+    flibInit("/usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GC/share/hedgewars/Data", "/usr/home/unC0Rr/.hedgewars");
     flibRegisterGUIMessagesCallback(this, &guiMessagesCallback);
+
+    fillModels();
 }
 
 HWEngine::~HWEngine()
@@ -102,3 +109,18 @@
 {
     return QString::fromLatin1(flibGetSeed());
 }
+
+void HWEngine::fillModels()
+{
+    QStringList resultModel;
+
+    char ** themes = flibGetThemesList();
+    for (char **i = themes; *i != NULL; i++) {
+        QString theme = QString::fromUtf8(*i);
+
+        resultModel << theme;
+    }
+    flibFreeThemesList(themes);
+
+    m_engine->rootContext()->setContextProperty("themesModel", QVariant::fromValue(resultModel));
+}