Fixed some focus and activation bugs
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Thu, 16 Sep 2010 09:38:28 +0000 (11:38 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Thu, 16 Sep 2010 09:38:28 +0000 (11:38 +0200)
src/mdictionary/gui/DictManagerWidget.cpp
src/mdictionary/gui/DictManagerWidget.h
src/mdictionary/gui/HistoryListDialog.cpp
src/mdictionary/gui/HistoryListDialog.h
src/mdictionary/gui/MainWindow.cpp
src/mdictionary/gui/SettingsWidget.cpp

index 4ea996c..4353301 100644 (file)
@@ -86,6 +86,15 @@ void DictManagerWidget::initalizeUI() {
     connect(dictList, SIGNAL(itemChanged(QListWidgetItem*)),
             this, SLOT(changed()));
 
+    #ifndef Q_WS_MAEMO_5
+        connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)),
+                this, SLOT(saveChanges()));
+        connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)),
+                this, SLOT(itemSelected(QListWidgetItem*)));
+        connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)),
+                settingsButton, SIGNAL(clicked()));
+    #endif
+
     refreshDictsList();
 
     #ifndef Q_WS_MAEMO_5
@@ -204,6 +213,7 @@ void DictManagerWidget::addNewDictButtonClicked() {
 void DictManagerWidget::itemSelected(QListWidgetItem *) {
     removeDictButton->setEnabled(true);
     settingsButton->setEnabled(true);
+    dictList->setFocus();
 }
 
 void DictManagerWidget::removeButtonClicked() {
@@ -248,3 +258,19 @@ void DictManagerWidget::changed() {
         hide();
     }
 #endif
+
+
+void DictManagerWidget::keyPressEvent(QKeyEvent *e) {
+    if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) {
+        switch (e->key()) {
+            case Qt::Key_Escape:
+               reject();
+               break;
+            default:
+               e->ignore();
+               return;
+        }
+    } else {
+        e->ignore();
+    }
+}
index eec621c..ab7c9cc 100644 (file)
@@ -52,6 +52,7 @@ public:
 protected:
     void showEvent(QShowEvent *e);
     void hideEvent(QHideEvent *e);
+    void keyPressEvent(QKeyEvent *e);
 
 Q_SIGNALS:
     //! Emitted when hiding widget, it will save states of dictionaries
index a9d4765..7e58372 100644 (file)
@@ -53,7 +53,7 @@ HistoryListDialog::HistoryListDialog(QStringList words, QWidget *parent):
 
      setMinimumHeight(300);
 
-     connect(historyListWidget, SIGNAL(clicked(QModelIndex)),
+     connect(historyListWidget, SIGNAL(activated(QModelIndex)),
              this, SLOT(itemClicked(QModelIndex)));
 }
 
@@ -72,3 +72,8 @@ QString HistoryListDialog::selectedWord() {
 int HistoryListDialog::selectedRow() {
     return _selectedRow;
 }
+
+int HistoryListDialog::exec() {
+    historyListWidget->setFocus();
+    QDialog::exec();
+}
index 20bf354..5d3c78c 100644 (file)
@@ -52,6 +52,9 @@ public:
     //! \returns row number of selected word
     int selectedRow();
 
+public Q_SLOTS:
+    int exec();
+
 private Q_SLOTS:
     void itemClicked(QModelIndex);
 
index 9d2ae5a..b7e4dca 100644 (file)
@@ -231,6 +231,8 @@ void MainWindow::wordListReady() {
             setExactSearch(false);
         }
     }
+
+    wordListWidget->setFocus();
 }
 
 bool MainWindow::checkExactSearch(
@@ -255,6 +257,7 @@ void MainWindow::translationsReady() {
     #endif
 
     Q_EMIT showTranslation(backbone->xmls());
+    wordListWidget->setFocus();
     #ifdef Q_WS_MAEMO_5
         notifyManager->screenChanged();
     #endif
index 7b7173e..68bafaf 100644 (file)
@@ -100,8 +100,8 @@ void SettingsWidget::initalizeUI() {
 
     checkBoxesLabel = new QLabel(tr("Search in:"),this);
 
-    searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"),this);
-    searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"),this);
+    searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"));
+    searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"));
 
     verticalLayout->addSpacing(20);
     verticalLayout->addWidget(checkBoxesLabel);