A little refactoring of keys handling (old solution don't work correctly in Qt5)

This commit is contained in:
Abs62 2014-04-23 17:46:48 +04:00
parent 0d60382e98
commit 88c40141d0
2 changed files with 20 additions and 7 deletions

View file

@ -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() )
{
if( ev->type() == QEvent::KeyPress )
on_searchNext_clicked();
ev->accept();
return true;
}
if ( ke->modifiers() == Qt::ShiftModifier )
{
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() )
{
if( ev->type() == QEvent::KeyPress )
on_ftsSearchNext_clicked();
ev->accept();
return true;
}
if ( ke->modifiers() == Qt::ShiftModifier )
{
if( ev->type() == QEvent::KeyPress )
on_ftsSearchPrevious_clicked();
ev->accept();
return true;
}

View file

@ -2191,11 +2191,14 @@ 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 )
{
if( ev->type() == QEvent::KeyPress )
on_showHideHistory_triggered();
ev->accept();
return true;