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