Fix new tab adding by mouse double click under Ubuntu

This commit is contained in:
Abs62 2012-12-27 17:04:46 +04:00
parent 32b77e2848
commit be4adc00a0
2 changed files with 23 additions and 1 deletions

View file

@ -3,9 +3,13 @@
#include "maintabwidget.hh"
#include <QDebug>
#include <QEvent>
#include <QMouseEvent>
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 );
}

View file

@ -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;
};