google translation can be added to bookmark
[mdictionary] / src / mdictionary / gui / MainWindow.cpp
index a26c999..51384d6 100644 (file)
@@ -47,11 +47,14 @@ MainWindow::MainWindow(Backbone *backbone, QWidget *parent):
 
     setExactSearch(false);
 
+    setMinimumSize(750, 400);
+
     showMaximized();
+
+    searchBarWidget->setFocus();
 }
 
 MainWindow::~MainWindow() {
-
 }
 
 
@@ -62,9 +65,6 @@ void MainWindow::initializeUI() {
     #endif
 
 
-    setWindowIcon(QIcon(":/icons/64x64/mdictionary.png"));
-    setWindowTitle("mDictionary");
-
     /*translationWidget is another stacked window, so we don't add it to
       layout, only create it with this widget as parent
       it must be created as first object in main window, otherwise sometimes
@@ -72,6 +72,12 @@ void MainWindow::initializeUI() {
       it segfaults*/
     translationWidget = new TranslationWidget(this);
 
+
+
+
+    setWindowIcon(QIcon(":/icons/64x64/mdictionary.png"));
+    setWindowTitle("mDictionary");
+
     mainLayout = new QVBoxLayout();
     QWidget* w = new QWidget();
     w->setLayout(mainLayout);
@@ -106,8 +112,8 @@ 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
 }
 
@@ -127,15 +133,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);
@@ -143,7 +149,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()));
 
@@ -157,6 +163,9 @@ void MainWindow::initializeMenuWidgets() {
     settingsWidget = new SettingsWidget(this);
     settingsWidget->hide();
 
+    connect(settingsWidget, SIGNAL(notify(Notify::NotifyType,QString)),
+            this, SLOT(showNotification(Notify::NotifyType,QString)));
+
     bookmarksWidget = new BookmarksWidget(this);
     bookmarksWidget->hide();
 
@@ -222,6 +231,8 @@ void MainWindow::wordListReady() {
             setExactSearch(false);
         }
     }
+
+    wordListWidget->setFocus();
 }
 
 bool MainWindow::checkExactSearch(
@@ -245,8 +256,11 @@ void MainWindow::translationsReady() {
         hideWelcomeScreen();
     #endif
 
-    Q_EMIT showTranslation(backbone->htmls());
-    notifyManager->screenChanged();
+    Q_EMIT showTranslation(backbone->xmls());
+    wordListWidget->setFocus();
+    #ifdef Q_WS_MAEMO_5
+        notifyManager->screenChanged();
+    #endif
 }
 
 
@@ -281,6 +295,12 @@ QHash<CommonDictInterface*, bool> MainWindow::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) {
@@ -405,7 +425,7 @@ void MainWindow::connectBackbone() {
             backbone, SLOT(search(QString)));
 
     connect(this, SIGNAL(searchTranslations(QList<Translation*>)),
-            backbone, SLOT(searchHtml(QList<Translation*>)));
+            backbone, SLOT(searchXml(QList<Translation*>)));
 
     connect(this, SIGNAL(stopSearching()),
             backbone, SLOT(stopSearching()));
@@ -426,14 +446,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()),
@@ -441,6 +461,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<Translation*>)),
+    //       this, SIGNAL(setBusy()));
+
+    //connect(backbone, SIGNAL(bookmarkReady()),
+    //        this, SIGNAL(setIdle()));
 }
 
 void MainWindow::connectSearchBar() {
@@ -504,12 +534,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() {
@@ -535,7 +567,7 @@ void MainWindow::connectMenu() {
 
 void MainWindow::connectBookmarksWidget() {
     #ifdef Q_WS_MAEMO_5
-        //after removing bookmarks we search for them once again to clear word list
+        //after removing bookmarks we search for them once again to clear the words list
         connect(bookmarksWidget, SIGNAL(removeAllBookmarks()),
                 this, SLOT(removeBookmarks()));
 
@@ -565,11 +597,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();
-        if(searchString.size())
-            backbone->search(searchString);
-
+        ((WordListWidget*)wordListWidget)->clear();
     }
+
+
 }