From 5193e53ba89b72f9760af7c8a02aab2f645d9c08 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?= Date: Tue, 30 Oct 2012 14:52:25 +0700 Subject: [PATCH] Add version info to About Dialog. --- about.cpp | 27 +++++++++++++++------------ about.h | 2 +- mainwindow.cpp | 2 +- mverbiste.pro | 6 +++--- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/about.cpp b/about.cpp index f8d45c6..939c0e0 100644 --- a/about.cpp +++ b/about.cpp @@ -1,41 +1,44 @@ #include "about.h" -AboutDialog::AboutDialog(const char *iconFile, const char *title) +AboutDialog::AboutDialog(const char *iconFile, const QString &title) : QDialog() { - setWindowTitle(title); + setWindowTitle("About"); QHBoxLayout *mlayout = new QHBoxLayout(); QLabel *iconshow = new QLabel(); iconshow->setPixmap(QPixmap(iconFile)); + mlayout->addWidget(iconshow); rlayout = new QVBoxLayout(); - mlayout->addWidget(iconshow); + QLabel *tit = new QLabel(title); + tit->setStyleSheet("QLabel {font-size: 40px}"); + rlayout->addWidget(tit); mlayout->addLayout(rlayout); setLayout(mlayout); } void AboutDialog::setIntro(const QString &text) { - // Place to the first item of rlayout - if (rlayout->count() == 0) { + // Place to the second item of rlayout + if (rlayout->count() == 1) { // 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); + // Second item has existed, replace it. + QWidget *child = (QWidget *)rlayout->takeAt(0); + delete 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. + // Place from the third item of rlayout + if (rlayout->count() == 1) { + // No second item, add empty one. rlayout->addWidget(new QLabel("")); } - // Add from the second + // Add from the third rlayout->addWidget(new QLabel(name)); } diff --git a/about.h b/about.h index c913b31..96bcd29 100644 --- a/about.h +++ b/about.h @@ -9,7 +9,7 @@ class AboutDialog: public QDialog { Q_OBJECT public: - explicit AboutDialog(const char *iconFile, const char *title); + explicit AboutDialog(const char *iconFile, const QString &title); void setIntro(const QString &text); void addAuthor(const QString &name); diff --git a/mainwindow.cpp b/mainwindow.cpp index 2ae5a60..2496c75 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -49,7 +49,7 @@ void MainWindow::setupcodedUI() setWindowIcon(*icon); /* About Dialog */ - aboutDialog = new AboutDialog(ICONFILE, "MVerbiste"); + 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 \nPierre Sarrazin ")); diff --git a/mverbiste.pro b/mverbiste.pro index 62e1007..abce02a 100644 --- a/mverbiste.pro +++ b/mverbiste.pro @@ -62,14 +62,14 @@ OTHER_FILES += \ verbiste/Makefile.in \ verbiste/Makefile.am \ gui/Makefile.in \ - gui/Makefile.am \ - icons/mverbiste.svg \ - icons/mverbiste160.png + gui/Makefile.am # To build verbiste unix: CONFIG += link_pkgconfig unix: PKGCONFIG += libxml-2.0 +DEFINES += VERSTR=\\\"1.0\\\" + # For verbiste DEFINES += ICONV_CONST= -- 1.7.9.5