mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +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 "maintabwidget.hh"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
MainTabWidget::MainTabWidget( QWidget * parent) : QTabWidget( parent ) {
|
MainTabWidget::MainTabWidget( QWidget * parent) : QTabWidget( parent ) {
|
||||||
hideSingleTab = false;
|
hideSingleTab = false;
|
||||||
|
installEventFilter( this );
|
||||||
|
tabBar()->installEventFilter( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTabWidget::setHideSingleTab(bool hide)
|
void MainTabWidget::setHideSingleTab(bool hide)
|
||||||
|
@ -37,8 +41,25 @@ void MainTabWidget::updateTabBarVisibility()
|
||||||
tabBar()->setVisible( !hideSingleTab || tabBar()->count() > 1 );
|
tabBar()->setVisible( !hideSingleTab || tabBar()->count() > 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void MainTabWidget::mouseDoubleClickEvent ( QMouseEvent * event )
|
void MainTabWidget::mouseDoubleClickEvent ( QMouseEvent * event )
|
||||||
{
|
{
|
||||||
(void) event;
|
(void) event;
|
||||||
emit doubleClicked();
|
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();
|
void doubleClicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mouseDoubleClickEvent ( QMouseEvent * event );
|
// virtual void mouseDoubleClickEvent ( QMouseEvent * event );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void tabInserted(int index);
|
virtual void tabInserted(int index);
|
||||||
virtual void tabRemoved(int index);
|
virtual void tabRemoved(int index);
|
||||||
void updateTabBarVisibility();
|
void updateTabBarVisibility();
|
||||||
|
virtual bool eventFilter( QObject * obj, QEvent * ev );
|
||||||
|
|
||||||
bool hideSingleTab;
|
bool hideSingleTab;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue