mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
improvement:refactor code ,ignore key event extract to method
This commit is contained in:
parent
d8f5e4a374
commit
9a4b119976
|
@ -2634,11 +2634,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
|||
( Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier ) )
|
||||
return false; // A non-typing modifier is pressed
|
||||
|
||||
if ( keyEvent->key() == Qt::Key_Space ||
|
||||
keyEvent->key() == Qt::Key_Backspace ||
|
||||
keyEvent->key() == Qt::Key_Tab ||
|
||||
keyEvent->key() == Qt::Key_Backtab ||
|
||||
keyEvent->key() == Qt::Key_Escape)
|
||||
if ( ignoreKeyEvent(keyEvent))
|
||||
return false; // Those key have other uses than to start typing
|
||||
// or don't make sense
|
||||
|
||||
|
@ -2664,11 +2660,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
|||
( Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier ) )
|
||||
return false; // A non-typing modifier is pressed
|
||||
|
||||
if ( keyEvent->key() == Qt::Key_Space ||
|
||||
keyEvent->key() == Qt::Key_Backspace ||
|
||||
keyEvent->key() == Qt::Key_Tab ||
|
||||
keyEvent->key() == Qt::Key_Backtab ||
|
||||
keyEvent->key() == Qt::Key_Escape)
|
||||
if ( ignoreKeyEvent(keyEvent))
|
||||
return false; // Those key have other uses than to start typing
|
||||
// or don't make sense
|
||||
|
||||
|
@ -2686,6 +2678,16 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
|||
return false;
|
||||
}
|
||||
|
||||
bool MainWindow::ignoreKeyEvent(QKeyEvent *keyEvent) {
|
||||
if ( keyEvent->key() == Qt::Key_Space ||
|
||||
keyEvent->key() == Qt::Key_Backspace ||
|
||||
keyEvent->key() == Qt::Key_Tab ||
|
||||
keyEvent->key() == Qt::Key_Backtab ||
|
||||
keyEvent->key() == Qt::Key_Escape)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::wordListItemActivated( QListWidgetItem * item )
|
||||
{
|
||||
if( wordListSelChanged )
|
||||
|
|
|
@ -276,7 +276,7 @@ private:
|
|||
TranslateBoxPopup popupAction );
|
||||
void setTranslateBoxTextAndClearSuffix( QString const & text, WildcardPolicy wildcardPolicy,
|
||||
TranslateBoxPopup popupAction );
|
||||
|
||||
bool ignoreKeyEvent(QKeyEvent *keyEvent);
|
||||
private slots:
|
||||
|
||||
void hotKeyActivated( int );
|
||||
|
|
Loading…
Reference in a new issue