Change of tool button
[mdictionary] / trunk / src / base / gui / MainWindow.cpp
index fac9d25..34fcec1 100644 (file)
@@ -46,6 +46,7 @@ MainWindow::MainWindow(Backbone *backbone, QWidget *parent):
     connectBookmarksWidget();
 
 
+
     setExactSearch(false);
 
     setWindowTitle("mDictionary");
@@ -176,11 +177,8 @@ void MainWindow::wordListReady() {
 
     //if nothing was found
     if(res.count() == 0) {
-        #ifdef Q_WS_MAEMO_5
-        QMaemo5InformationBox::information(this,
-                            tr("Can't find any matching words"),
-                            QMaemo5InformationBox::DefaultTimeout);
-        #endif
+        showNotify(Notify::Info, tr("Can't find any matching words"));
+
         //show empty list to remove results of old search
         emit showWordList(searchResult);
     }
@@ -211,11 +209,8 @@ void MainWindow::wordListReady() {
             }
 
             if(!foundExactMatch) {
-                #ifdef Q_WS_MAEMO_5
-                QMaemo5InformationBox::information(this,
-                                    tr("Can't find exactly matching word"),
-                                    QMaemo5InformationBox::DefaultTimeout);
-                #endif
+                showNotify(Notify::Info,
+                           tr("Can't find exactly matching word"));
 
                 emit showWordList(searchResult);
             }
@@ -229,7 +224,6 @@ void MainWindow::translationsReady() {
     #ifndef Q_WS_MAEMO_5
     //switch welcome screen with translation widget
     if(!translationWidget->isVisible()) {
-        int i = ui->centralWidget->layout()->indexOf(welcomeScreenWidget);
         QBoxLayout* l = (QBoxLayout*)(ui->centralWidget->layout());
         QSplitter* s = (QSplitter*)((QWidgetItem*)(l->itemAt(0))->widget());
         s->insertWidget(1,translationWidget);
@@ -333,6 +327,37 @@ Settings* MainWindow::settings() {
     return backbone->settings();
 }
 
+
+void MainWindow::showNotify(Notify::NotifyType type, QString text) {
+    switch(type) {
+    case Notify::Info:
+        #ifdef Q_WS_MAEMO_5
+            QMaemo5InformationBox::information(this,
+                                text,
+                                QMaemo5InformationBox::DefaultTimeout);
+        #else
+            QMessageBox::information(this, "Information", text);
+        #endif
+        break;
+
+    case Notify::Warning:
+        #ifndef Q_WS_MAEMO_5
+                QMessageBox::warning(this, "Warning", text);
+                break;
+        #endif
+
+    case Notify::Error:
+        #ifdef Q_WS_MAEMO_5
+            QMaemo5InformationBox::information(this,
+                                text,
+                                QMaemo5InformationBox::NoTimeout);
+        #else
+            QMessageBox::critical(this, "Error", text);
+        #endif
+        break;
+    }
+}
+
 void MainWindow::connectBackbone() {
     connect(this, SIGNAL(quit()),
             backbone, SLOT(quit()));