mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-26 14:29:02 +08:00
Fix docking behavior when there is a central widget
This commit is contained in:
parent
42498b2021
commit
8ddabc4cc8
@ -1129,6 +1129,22 @@ bool CDockAreaWidget::isCentralWidgetArea() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
bool CDockAreaWidget::containsCentralWidget() const
|
||||||
|
{
|
||||||
|
auto centralWidget = dockManager()->centralWidget();
|
||||||
|
for (const auto &dockWidget : dockWidgets())
|
||||||
|
{
|
||||||
|
if (dockWidget == centralWidget)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QSize CDockAreaWidget::minimumSizeHint() const
|
QSize CDockAreaWidget::minimumSizeHint() const
|
||||||
{
|
{
|
||||||
|
@ -358,10 +358,15 @@ public:
|
|||||||
void setDockAreaFlag(eDockAreaFlag Flag, bool On);
|
void setDockAreaFlag(eDockAreaFlag Flag, bool On);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the area contains the central widget of it's manager.
|
* Returns true if the area has a single dock widget and contains the central widget of it's manager.
|
||||||
*/
|
*/
|
||||||
bool isCentralWidgetArea() const;
|
bool isCentralWidgetArea() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the area contains the central widget of it's manager.
|
||||||
|
*/
|
||||||
|
bool containsCentralWidget() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* This activates the tab for the given tab index.
|
* This activates the tab for the given tab index.
|
||||||
|
@ -1898,8 +1898,6 @@ QList<CDockAreaWidget*> CDockContainerWidget::openedDockAreas() const
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
QList<CDockWidget*> CDockContainerWidget::openedDockWidgets() const
|
QList<CDockWidget*> CDockContainerWidget::openedDockWidgets() const
|
||||||
{
|
{
|
||||||
// todo: cleanup
|
|
||||||
qInfo() << "Opened Dock Widgets: ";
|
|
||||||
QList<CDockWidget*> DockWidgetList;
|
QList<CDockWidget*> DockWidgetList;
|
||||||
for (auto DockArea : d->DockAreas)
|
for (auto DockArea : d->DockAreas)
|
||||||
{
|
{
|
||||||
@ -1909,12 +1907,6 @@ QList<CDockWidget*> CDockContainerWidget::openedDockWidgets() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: cleanup
|
|
||||||
for (auto dockWidget : DockWidgetList)
|
|
||||||
{
|
|
||||||
qInfo() << "Opened dock widgets: " << dockWidget->objectName();
|
|
||||||
}
|
|
||||||
|
|
||||||
return DockWidgetList;
|
return DockWidgetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ void COverlayDockContainer::moveContentsToParent()
|
|||||||
const auto position = mapToGlobal(d->Area == CDockWidgetSideTab::Left ? QPoint(1,height() / 2) : QPoint(width() - 1, height() / 2));
|
const auto position = mapToGlobal(d->Area == CDockWidgetSideTab::Left ? QPoint(1,height() / 2) : QPoint(width() - 1, height() / 2));
|
||||||
|
|
||||||
const auto dockAreaWidget = parentContainer()->dockAreaAt(position);
|
const auto dockAreaWidget = parentContainer()->dockAreaAt(position);
|
||||||
if (dockAreaWidget != nullptr && !dockAreaWidget->isCentralWidgetArea())
|
if (dockAreaWidget != nullptr && !dockAreaWidget->containsCentralWidget())
|
||||||
{
|
{
|
||||||
parentContainer()->addDockWidget(CenterDockWidgetArea, d->DockWidget, dockAreaWidget);
|
parentContainer()->addDockWidget(CenterDockWidgetArea, d->DockWidget, dockAreaWidget);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user