Override QTabBar::tabInserted insted of QTabWidget::tabInserted

Since we're moving logic to tab bar instead of tab widget.
Otherwise calling count() on the tab bar while QTabWidget::tabInserted
is running can give the wrong value. So settle with a single class.
This commit is contained in:
Sergio Martins
2022-08-15 13:47:03 +01:00
parent a0329a01fb
commit bbef108e32
5 changed files with 2 additions and 24 deletions

View File

@@ -154,16 +154,6 @@ bool Stack::isMDI() const
return m_group && m_group->isMDI();
}
void Stack::onTabInserted()
{
m_group->onDockWidgetCountChanged();
}
void Stack::onTabRemoved()
{
m_group->onDockWidgetCountChanged();
}
bool Stack::onMouseDoubleClick(QPoint localPos)
{
// User clicked the empty space of the tab widget and we don't have title bar

View File

@@ -81,8 +81,6 @@ public:
KDBindings::Signal<bool> tabBarAutoHideChanged;
public: // TODOm3
void onTabInserted();
void onTabRemoved();
bool onMouseDoubleClick(QPoint localPos);
private:

View File

@@ -97,16 +97,6 @@ void Stack_qtwidgets::mousePressEvent(QMouseEvent *ev)
}
}
void Stack_qtwidgets::tabInserted(int)
{
m_stack->onTabInserted();
}
void Stack_qtwidgets::tabRemoved(int)
{
m_stack->onTabRemoved();
}
void Stack_qtwidgets::setupTabBarButtons()
{
if (!(Config::self().flags() & Config::Flag_ShowButtonsOnTabBarIfTitleBarHidden))

View File

@@ -47,8 +47,6 @@ public:
public: // TODOm3: make protected
void mouseDoubleClickEvent(QMouseEvent *) override;
void mousePressEvent(QMouseEvent *) override;
void tabInserted(int index) override;
void tabRemoved(int index) override;
/// @brief Shows the context menu. Override to implement your own context menu.
/// By default it's used to honour Config::Flag_AllowSwitchingTabsViaMenu

View File

@@ -139,12 +139,14 @@ void TabBar_qtwidgets::tabInserted(int index)
{
QTabBar::tabInserted(index);
Q_EMIT dockWidgetInserted(index);
m_tabBar->group()->onDockWidgetCountChanged();
}
void TabBar_qtwidgets::tabRemoved(int index)
{
QTabBar::tabRemoved(index);
Q_EMIT dockWidgetRemoved(index);
m_tabBar->group()->onDockWidgetCountChanged();
}
void TabBar_qtwidgets::setCurrentIndex(int index)