mirror of
https://github.com/leozide/leocad.git
synced 2026-07-28 04:07:11 +00:00
Only close tab if the user clicked and released the mouse on the same tab.
This commit is contained in:
+15
-11
@@ -30,24 +30,28 @@
|
||||
lcMainWindow* gMainWindow;
|
||||
#define LC_TAB_LAYOUT_VERSION 0x0001
|
||||
|
||||
void lcTabBar::mouseReleaseEvent(QMouseEvent *event)
|
||||
void lcTabBar::mousePressEvent(QMouseEvent* Event)
|
||||
{
|
||||
if (event->type() == QEvent::MouseButtonRelease && event->button() == Qt::MidButton)
|
||||
tabCloseRequested(tabAt(event->pos()));
|
||||
if (Event->button() == Qt::MidButton)
|
||||
mMousePressTab = tabAt(Event->pos());
|
||||
else
|
||||
QTabBar::mouseReleaseEvent(event);
|
||||
QTabBar::mousePressEvent(Event);
|
||||
}
|
||||
|
||||
void lcTabBar::mouseReleaseEvent(QMouseEvent* Event)
|
||||
{
|
||||
if (Event->button() == Qt::MidButton && tabAt(Event->pos()) == mMousePressTab)
|
||||
tabCloseRequested(mMousePressTab);
|
||||
else
|
||||
QTabBar::mouseReleaseEvent(Event);
|
||||
}
|
||||
|
||||
lcTabWidget::lcTabWidget()
|
||||
: QTabWidget()
|
||||
{
|
||||
setTabBar(new lcTabBar());
|
||||
}
|
||||
|
||||
lcTabWidget::~lcTabWidget()
|
||||
{
|
||||
if (tabBar())
|
||||
delete tabBar();
|
||||
lcTabBar* TabBar = new lcTabBar(this);
|
||||
setTabBar(TabBar);
|
||||
TabBar->setDrawBase(false);
|
||||
}
|
||||
|
||||
void lcModelTabWidget::ResetLayout()
|
||||
|
||||
+10
-8
@@ -32,21 +32,23 @@ struct lcSearchOptions
|
||||
|
||||
class lcTabBar : public QTabBar
|
||||
{
|
||||
public:
|
||||
lcTabBar(QWidget* Parent = nullptr)
|
||||
: QTabBar(Parent), mMousePressTab(-1)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
virtual void mousePressEvent(QMouseEvent* Event) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent* Event) override;
|
||||
|
||||
int mMousePressTab;
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user