Add version info to About Dialog.
[mverbiste] / mainwindow.cpp
index f194fc1..2496c75 100644 (file)
@@ -13,7 +13,6 @@ MainWindow::MainWindow(QWidget *parent)
 #endif
     ui->setupUi(this);
     setupcodedUI();
-    initverbiste();
 }
 
 void MainWindow::setupcodedUI()
@@ -43,12 +42,28 @@ void MainWindow::setupcodedUI()
 
     connect(wordinput, SIGNAL(returnPressed()), this, SLOT(startLookup()));
     connect(btnLookup, SIGNAL(clicked()), this, SLOT(startLookup()));
+
+    /* Icon */
+    QIcon *icon = new QIcon();
+    icon->addFile(ICONFILE);
+    setWindowIcon(*icon);
+
+    /* About Dialog */
+    aboutDialog = new AboutDialog(ICONFILE, QString("MVerbiste v%1").arg(VERSTR));
+    aboutDialog->setIntro(trUtf8("A French conjugation utility for Maemo and MeeGo"));
+    aboutDialog->addAuthor(QString::fromUtf8("Nguyễn Hồng Quân <ng.hong.quan@gmail.com>\nPierre Sarrazin <sarrazip@sarrazip.com>"));
+
+    /* Menu */
+    QMenu *menu = ui->menuBar->addMenu(tr("Top menu"));
+    QAction *act_about = menu->addAction(tr("About"));
+    connect(act_about, SIGNAL(triggered()), aboutDialog, SLOT(show()));
 }
 
 MainWindow::~MainWindow()
 {
     delete ui;
     delete freVerbDic;
+    delete aboutDialog;
 }
 
 void MainWindow::setOrientation(ScreenOrientation orientation)
@@ -103,6 +118,7 @@ void MainWindow::showExpanded()
 #else
     show();
 #endif
+    initverbiste();
     wordinput->setFocus();
 }
 
@@ -144,6 +160,10 @@ void MainWindow::startLookup()
     bool includePronouns = FALSE;    // TODO: Will get this value from external
     bool isItalian = FALSE;          // TODO: Will get this value from external
 
+#ifndef QT_NO_DEBUG
+    timer.start();
+    qDebug() << "Start " << timer.elapsed();
+#endif
     freVerbDic->deconjugate(word, infles);
 
     resultPages->setUpdatesEnabled(false);
@@ -171,7 +191,18 @@ void MainWindow::startLookup()
          */
 
         VVVS conjug;
-        getConjugation(freVerbDic, d.infinitive, d.templateName, conjug, includePronouns);
+#ifndef QT_NO_DEBUG
+        qDebug() << "   START getConjugation " << timer.elapsed();
+#endif
+        getConjugation(freVerbDic, d.infinitive, d.templateName, conjug,
+               #ifndef QT_NO_DEBUG
+                       timer,
+               #endif
+                       includePronouns);
+
+#ifndef QT_NO_DEBUG
+        qDebug() << "   getConjugation() returns: " << timer.elapsed();
+#endif
 
         if (conjug.size() == 0           // if no tenses
             || conjug[0].size() == 0     // if no infinitive tense
@@ -183,8 +214,7 @@ void MainWindow::startLookup()
 
         std::string utf8Infinitive = conjug[0][0][0];
 #ifndef QT_NO_DEBUG
-        qDebug() << "   getConjugation() returns:";
-        qDebug() << "     Infinitive " << utf8Infinitive.c_str() << " at " << timer.elapsed();
+        qDebug() << "     Infinitive " << utf8Infinitive.c_str();
         qDebug() << "     Template " << d.templateName.c_str();
 #endif
 
@@ -211,11 +241,13 @@ void MainWindow::startLookup()
             QVBoxLayout *cell = makeResultCell(*t, utf8TenseName, word, freVerbDic);
             rsp->grid->addLayout(cell, row, col);
         }
+
         /* Show the result on GUI */
         rsp->packContent();
         prevUTF8Infinitive = utf8Infinitive;
         prevTemplateName = d.templateName;
     }
+
     /* Enable the button again */
     btnLookup->setEnabled(true);
     btnLookup->setText("");