]> git.lyx.org Git - lyx.git/commitdiff
* GuiSpellchecker:
authorJürgen Spitzmüller <spitz@lyx.org>
Sun, 17 Jan 2010 12:27:44 +0000 (12:27 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Sun, 17 Jan 2010 12:27:44 +0000 (12:27 +0000)
- implement event filter and allow selection of suggestions with the keyboard
  (second part of bug 6460).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33069 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiSpellchecker.cpp
src/frontends/qt4/GuiSpellchecker.h

index c6a4adf20b79eb9a24c4323c0249978cb654b5f1..10edda44629b9b24705a5ed14d0113403dce9b3c 100644 (file)
@@ -41,6 +41,7 @@
 #include "support/textutils.h"
 
 #include <QListWidgetItem>
+#include <QKeyEvent>
 
 #include "SpellChecker.h"
 
@@ -77,6 +78,8 @@ GuiSpellchecker::GuiSpellchecker(GuiView & lv)
                this, SLOT(on_replacePB_clicked()));
 
        d->ui.wordED->setReadOnly(true);
+
+       d->ui.suggestionsLW->installEventFilter(this);
 }
 
 
@@ -92,6 +95,24 @@ void GuiSpellchecker::on_closePB_clicked()
 }
 
 
+bool GuiSpellchecker::eventFilter(QObject *obj, QEvent *event)
+{
+       if (obj == d->ui.suggestionsLW && event->type() == QEvent::KeyPress) {
+               QKeyEvent *e = static_cast<QKeyEvent *> (event);
+               if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
+                       on_suggestionsLW_itemClicked(d->ui.suggestionsLW->currentItem());
+                       on_replacePB_clicked();
+                       return true;
+               } else if (e->key() == Qt::Key_Right) {
+                       on_suggestionsLW_itemClicked(d->ui.suggestionsLW->currentItem());
+                       return true;
+               }
+       }
+       // standard event processing
+       return QWidget::eventFilter(obj, event);
+}
+
+
 void GuiSpellchecker::on_suggestionsLW_itemClicked(QListWidgetItem * item)
 {
        if (d->ui.replaceCO->count() != 0)
index 58458e8ec81bee4ed9eaf7466dd70fa5fd7e6186..937d4f294b78087bb843be9781ff3335efb2a414 100644 (file)
@@ -62,6 +62,8 @@ private:
        /// show count of checked words at normal exit
        void showSummary();
 
+       bool eventFilter(QObject *obj, QEvent *event);
+
        struct Private;
        Private * const d;
 };