Skip to content

Commit

Permalink
Handle "Enter" key in headwords list in dictionary headwords dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Abs62 committed Mar 4, 2014
1 parent 902c5f6 commit 4462c29
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions dictheadwords.cc
Expand Up @@ -92,6 +92,8 @@ DictHeadwords::DictHeadwords( QWidget *parent, Config::Class & cfg_,
connect( proxy, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
this, SLOT( showHeadwordsNumber() ) );

ui.headersListView->installEventFilter( this );

setup( dict_ );
}

Expand Down Expand Up @@ -132,6 +134,20 @@ void DictHeadwords::savePos()
cfg.headwordsDialog.headwordsDialogGeometry = saveGeometry();
}

bool DictHeadwords::eventFilter( QObject * obj, QEvent * ev )
{
if( obj == ui.headersListView && ev->type() == QEvent::KeyPress )
{
QKeyEvent * kev = static_cast< QKeyEvent * >( ev );
if( kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter )
{
itemClicked( ui.headersListView->currentIndex() );
return true;
}
}
return QDialog::eventFilter( obj, ev );
}

void DictHeadwords::okButtonClicked()
{
savePos();
Expand Down
1 change: 1 addition & 0 deletions dictheadwords.hh
Expand Up @@ -33,6 +33,7 @@ protected:
WordListItemDelegate * delegate;

void saveHeadersToFile();
bool eventFilter( QObject * obj, QEvent * ev );

private:
Ui::DictHeadwords ui;
Expand Down

0 comments on commit 4462c29

Please sign in to comment.