Fixed adding of dock widgets to floating widget

This commit is contained in:
Uwe Kindler 2020-11-21 15:08:30 +01:00
parent 44dc76bd19
commit 0a096869fe
3 changed files with 19 additions and 6 deletions

View File

@ -58,6 +58,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QMenu> #include <QMenu>
#include <QToolButton> #include <QToolButton>
#include <QPointer>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -166,7 +167,8 @@ struct MainWindowPrivate
QComboBox* PerspectiveComboBox = nullptr; QComboBox* PerspectiveComboBox = nullptr;
ads::CDockManager* DockManager = nullptr; ads::CDockManager* DockManager = nullptr;
ads::CDockWidget* WindowTitleTestDockWidget = nullptr; ads::CDockWidget* WindowTitleTestDockWidget = nullptr;
ads::CDockWidget* LastDockedEditor = nullptr; QPointer<ads::CDockWidget> LastDockedEditor;
QPointer<ads::CDockWidget> LastCreatedFloatingEditor;
MainWindowPrivate(CMainWindow* _public) : _this(_public) {} MainWindowPrivate(CMainWindow* _public) : _this(_public) {}
@ -719,18 +721,30 @@ void CMainWindow::createEditor()
{ {
auto FloatingWidget = d->DockManager->addDockWidgetFloating(DockWidget); auto FloatingWidget = d->DockManager->addDockWidgetFloating(DockWidget);
FloatingWidget->move(QPoint(20, 20)); FloatingWidget->move(QPoint(20, 20));
d->LastCreatedFloatingEditor = DockWidget;
d->LastDockedEditor.clear();
} }
else else
{ {
ads::CDockAreaWidget* EditorArea = d->LastDockedEditor ? d->LastDockedEditor->dockAreaWidget() : nullptr; ads::CDockAreaWidget* EditorArea = d->LastDockedEditor ? d->LastDockedEditor->dockAreaWidget() : nullptr;
if (EditorArea) if (EditorArea)
{ {
std::cout << "DockAreaCount before: " << EditorArea->dockContainer()->dockAreaCount() << std::endl;
d->DockManager->setConfigFlag(ads::CDockManager::EqualSplitOnInsertion, true); d->DockManager->setConfigFlag(ads::CDockManager::EqualSplitOnInsertion, true);
d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget, EditorArea); d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget, EditorArea);
std::cout << "DockAreaCount after: " << DockWidget->dockContainer()->dockAreaCount() << std::endl;
} }
else 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; d->LastDockedEditor = DockWidget;
} }

View File

@ -1253,7 +1253,6 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA
{ {
adjustSplitterSizesOnInsertion(TargetAreaSplitter); adjustSplitterSizesOnInsertion(TargetAreaSplitter);
} }
} }
else else
{ {
@ -1273,8 +1272,7 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA
} }
} }
appendDockAreas({NewDockArea}); addDockAreasToList({NewDockArea});
emitDockAreasAdded();
return NewDockArea; return NewDockArea;
} }

View File

@ -759,7 +759,8 @@ CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget) CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget)
{ {
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget); 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); emit dockWidgetAdded(Dockwidget);
return AreaOfAddedDockWidget; return AreaOfAddedDockWidget;
} }