mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +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 ) )
|
( Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier ) )
|
||||||
return false; // A non-typing modifier is pressed
|
return false; // A non-typing modifier is pressed
|
||||||
|
|
||||||
if ( keyEvent->key() == Qt::Key_Space ||
|
if ( ignoreKeyEvent(keyEvent))
|
||||||
keyEvent->key() == Qt::Key_Backspace ||
|
|
||||||
keyEvent->key() == Qt::Key_Tab ||
|
|
||||||
keyEvent->key() == Qt::Key_Backtab ||
|
|
||||||
keyEvent->key() == Qt::Key_Escape)
|
|
||||||
return false; // Those key have other uses than to start typing
|
return false; // Those key have other uses than to start typing
|
||||||
// or don't make sense
|
// or don't make sense
|
||||||
|
|
||||||
|
@ -2664,11 +2660,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
||||||
( Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier ) )
|
( Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier ) )
|
||||||
return false; // A non-typing modifier is pressed
|
return false; // A non-typing modifier is pressed
|
||||||
|
|
||||||
if ( keyEvent->key() == Qt::Key_Space ||
|
if ( ignoreKeyEvent(keyEvent))
|
||||||
keyEvent->key() == Qt::Key_Backspace ||
|
|
||||||
keyEvent->key() == Qt::Key_Tab ||
|
|
||||||
keyEvent->key() == Qt::Key_Backtab ||
|
|
||||||
keyEvent->key() == Qt::Key_Escape)
|
|
||||||
return false; // Those key have other uses than to start typing
|
return false; // Those key have other uses than to start typing
|
||||||
// or don't make sense
|
// or don't make sense
|
||||||
|
|
||||||
|
@ -2686,6 +2678,16 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
||||||
return false;
|
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 )
|
void MainWindow::wordListItemActivated( QListWidgetItem * item )
|
||||||
{
|
{
|
||||||
if( wordListSelChanged )
|
if( wordListSelChanged )
|
||||||
|
|
|
@ -276,7 +276,7 @@ private:
|
||||||
TranslateBoxPopup popupAction );
|
TranslateBoxPopup popupAction );
|
||||||
void setTranslateBoxTextAndClearSuffix( QString const & text, WildcardPolicy wildcardPolicy,
|
void setTranslateBoxTextAndClearSuffix( QString const & text, WildcardPolicy wildcardPolicy,
|
||||||
TranslateBoxPopup popupAction );
|
TranslateBoxPopup popupAction );
|
||||||
|
bool ignoreKeyEvent(QKeyEvent *keyEvent);
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void hotKeyActivated( int );
|
void hotKeyActivated( int );
|
||||||
|
|
Loading…
Reference in a new issue