I'd like to backport this also to branch.

Any objections?

Jürgen

spitz wrote:
> Author: spitz
> Date: Sun Jan 17 13:27:44 2010
> New Revision: 33069
> URL: http://www.lyx.org/trac/changeset/33069
> 
> Log:
> * GuiSpellchecker:
>       - implement event filter and allow selection of suggestions with the
>  keyboard (second part of bug 6460).
> 
> Modified:
>    lyx-devel/trunk/src/frontends/qt4/GuiSpellchecker.cpp
>    lyx-devel/trunk/src/frontends/qt4/GuiSpellchecker.h
> 
> Modified: lyx-devel/trunk/src/frontends/qt4/GuiSpellchecker.cpp
> ===========================================================================
> === --- lyx-devel/trunk/src/frontends/qt4/GuiSpellchecker.cpp Sun Jan 17
>  12:32:08 2010        (r33068) +++
>  lyx-devel/trunk/src/frontends/qt4/GuiSpellchecker.cpp        Sun Jan 17 
> 13:27:44
>  2010 (r33069) @@ -41,6 +41,7 @@
>  #include "support/textutils.h"
> 
>  #include <QListWidgetItem>
> +#include <QKeyEvent>
> 
>  #include "SpellChecker.h"
> 
> @@ -77,6 +78,8 @@
>               this, SLOT(on_replacePB_clicked()));
> 
>       d->ui.wordED->setReadOnly(true);
> +
> +     d->ui.suggestionsLW->installEventFilter(this);
>  }
> 
> 
> @@ -92,6 +95,24 @@
>  }
> 
> 
> +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)
> 
> Modified: lyx-devel/trunk/src/frontends/qt4/GuiSpellchecker.h
> ===========================================================================
> === --- lyx-devel/trunk/src/frontends/qt4/GuiSpellchecker.h   Sun Jan 17
>  12:32:08 2010        (r33068) +++
>  lyx-devel/trunk/src/frontends/qt4/GuiSpellchecker.h  Sun Jan 17 13:27:44
>  2010 (r33069) @@ -62,6 +62,8 @@
>       /// show count of checked words at normal exit
>       void showSummary();
> 
> +     bool eventFilter(QObject *obj, QEvent *event);
> +
>       struct Private;
>       Private * const d;
>  };
> 

Reply via email to