Close tab with middle mouse click (#363)

This commit is contained in:
Thomas Cujé 2019-07-01 23:11:47 +02:00 committed by Leonardo Zide
parent b42e3b7e31
commit 0bae463b71
2 changed files with 30 additions and 4 deletions

View file

@ -30,6 +30,26 @@
lcMainWindow* gMainWindow;
#define LC_TAB_LAYOUT_VERSION 0x0001
void lcTabBar::mouseReleaseEvent(QMouseEvent *event)
{
if (event->type() == QEvent::MouseButtonRelease && event->button() == Qt::MidButton)
tabCloseRequested(tabAt(event->pos()));
else
QTabBar::mouseReleaseEvent(event);
}
lcTabWidget::lcTabWidget()
: QTabWidget()
{
setTabBar(new lcTabBar());
}
lcTabWidget::~lcTabWidget()
{
if (tabBar())
delete tabBar();
}
void lcModelTabWidget::ResetLayout()
{
QLayout* TabLayout = layout();

View file

@ -30,18 +30,24 @@ struct lcSearchOptions
char Name[256];
};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
typedef QTabWidget lcTabWidget;
#else
class lcTabBar : public QTabBar
{
protected:
void mouseReleaseEvent(QMouseEvent *event);
};
class lcTabWidget : public QTabWidget
{
public:
lcTabWidget();
~lcTabWidget();
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QTabBar* tabBar()
{
return QTabWidget::tabBar();
}
};
#endif
};
class lcModelTabWidget : public QWidget
{