X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmdictionary%2Fgui%2FMainWindow.cpp;h=e5a0b61c5eff6ea99543ec6187e7e2eefd10ec36;hb=5ff31a8e7a9f8d8a42d29a00882adcad16eedbdc;hp=771b97a5b052a25d5a24098288d7d0f37006e7c5;hpb=613dcf1e9d4177cf67153c7ef92fa0f466d77b21;p=mdictionary diff --git a/src/mdictionary/gui/MainWindow.cpp b/src/mdictionary/gui/MainWindow.cpp index 771b97a..e5a0b61 100644 --- a/src/mdictionary/gui/MainWindow.cpp +++ b/src/mdictionary/gui/MainWindow.cpp @@ -19,8 +19,11 @@ *******************************************************************************/ -//! \file MainWindow.cpp -//! \author Mateusz Półrola +/*! \file MainWindow.cpp + \brief Implements interface for GUI + + \author Mateusz Półrola +*/ #include "MainWindow.h" #include @@ -47,13 +50,14 @@ MainWindow::MainWindow(Backbone *backbone, QWidget *parent): setExactSearch(false); + setMinimumSize(750, 400); + showMaximized(); searchBarWidget->setFocus(); } MainWindow::~MainWindow() { - } @@ -111,8 +115,9 @@ void MainWindow::initializeSearchWidgets() { splitter->addWidget(welcomeScreenWidget); splitter->setStretchFactor(1, 150); - mainLayout->addWidget(splitter); - mainLayout->addWidget(searchBarWidget); + mainLayout->addWidget(splitter, 1); + + mainLayout->addWidget(searchBarWidget,0, Qt::AlignBottom); #endif } @@ -132,15 +137,15 @@ void MainWindow::initializeMenu() { connect(menuWidget, SIGNAL(setApplicationMenu(QWidget*)), notifyManager, SLOT(setMenu(QWidget*))); #else - dictionariesAction = menuBar->addAction(tr("Dictionaries")); + dictionariesAction = menuBar->addAction(tr("&Dictionaries")); connect(dictionariesAction, SIGNAL(triggered()), dictManagerWidget, SLOT(show())); - settingsAction = menuBar->addAction(tr("Settings")); + settingsAction = menuBar->addAction(tr("&Settings")); connect(settingsAction, SIGNAL(triggered()), settingsWidget, SLOT(show())); - QMenu* m = menuBar->addMenu(tr("Bookmarks")); + QMenu* m = menuBar->addMenu(tr("&Bookmarks")); bookmarksShowAllAction = new QAction(tr("Show all"), m); bookmarksRemoveAllAction = new QAction(tr("Remove all"), m); @@ -148,7 +153,7 @@ void MainWindow::initializeMenu() { m->addAction(bookmarksShowAllAction); m->addAction(bookmarksRemoveAllAction); - aboutAction = menuBar->addAction(tr("About")); + aboutAction = menuBar->addAction(tr("&About")); connect(aboutAction, SIGNAL(triggered()), aboutWidget, SLOT(show())); @@ -230,6 +235,8 @@ void MainWindow::wordListReady() { setExactSearch(false); } } + + wordListWidget->setFocus(); } bool MainWindow::checkExactSearch( @@ -253,7 +260,8 @@ void MainWindow::translationsReady() { hideWelcomeScreen(); #endif - Q_EMIT showTranslation(backbone->htmls()); + Q_EMIT showTranslation(backbone->xmls()); + wordListWidget->setFocus(); #ifdef Q_WS_MAEMO_5 notifyManager->screenChanged(); #endif @@ -287,10 +295,16 @@ QHash MainWindow::getDictionaries() { return backbone->getDictionaries(); } - +/**/ void MainWindow::search(QString word) { setExactSearch(false); searchBarWidget->search(word); + #ifdef Q_WS_MAEMO_5 + if(translationWidget->isVisible()) { + translationWidget->hide(); + update(); + } + #endif } void MainWindow::searchExact(QString word) { @@ -358,16 +372,11 @@ void MainWindow::enableMenu() { } void MainWindow::showHistory(QPoint p) { - - HistoryListDialog historyDialog(backbone->history()->list(), searchBarWidget); - + HistoryListDialog historyDialog(backbone->history()->list(), this );// searchBarWidget); #ifndef Q_WS_MAEMO_5 - QPoint newPos = mapFromGlobal(p); - newPos.setY(searchBarWidget->pos().y() - - historyDialog.sizeHint().height()); - newPos.setX(width() - historyDialog.sizeHint().width()); - - historyDialog.move(newPos); + p.setX(p.x() - historyDialog.sizeHint().width() + 5); + p.setY(p.y() - historyDialog.sizeHint().height() - 80); + historyDialog.move(p); #endif if(historyDialog.exec() == QDialog::Accepted) { @@ -415,7 +424,7 @@ void MainWindow::connectBackbone() { backbone, SLOT(search(QString))); connect(this, SIGNAL(searchTranslations(QList)), - backbone, SLOT(searchHtml(QList))); + backbone, SLOT(searchXml(QList))); connect(this, SIGNAL(stopSearching()), backbone, SLOT(stopSearching())); @@ -436,14 +445,14 @@ void MainWindow::connectBackbone() { connect(backbone, SIGNAL(ready()), this, SIGNAL(setIdle())); - connect(backbone, SIGNAL(htmlReady()), + connect(backbone, SIGNAL(xmlReady()), this, SIGNAL(setIdle())); connect(backbone, SIGNAL(ready()), this, SLOT(wordListReady())); - connect(backbone, SIGNAL(htmlReady()), + connect(backbone, SIGNAL(xmlReady()), this, SLOT(translationsReady())); connect(backbone, SIGNAL(searchCanceled()), @@ -451,6 +460,16 @@ void MainWindow::connectBackbone() { connect(backbone, SIGNAL(notify(Notify::NotifyType,QString)), this, SLOT(showNotification(Notify::NotifyType,QString))); + + connect(backbone, SIGNAL(closeOk()), + this, SLOT(close())); + + + //connect(wordListWidget, SIGNAL(addBookmark(QList)), + // this, SIGNAL(setBusy())); + + //connect(backbone, SIGNAL(bookmarkReady()), + // this, SIGNAL(setIdle())); } void MainWindow::connectSearchBar() { @@ -514,12 +533,14 @@ void MainWindow::connectTranslationWidget() { #ifdef Q_WS_MAEMO_5 connect(translationWidget, SIGNAL(search(QString)), this, SLOT(search(QString))); + + connect(translationWidget, SIGNAL(notify(Notify::NotifyType, QString)), + this, SLOT(showNotification(Notify::NotifyType,QString))); #else connect(translationWidget, SIGNAL(search(QString)), this, SLOT(searchExact(QString))); #endif - } void MainWindow::connectDictManager() { @@ -575,8 +596,11 @@ void MainWindow::removeBookmarks() { par = this; #endif if(QMessageBox::question(par, tr("Delete all bookmarks"), - tr("Do you want to delete all bookmarks? (This action cannot be revoked)"), + tr("Do you want to delete all bookmarks? (This action cannot be revoked, and will clear current word list)"), QMessageBox::Yes, QMessageBox::Cancel) == QMessageBox::Yes) { backbone->removeAllBookmarks(); + ((WordListWidget*)wordListWidget)->clear(); } + + }