load mission caption and description from localization file (WIP)
authorsheepluva
Wed, 28 Sep 2011 04:21:24 +0200
changeset 6058 ae8684864a6e
parent 6056 a60e603ef8ef
child 6059 ddf020d0941a
load mission caption and description from localization file (WIP)
QTfrontend/pagetraining.cpp
QTfrontend/pagetraining.h
--- a/QTfrontend/pagetraining.cpp	Wed Sep 28 04:17:41 2011 +0200
+++ b/QTfrontend/pagetraining.cpp	Wed Sep 28 04:21:24 2011 +0200
@@ -23,6 +23,8 @@
 #include <QListWidgetItem>
 #include <QPushButton>
 
+#include <QSettings>
+
 #include "pagetraining.h"
 #include "hwconsts.h"
 
@@ -108,6 +110,10 @@
 {
     initPage();
 
+    // preload localized descriptions/etc  TODO; this is just mockup code
+    m_info = new QSettings(datadir->absolutePath() + "/Locale/missions_en.txt",
+                           QSettings::IniFormat, this);
+
 //  TODO -> this should be done in a tool "DataDir" class
     QDir tmpdir;
     tmpdir.cd(cfgdir->absolutePath());
@@ -127,7 +133,7 @@
             missionList.append(mission);
     }
 
-    // add only default scripts that have names different from detected user scripts
+    // add default scripts that have names different from detected user scripts
     foreach (const QString & mission, missionList)
     {
         QListWidgetItem * item = new QListWidgetItem(mission);
@@ -170,15 +176,27 @@
     if (lstMissions->currentItem())
     {
         // TODO also use .pngs in userdata folder
-        QString thumbFile = datadir->absolutePath() + "/Graphics/Missions/Training/" + lstMissions->currentItem()->data(Qt::UserRole).toString() + ".png";
+        QString thumbFile = datadir->absolutePath() +
+                    "/Graphics/Missions/Training/" +
+                    lstMissions->currentItem()->data(Qt::UserRole).toString() +
+                    ".png";
+
         if (QFile::exists(thumbFile))
             btnPreview->setIcon(QIcon(thumbFile));
         else
             btnPreview->setIcon(QIcon(":/res/Trainings.png"));
 
-        lblCaption->setText("<h2>" + lstMissions->currentItem()->text()+"</h2>");
-        // TODO load mission description from file
-        lblDescription->setText("< Imagine Mission Description here >\n\nThank you.");
+        QString realName = lstMissions->currentItem()->data(
+                           Qt::UserRole).toString();
+
+        QString caption = m_info->value(realName + ".name", 
+                          lstMissions->currentItem()->text()).toString();
+
+        QString description = m_info->value(realName + ".desc",
+                              tr("No description available")).toString();
+
+        lblCaption->setText("<h2>" + caption +"</h2>");
+        lblDescription->setText(description);
     }
     else
     {
--- a/QTfrontend/pagetraining.h	Wed Sep 28 04:17:41 2011 +0200
+++ b/QTfrontend/pagetraining.h	Wed Sep 28 04:21:24 2011 +0200
@@ -47,6 +47,7 @@
     QLabel * lblCaption;
     QLabel * lblDescription;
     QListWidget * lstMissions;
+    QSettings * m_info;
 
     QStringList scriptList(const QDir & scriptDir) const;