mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Full-text search: Handle "Enter" key in headwords list
and focus dialog on Ctrl+Shift+F
This commit is contained in:
parent
88c40141d0
commit
948db01572
|
@ -189,6 +189,8 @@ FullTextSearchDialog::FullTextSearchDialog( QWidget * parent,
|
||||||
connect( ui.OKButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
|
connect( ui.OKButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
|
||||||
connect( ui.cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
|
connect( ui.cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
|
||||||
|
|
||||||
|
ui.headwordsView->installEventFilter( this );
|
||||||
|
|
||||||
delegate = new WordListItemDelegate( ui.headwordsView->itemDelegate() );
|
delegate = new WordListItemDelegate( ui.headwordsView->itemDelegate() );
|
||||||
if( delegate )
|
if( delegate )
|
||||||
ui.headwordsView->setItemDelegate( delegate );
|
ui.headwordsView->setItemDelegate( delegate );
|
||||||
|
@ -455,6 +457,20 @@ void FullTextSearchDialog::updateDictionaries()
|
||||||
showDictNumbers();
|
showDictNumbers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FullTextSearchDialog::eventFilter( QObject * obj, QEvent * ev )
|
||||||
|
{
|
||||||
|
if( obj == ui.headwordsView && ev->type() == QEvent::KeyPress )
|
||||||
|
{
|
||||||
|
QKeyEvent * kev = static_cast< QKeyEvent * >( ev );
|
||||||
|
if( kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter )
|
||||||
|
{
|
||||||
|
itemClicked( ui.headwordsView->currentIndex() );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QDialog::eventFilter( obj, ev );
|
||||||
|
}
|
||||||
|
|
||||||
/// HeadwordsListModel
|
/// HeadwordsListModel
|
||||||
|
|
||||||
int HeadwordsListModel::rowCount( QModelIndex const & ) const
|
int HeadwordsListModel::rowCount( QModelIndex const & ) const
|
||||||
|
|
|
@ -192,6 +192,9 @@ public:
|
||||||
|
|
||||||
void stopSearch();
|
void stopSearch();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter( QObject * obj, QEvent * ev );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FullTextSearchDialog ui;
|
Ui::FullTextSearchDialog ui;
|
||||||
QList< FtsHeadword > results;
|
QList< FtsHeadword > results;
|
||||||
|
|
|
@ -4001,7 +4001,10 @@ void MainWindow::showFullTextSearchDialog()
|
||||||
: groupInstances[ groupList->currentIndex() ].id;
|
: groupInstances[ groupList->currentIndex() ].id;
|
||||||
ftsDlg->setCurrentGroup( group );
|
ftsDlg->setCurrentGroup( group );
|
||||||
|
|
||||||
ftsDlg->show();
|
if( !ftsDlg ->isVisible() )
|
||||||
|
ftsDlg->show();
|
||||||
|
else
|
||||||
|
ftsDlg->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::closeFullTextSearchDialog()
|
void MainWindow::closeFullTextSearchDialog()
|
||||||
|
|
Loading…
Reference in a new issue