From 88c40141d093e5704dd4aea19c3b5a800f2c89c4 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Wed, 23 Apr 2014 17:46:48 +0400 Subject: [PATCH] A little refactoring of keys handling (old solution don't work correctly in Qt5) --- articleview.cc | 20 +++++++++++++++----- mainwindow.cc | 7 +++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/articleview.cc b/articleview.cc index e25867f6..390c4507 100644 --- a/articleview.cc +++ b/articleview.cc @@ -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( 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; } diff --git a/mainwindow.cc b/mainwindow.cc index a36ce2b1..84f12a52 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -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( 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; }