Fixed dropping of floating widgets with multiple dock widgets

This commit is contained in:
Uwe Kindler 2018-10-11 10:55:36 +02:00
parent 0e85431405
commit c3a5e3ef21
3 changed files with 11 additions and 3 deletions

View File

@ -199,6 +199,7 @@ void CDockAreaTabBar::startFloating(const QPoint& Pos)
//============================================================================
void CDockAreaTabBar::setCurrentIndex(int index)
{
std::cout << "CDockAreaTabBar::setCurrentIndex " << index << std::endl;
if (index == d->CurrentIndex)
{
return;
@ -267,6 +268,7 @@ void CDockAreaTabBar::insertTab(int Index, CDockWidgetTab* Tab)
//===========================================================================
void CDockAreaTabBar::removeTab(CDockWidgetTab* Tab)
{
std::cout << "CDockAreaTabBar::removeTab " << std::endl;
d->TabsLayout->removeWidget(Tab);
disconnect(Tab, SIGNAL(clicked()), this, SLOT(onTabClicked()));
d->MenuOutdated = true;
@ -297,6 +299,10 @@ void CDockAreaTabBar::onTabClicked()
}
int index = d->TabsLayout->indexOf(Tab);
if (index < 0)
{
return;
}
setCurrentIndex(index);
std::cout << "emit tabBarClicked " << index << std::endl;
emit tabBarClicked(index);

View File

@ -159,6 +159,7 @@ public:
void insertWidget(int index, QWidget* Widget)
{
Widget->setParent(0);
if (index < 0)
{
index = m_Widgets.count();
@ -643,7 +644,8 @@ void CDockAreaWidget::setCurrentIndex(int index)
emit currentChanging(index);
d->TabBar->setCurrentIndex(index);
auto Features = d->TabBar->currentTab()->dockWidget()->features();
CDockWidgetTab* CurrentTab = d->TabBar->currentTab();
auto Features = CurrentTab->dockWidget()->features();
d->CloseButton->setVisible(Features.testFlag(CDockWidget::DockWidgetClosable));
if (!dockManager()->isRestoringState())

View File

@ -255,9 +255,9 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
if (area == CenterDockWidgetArea)
{
auto NewDockWidgets = FloatingContainer->dockWidgets();
for (auto DockWidget : NewDockWidgets)
for (int i = 0; i < NewDockWidgets.count(); ++i)
{
TargetArea->insertDockWidget(0, DockWidget, false);
TargetArea->insertDockWidget(i, NewDockWidgets[i], false);
}
TargetArea->setCurrentIndex(0); // make the topmost widget active
FloatingWidget->deleteLater();