mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-02-04 01:59:19 +08:00
Fixed some bugs in tabbar handling
This commit is contained in:
parent
ceebda7431
commit
9c95e34df5
@ -265,6 +265,7 @@ void CDockAreaTabBar::insertTab(int Index, CDockWidgetTab* Tab)
|
||||
d->TabsLayout->insertWidget(Index, Tab);
|
||||
connect(Tab, SIGNAL(clicked()), this, SLOT(onTabClicked()));
|
||||
connect(Tab, SIGNAL(moved(const QPoint&)), this, SLOT(onTabWidgetMoved(const QPoint&)));
|
||||
Tab->installEventFilter(this);
|
||||
d->MenuOutdated = true;
|
||||
if (Index <= d->CurrentIndex)
|
||||
{
|
||||
@ -321,6 +322,7 @@ void CDockAreaTabBar::removeTab(CDockWidgetTab* Tab)
|
||||
|
||||
d->TabsLayout->removeWidget(Tab);
|
||||
Tab->disconnect(this);
|
||||
Tab->removeEventFilter(this);
|
||||
d->MenuOutdated = true;
|
||||
qDebug() << "NewCurrentIndex " << NewCurrentIndex;
|
||||
if (NewCurrentIndex != d->CurrentIndex)
|
||||
@ -448,6 +450,26 @@ void CDockAreaTabBar::closeTab(int Index)
|
||||
}
|
||||
emit tabCloseRequested(Index);
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
bool CDockAreaTabBar::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
bool Result = Super::eventFilter(watched, event);
|
||||
if (event->type() != QEvent::Hide)
|
||||
{
|
||||
return Result;
|
||||
}
|
||||
|
||||
CDockWidgetTab* Tab = qobject_cast<CDockWidgetTab*>(watched);
|
||||
if (!Tab)
|
||||
{
|
||||
return Result;
|
||||
}
|
||||
|
||||
qDebug() << "Hide event for tab " << Tab->text();
|
||||
return Result;
|
||||
}
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -63,6 +63,7 @@ protected:
|
||||
void startFloating(const QPoint& Pos);
|
||||
|
||||
public:
|
||||
using Super = QScrollArea;
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
@ -105,6 +106,11 @@ public:
|
||||
*/
|
||||
CDockWidgetTab* tab(int Index) const;
|
||||
|
||||
/**
|
||||
* Filters the tab widget events
|
||||
*/
|
||||
virtual bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* This property sets the index of the tab bar's visible tab
|
||||
|
@ -187,9 +187,10 @@ public:
|
||||
{
|
||||
LayoutItem->widget()->setParent(0);
|
||||
}
|
||||
m_CurrentWidget = nullptr;
|
||||
m_CurrentIndex = -1;
|
||||
}
|
||||
m_Widgets.removeOne(Widget);
|
||||
//setCurrentIndex(0);
|
||||
}
|
||||
|
||||
QWidget* currentWidget() const
|
||||
@ -379,7 +380,7 @@ void DockAreaWidgetPrivate::createTabBar()
|
||||
|
||||
TabBar = new CDockAreaTabBar(_this);
|
||||
TopLayout->addWidget(TabBar, 1);
|
||||
_this->connect(TabBar, SIGNAL(tabBarClicked(int)), SLOT(setCurrentIndex(int)));
|
||||
_this->connect(TabBar, SIGNAL(currentChanged(int)), SLOT(setCurrentIndex(int)));
|
||||
_this->connect(TabBar, SIGNAL(tabMoved(int, int)), SLOT(reorderDockWidget(int, int)));
|
||||
|
||||
TabsMenuButton = new QPushButton();
|
||||
|
@ -132,6 +132,7 @@ void DockWidgetPrivate::showDockWidget()
|
||||
{
|
||||
DockArea->show();
|
||||
DockArea->setCurrentDockWidget(_this);
|
||||
TabWidget->show();
|
||||
QSplitter* Splitter = internal::findParent<QSplitter*>(_this);
|
||||
while (Splitter && !Splitter->isVisible())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user