Add About Dialog.
authorNguyễn Hồng Quân <ng.hong.quan@gmail.com>
Tue, 30 Oct 2012 05:30:16 +0000 (12:30 +0700)
committerNguyễn Hồng Quân <ng.hong.quan@gmail.com>
Tue, 30 Oct 2012 05:30:16 +0000 (12:30 +0700)
about.cpp [new file with mode: 0644]
about.h [new file with mode: 0644]
icons/mverbiste160.png [new file with mode: 0644]
mainwindow.cpp
mainwindow.h
mverbiste.pro

diff --git a/about.cpp b/about.cpp
new file mode 100644 (file)
index 0000000..f8d45c6
--- /dev/null
+++ b/about.cpp
@@ -0,0 +1,41 @@
+#include "about.h"
+
+AboutDialog::AboutDialog(const char *iconFile, const char *title)
+    : QDialog()
+{
+    setWindowTitle(title);
+    QHBoxLayout *mlayout = new QHBoxLayout();
+    QLabel *iconshow = new QLabel();
+    iconshow->setPixmap(QPixmap(iconFile));
+
+    rlayout = new QVBoxLayout();
+    mlayout->addWidget(iconshow);
+    mlayout->addLayout(rlayout);
+    setLayout(mlayout);
+}
+
+void AboutDialog::setIntro(const QString &text)
+{
+    // Place to the first item of rlayout
+    if (rlayout->count() == 0) {
+        // No item yet, add one
+        rlayout->addWidget(new QLabel(text));
+    }
+    else {
+        // First item has existed, replace it.
+        QWidget *child = (QWidget *)rlayout->itemAt(0);
+        rlayout->removeWidget(child);
+        rlayout->insertWidget(0, new QLabel(text));
+    }
+}
+
+void AboutDialog::addAuthor(const QString &name)
+{
+    // Place from the second item of rlayout
+    if (rlayout->count() == 0) {
+        // No first item, add empty one.
+        rlayout->addWidget(new QLabel(""));
+    }
+    // Add from the second
+    rlayout->addWidget(new QLabel(name));
+}
diff --git a/about.h b/about.h
new file mode 100644 (file)
index 0000000..c913b31
--- /dev/null
+++ b/about.h
@@ -0,0 +1,21 @@
+#ifndef ABOUT_H
+#define ABOUT_H
+
+#include <QtGui/QDialog>
+#include <QtGui/QHBoxLayout>
+#include <QtGui/QLabel>
+
+class AboutDialog: public QDialog
+{
+    Q_OBJECT
+public:
+    explicit AboutDialog(const char *iconFile, const char *title);
+
+    void setIntro(const QString &text);
+    void addAuthor(const QString &name);
+
+private:
+    QVBoxLayout *rlayout;
+};
+
+#endif // ABOUT_H
diff --git a/icons/mverbiste160.png b/icons/mverbiste160.png
new file mode 100644 (file)
index 0000000..8eb903b
Binary files /dev/null and b/icons/mverbiste160.png differ
index 9ed6d6c..2ae5a60 100644 (file)
@@ -42,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, "MVerbiste");
+    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)
index c02a6cb..49aa76f 100644 (file)
@@ -9,6 +9,7 @@
 #include <QtGui/QScrollArea>
 #include <QtGui/QLabel>
 #include <QtGui/QTableWidget>
+#include <QtGui/QMessageBox>
 
 /* Verbiste */
 #include <iostream>
@@ -16,6 +17,7 @@
 #include <string.h>
 #include <verbiste/FrenchVerbDictionary.h>
 #include "gui/conjugation.h"
+#include "about.h"
 
 #ifndef QT_NO_DEBUG
 #include <QtCore/QDebug>
@@ -65,9 +67,9 @@ public:
     void showExpanded();
     void initverbiste();
     QVBoxLayout* makeResultCell(const VVS &tenseIterator,
-                                     const std::string &tenseName,
-                                     const std::string &inputWord,
-                                     FrenchVerbDictionary *verbDict);
+                                const std::string &tenseName,
+                                const std::string &inputWord,
+                                FrenchVerbDictionary *verbDict);
 
 public slots:
     void startLookup();
@@ -81,8 +83,10 @@ private:
     QPushButton *btnClear;           // Clear button
     QLineEdit   *wordinput;          //  Word input
     QPushButton *btnLookup;          // Lookup button
+    QMessageBox *msgbox;
     std::string langCode;
     FrenchVerbDictionary *freVerbDic;
+    AboutDialog *aboutDialog;
 
     ResultPage* addResultPage(const std::string &labelText);
 #ifndef QT_NO_DEBUG
index 0e6f13e..62e1007 100644 (file)
@@ -2,8 +2,9 @@
 # by adapting the examples below.
 # file1.source = myfile
 # dir1.source = mydir
-DEPLOYMENTFOLDERS = xmldata # file1 dir1
+DEPLOYMENTFOLDERS = xmldata icon # file1 dir1
 xmldata.source = data
+icon.source = icons
 
 symbian:TARGET.UID3 = 0xE214283E
 
@@ -28,13 +29,15 @@ SOURCES += main.cpp mainwindow.cpp \
     verbiste/misc-types.cpp \
     verbiste/FrenchVerbDictionary.cpp \
     verbiste/c-api.cpp \
-    gui/conjugation.cpp
+    gui/conjugation.cpp \
+    about.cpp
 HEADERS += mainwindow.h \
     verbiste/Trie.h \
     verbiste/misc-types.h \
     verbiste/FrenchVerbDictionary.h \
     verbiste/c-api.h \
-    gui/conjugation.h
+    gui/conjugation.h \
+    about.h
 FORMS += mainwindow.ui
 
 # Please do not modify the following two lines. Required for deployment.
@@ -59,22 +62,23 @@ OTHER_FILES += \
     verbiste/Makefile.in \
     verbiste/Makefile.am \
     gui/Makefile.in \
-    gui/Makefile.am
+    gui/Makefile.am \
+    icons/mverbiste.svg \
+    icons/mverbiste160.png
 
 # To build verbiste
 unix: CONFIG += link_pkgconfig
 unix: PKGCONFIG += libxml-2.0
 
+# For verbiste
 DEFINES += ICONV_CONST=
 
-simulator {
-    DEFINES += LIBDATADIR=\\\"$$PWD/data\\\"
-}
-
 simulator {    # Build to run on simulator.
     DEFINES += LIBDATADIR=\\\"$$PWD/data\\\"
+    DEFINES +=ICONFILE=\\\"$$PWD/icons/mverbiste160.png\\\"
 }
 else {
     # installPrefix must be explicitly exported from deployment.pri first
     DEFINES += LIBDATADIR=\\\"$${installPrefix}/data\\\"
+    DEFINES +=ICONFILE=\\\"$${installPrefix}/icons/mverbiste160.png\\\"
 }