diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 9520830..289fba1 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #ifdef Q_OS_WIN @@ -166,7 +167,8 @@ struct MainWindowPrivate QComboBox* PerspectiveComboBox = nullptr; ads::CDockManager* DockManager = nullptr; ads::CDockWidget* WindowTitleTestDockWidget = nullptr; - ads::CDockWidget* LastDockedEditor = nullptr; + QPointer LastDockedEditor; + QPointer LastCreatedFloatingEditor; MainWindowPrivate(CMainWindow* _public) : _this(_public) {} @@ -719,18 +721,30 @@ void CMainWindow::createEditor() { auto FloatingWidget = d->DockManager->addDockWidgetFloating(DockWidget); FloatingWidget->move(QPoint(20, 20)); + d->LastCreatedFloatingEditor = DockWidget; + d->LastDockedEditor.clear(); } else { ads::CDockAreaWidget* EditorArea = d->LastDockedEditor ? d->LastDockedEditor->dockAreaWidget() : nullptr; if (EditorArea) { + std::cout << "DockAreaCount before: " << EditorArea->dockContainer()->dockAreaCount() << std::endl; d->DockManager->setConfigFlag(ads::CDockManager::EqualSplitOnInsertion, true); d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget, EditorArea); + std::cout << "DockAreaCount after: " << DockWidget->dockContainer()->dockAreaCount() << std::endl; } else { - d->DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget); + if (d->LastCreatedFloatingEditor) + { + std::cout << "LastCreated" << std::endl; + d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget, d->LastCreatedFloatingEditor->dockAreaWidget()); + } + else + { + d->DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget); + } } d->LastDockedEditor = DockWidget; } diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index e045a31..0288ae9 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1253,7 +1253,6 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA { adjustSplitterSizesOnInsertion(TargetAreaSplitter); } - } else { @@ -1273,8 +1272,7 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA } } - appendDockAreas({NewDockArea}); - emitDockAreasAdded(); + addDockAreasToList({NewDockArea}); return NewDockArea; } diff --git a/src/DockManager.cpp b/src/DockManager.cpp index a7b0ddb..67cf210 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -759,7 +759,8 @@ CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget) { d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget); - auto AreaOfAddedDockWidget = CDockContainerWidget::addDockWidget(area, Dockwidget, DockAreaWidget); + auto Container = DockAreaWidget ? DockAreaWidget->dockContainer(): this; + auto AreaOfAddedDockWidget = Container->addDockWidget(area, Dockwidget, DockAreaWidget); emit dockWidgetAdded(Dockwidget); return AreaOfAddedDockWidget; }