mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
[clean] remove code in dictionarybar eventfilter
This commit is contained in:
parent
e66380763f
commit
10972abcf4
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -61,10 +61,6 @@ private:
|
|||
QList< QAction * > dictActions;
|
||||
QAction * maxDictionaryRefsAction;
|
||||
|
||||
int timerId;
|
||||
|
||||
virtual bool eventFilter( QObject *, QEvent * );
|
||||
|
||||
protected:
|
||||
|
||||
void contextMenuEvent( QContextMenuEvent * event );
|
||||
|
|
Loading…
Reference in a new issue