mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
A little refactoring of keys handling (old solution don't work correctly in Qt5)
This commit is contained in:
parent
0d60382e98
commit
88c40141d0
|
@ -635,19 +635,25 @@ void ArticleView::cleanupTemp()
|
|||
|
||||
bool ArticleView::handleF3( QObject * /*obj*/, QEvent * ev )
|
||||
{
|
||||
if ( ev->type() == QEvent::ShortcutOverride ) {
|
||||
if ( ev->type() == QEvent::ShortcutOverride
|
||||
|| ev->type() == QEvent::KeyPress )
|
||||
{
|
||||
QKeyEvent * ke = static_cast<QKeyEvent *>( ev );
|
||||
if ( ke->key() == Qt::Key_F3 && isSearchOpened() ) {
|
||||
if ( !ke->modifiers() )
|
||||
{
|
||||
on_searchNext_clicked();
|
||||
if( ev->type() == QEvent::KeyPress )
|
||||
on_searchNext_clicked();
|
||||
|
||||
ev->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ke->modifiers() == Qt::ShiftModifier )
|
||||
{
|
||||
on_searchPrevious_clicked();
|
||||
if( ev->type() == QEvent::KeyPress )
|
||||
on_searchPrevious_clicked();
|
||||
|
||||
ev->accept();
|
||||
return true;
|
||||
}
|
||||
|
@ -656,14 +662,18 @@ bool ArticleView::handleF3( QObject * /*obj*/, QEvent * ev )
|
|||
{
|
||||
if ( !ke->modifiers() )
|
||||
{
|
||||
on_ftsSearchNext_clicked();
|
||||
if( ev->type() == QEvent::KeyPress )
|
||||
on_ftsSearchNext_clicked();
|
||||
|
||||
ev->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ke->modifiers() == Qt::ShiftModifier )
|
||||
{
|
||||
on_ftsSearchPrevious_clicked();
|
||||
if( ev->type() == QEvent::KeyPress )
|
||||
on_ftsSearchPrevious_clicked();
|
||||
|
||||
ev->accept();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2191,12 +2191,15 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
|||
return true;
|
||||
}
|
||||
#endif
|
||||
if ( ev->type() == QEvent::ShortcutOverride ) {
|
||||
if ( ev->type() == QEvent::ShortcutOverride
|
||||
|| ev->type() == QEvent::KeyPress )
|
||||
{
|
||||
// Handle Ctrl+H to show the History Pane.
|
||||
QKeyEvent * ke = static_cast<QKeyEvent*>( ev );
|
||||
if ( ke->key() == Qt::Key_H && ke->modifiers() == Qt::ControlModifier )
|
||||
{
|
||||
on_showHideHistory_triggered();
|
||||
if( ev->type() == QEvent::KeyPress )
|
||||
on_showHideHistory_triggered();
|
||||
ev->accept();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue