Fixed some focus and activation bugs
[mdictionary] / src / mdictionary / gui / DictManagerWidget.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();
+    }
+}