mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Fix new tab adding by mouse double click under Ubuntu
This commit is contained in:
parent
32b77e2848
commit
be4adc00a0
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue