diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index c0614404..bc73b110 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -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(); diff --git a/common/lc_mainwindow.h b/common/lc_mainwindow.h index 850d53ee..3c447ad2 100644 --- a/common/lc_mainwindow.h +++ b/common/lc_mainwindow.h @@ -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 {