From: Nguyễn Hồng Quân Date: Wed, 14 Nov 2012 07:45:40 +0000 (+0700) Subject: Allow to lookup Italian verbs and show pronouns. X-Git-Url: http://git.maemo.org/git/?p=mverbiste;a=commitdiff_plain;h=c25581650ae1b331ada3a98d19aae51ce9edc75b Allow to lookup Italian verbs and show pronouns. --- diff --git a/mainwindow.cpp b/mainwindow.cpp index 9e227d4..05b75ff 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -22,15 +22,18 @@ void MainWindow::setupcodedUI() btlayout = new QHBoxLayout; resultPages = new QTabWidget; - resultPages->setTabPosition(QTabWidget::West); + resultPages->setStyleSheet("QTabBar::tab { height: 50px }"); mlayout->addWidget(resultPages); - btnClear = new QPushButton; + btnPron = new QCheckBox(); + btnPron->setIcon(QIcon("/usr/share/icons/hicolor/48x48/hildon/general_conference_avatar.png")); + btnClear = new QPushButton; /* Clearbutton */ btnClear->setIcon(QIcon("/usr/share/icons/hicolor/64x64/hildon/general_delete.png")); - wordinput = new QLineEdit; + wordinput = new QLineEdit; /* Word input */ + btlayout->addWidget(btnPron); btlayout->addWidget(btnClear); btlayout->addWidget(wordinput); - btnLookup = new QPushButton; // Lookup button + btnLookup = new QPushButton; /* Lookup button */ btnLookup->setIcon(QIcon("/usr/share/icons/hicolor/64x64/hildon/general_search.png")); btlayout->addWidget(btnLookup); @@ -42,6 +45,7 @@ void MainWindow::setupcodedUI() connect(wordinput, SIGNAL(returnPressed()), this, SLOT(startLookup())); connect(btnLookup, SIGNAL(clicked()), this, SLOT(startLookup())); + connect(btnPron, SIGNAL(clicked()), this, SLOT(startLookup())); /* Icon */ QIcon *icon = new QIcon(); @@ -57,6 +61,17 @@ void MainWindow::setupcodedUI() QMenu *menu = ui->menuBar->addMenu(tr("Top menu")); QAction *act_about = menu->addAction(tr("About")); connect(act_about, SIGNAL(triggered()), aboutDialog, SLOT(show())); + /* Menu filters */ + QActionGroup *filterGroup = new QActionGroup(this); + filterGroup->setExclusive(true); + filFrench = new QAction(tr("Search French"), filterGroup); + filFrench->setCheckable(true); + filFrench->setChecked(true); + filItalian = new QAction(tr("Search Italian"), filterGroup); + filItalian->setCheckable(true); + menu->addActions(filterGroup->actions()); + connect(filItalian, SIGNAL(changed()), this, SLOT(switchLang())); + connect(filFrench, SIGNAL(changed()), this, SLOT(switchLang())); } MainWindow::~MainWindow() @@ -136,6 +151,21 @@ void MainWindow::initverbiste() freVerbDic = new FrenchVerbDictionary(true); } +void MainWindow::switchLang() +{ + FrenchVerbDictionary::Language curlang = freVerbDic->getLanguage(); + FrenchVerbDictionary::Language targetlang = filItalian->isChecked() ? FrenchVerbDictionary::ITALIAN + : FrenchVerbDictionary::FRENCH; + if (curlang == targetlang) { + return; + } + /* If lang change */ + std::string conjFN, verbsFN; + FrenchVerbDictionary::getXMLFilenames(conjFN, verbsFN, targetlang); + delete freVerbDic; + freVerbDic = new FrenchVerbDictionary(conjFN, verbsFN, true, targetlang); +} + void MainWindow::startLookup() { QString input = wordinput->text().trimmed(); @@ -157,8 +187,8 @@ void MainWindow::startLookup() * obtain its complete conjugation. */ std::vector infles; - bool includePronouns = FALSE; // TODO: Will get this value from external - bool isItalian = FALSE; // TODO: Will get this value from external + bool includePronouns = btnPron->isChecked(); + bool isItalian = filItalian->isChecked(); // TODO: Will get this value from external #ifndef QT_NO_DEBUG timer.start(); diff --git a/mainwindow.h b/mainwindow.h index 49aa76f..2cc62cc 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -4,12 +4,18 @@ #include #include #include +#include #include #include #include #include #include #include +#include + +#if defined(Q_WS_MAEMO_5) +#include +#endif /* Verbiste */ #include @@ -73,6 +79,7 @@ public: public slots: void startLookup(); + void switchLang(); private: Ui::MainWindow *ui; @@ -81,8 +88,11 @@ private: QTabWidget *resultPages; QHBoxLayout *btlayout; // Layout to pack the functional buttons QPushButton *btnClear; // Clear button + QCheckBox *btnPron; QLineEdit *wordinput; // Word input QPushButton *btnLookup; // Lookup button + QAction *filFrench; + QAction *filItalian; QMessageBox *msgbox; std::string langCode; FrenchVerbDictionary *freVerbDic; diff --git a/mverbiste.pro b/mverbiste.pro index 7e2058d..624e552 100644 --- a/mverbiste.pro +++ b/mverbiste.pro @@ -77,3 +77,7 @@ else { DEFINES += LIBDATADIR=\\\"$${installPrefix}/data\\\" DEFINES +=ICONFILE=\\\"$${installPrefix}/icons/mverbiste160.png\\\" } + +maemo5 { + QT += maemo5 +}