[clean] remove code in dictionarybar eventfilter

This commit is contained in:
Xiao YiFang 2022-11-01 20:21:16 +08:00
parent e66380763f
commit 10972abcf4
2 changed files with 1 additions and 47 deletions

View file

@ -16,8 +16,7 @@ DictionaryBar::DictionaryBar( QWidget * parent,
mutedDictionaries( 0 ),
configEvents( events ),
editDictionaryCommand( _editDictionaryCommand ),
maxDictionaryRefsInContextMenu(maxDictionaryRefsInContextMenu_),
timerId( 0 )
maxDictionaryRefsInContextMenu(maxDictionaryRefsInContextMenu_)
{
setObjectName( "dictionaryBar" );
@ -28,8 +27,6 @@ DictionaryBar::DictionaryBar( QWidget * parent,
connect( this, SIGNAL(actionTriggered(QAction*)),
this, SLOT(actionWasTriggered(QAction*)) );
installEventFilter( this );
}
static QString elideDictName( QString const & name )
@ -352,42 +349,3 @@ void DictionaryBar::dictsPaneClicked( const QString & id )
}
}
}
bool DictionaryBar::eventFilter( QObject * obj, QEvent * ev )
{
if(obj == this && !isFloating() )
{
QPoint pt = parentWidget()->mapFromGlobal( QCursor::pos() );
switch( ev->type() )
{
case QEvent::Leave : if( geometry().contains( pt ) )
{
if( timerId )
killTimer( timerId );
timerId = startTimer( 500 );
return true;
}
break;
case QEvent::Enter : if( timerId != 0)
{
killTimer( timerId );
timerId = 0;
}
break;
case QEvent::Timer: if( static_cast< QTimerEvent * >( ev )->timerId() == timerId )
{
if( !geometry().contains( pt ) )
{
killTimer( timerId );
timerId = 0;
QEvent event( QEvent::Leave );
QApplication::sendEvent( this, &event );
}
return true;
}
break;
default: break;
}
}
return false;
}

View file

@ -61,10 +61,6 @@ private:
QList< QAction * > dictActions;
QAction * maxDictionaryRefsAction;
int timerId;
virtual bool eventFilter( QObject *, QEvent * );
protected:
void contextMenuEvent( QContextMenuEvent * event );