diff --git a/maintabwidget.cc b/maintabwidget.cc index 185d19ac..3d0c79a2 100644 --- a/maintabwidget.cc +++ b/maintabwidget.cc @@ -3,9 +3,13 @@ #include "maintabwidget.hh" #include +#include +#include MainTabWidget::MainTabWidget( QWidget * parent) : QTabWidget( parent ) { hideSingleTab = false; + installEventFilter( this ); + tabBar()->installEventFilter( this ); } void MainTabWidget::setHideSingleTab(bool hide) @@ -37,8 +41,25 @@ void MainTabWidget::updateTabBarVisibility() tabBar()->setVisible( !hideSingleTab || tabBar()->count() > 1 ); } +/* void MainTabWidget::mouseDoubleClickEvent ( QMouseEvent * event ) { (void) event; emit doubleClicked(); } +*/ + +bool MainTabWidget::eventFilter( QObject * obj, QEvent * ev ) +{ + // mouseDoubleClickEvent don't called under Ubuntu + if( ev->type() == QEvent::MouseButtonDblClick ) + { + QMouseEvent * mev = static_cast< QMouseEvent *>( ev ); + if( tabBar()->tabAt( mev->pos() ) == -1 ) + { + emit doubleClicked(); + return true; + } + } + return QTabWidget::eventFilter( obj, ev ); +} diff --git a/maintabwidget.hh b/maintabwidget.hh index 92cc8428..bf13c8a5 100644 --- a/maintabwidget.hh +++ b/maintabwidget.hh @@ -24,12 +24,13 @@ signals: void doubleClicked(); protected: - virtual void mouseDoubleClickEvent ( QMouseEvent * event ); +// virtual void mouseDoubleClickEvent ( QMouseEvent * event ); private: virtual void tabInserted(int index); virtual void tabRemoved(int index); void updateTabBarVisibility(); + virtual bool eventFilter( QObject * obj, QEvent * ev ); bool hideSingleTab; };