mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-01 02:42:39 +08:00
Fixed DockContainerWidget.cpp contentRect() function to work properly even if no dock widget is visible in container
This commit is contained in:
parent
b801f0655d
commit
e2929ade14
@ -230,6 +230,7 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, SideBarL
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::updateSize()
|
void CAutoHideDockContainer::updateSize()
|
||||||
{
|
{
|
||||||
|
std::cout << "CAutoHideDockContainer::updateSize()" << std::endl;
|
||||||
auto dockContainerParent = dockContainer();
|
auto dockContainerParent = dockContainer();
|
||||||
if (!dockContainerParent)
|
if (!dockContainerParent)
|
||||||
{
|
{
|
||||||
@ -237,6 +238,7 @@ void CAutoHideDockContainer::updateSize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto rect = dockContainerParent->contentRect();
|
auto rect = dockContainerParent->contentRect();
|
||||||
|
qDebug() << "dockContainerParent->contentRect() " << rect;
|
||||||
|
|
||||||
switch (sideBarLocation())
|
switch (sideBarLocation())
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ public:
|
|||||||
QList<CAutoHideDockContainer*> AutoHideWidgets;
|
QList<CAutoHideDockContainer*> AutoHideWidgets;
|
||||||
QMap<SideBarLocation, CAutoHideSideBar*> SideTabBarWidgets;
|
QMap<SideBarLocation, CAutoHideSideBar*> SideTabBarWidgets;
|
||||||
QGridLayout* Layout = nullptr;
|
QGridLayout* Layout = nullptr;
|
||||||
QSplitter* RootSplitter = nullptr;
|
CDockSplitter* RootSplitter = nullptr;
|
||||||
bool isFloating = false;
|
bool isFloating = false;
|
||||||
CDockAreaWidget* LastAddedAreaCache[5];
|
CDockAreaWidget* LastAddedAreaCache[5];
|
||||||
int VisibleDockAreaCount = -1;
|
int VisibleDockAreaCount = -1;
|
||||||
@ -465,7 +465,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
CDockContainerWidget* FloatingDockContainer = FloatingWidget->dockContainer();
|
CDockContainerWidget* FloatingDockContainer = FloatingWidget->dockContainer();
|
||||||
auto NewDockAreas = FloatingDockContainer->findChildren<CDockAreaWidget*>(
|
auto NewDockAreas = FloatingDockContainer->findChildren<CDockAreaWidget*>(
|
||||||
QString(), Qt::FindChildrenRecursively);
|
QString(), Qt::FindChildrenRecursively);
|
||||||
QSplitter* Splitter = RootSplitter;
|
auto Splitter = RootSplitter;
|
||||||
|
|
||||||
if (DockAreas.count() <= 1)
|
if (DockAreas.count() <= 1)
|
||||||
{
|
{
|
||||||
@ -473,7 +473,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
}
|
}
|
||||||
else if (Splitter->orientation() != InsertParam.orientation())
|
else if (Splitter->orientation() != InsertParam.orientation())
|
||||||
{
|
{
|
||||||
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
auto NewSplitter = newSplitter(InsertParam.orientation());
|
||||||
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
||||||
NewSplitter->addWidget(Splitter);
|
NewSplitter->addWidget(Splitter);
|
||||||
updateSplitterHandles(NewSplitter);
|
updateSplitterHandles(NewSplitter);
|
||||||
@ -1248,7 +1248,7 @@ void DockContainerWidgetPrivate::addDockArea(CDockAreaWidget* NewDockArea, DockW
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
auto NewSplitter = newSplitter(InsertParam.orientation());
|
||||||
if (InsertParam.append())
|
if (InsertParam.append())
|
||||||
{
|
{
|
||||||
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
||||||
@ -1583,7 +1583,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QWidget* widget = Splitter->widget(0);
|
QWidget* widget = Splitter->widget(0);
|
||||||
QSplitter* ChildSplitter = qobject_cast<QSplitter*>(widget);
|
auto ChildSplitter = qobject_cast<CDockSplitter*>(widget);
|
||||||
// If the one and only content widget of the splitter is not a splitter
|
// If the one and only content widget of the splitter is not a splitter
|
||||||
// then we are finished
|
// then we are finished
|
||||||
if (!ChildSplitter)
|
if (!ChildSplitter)
|
||||||
@ -1913,8 +1913,8 @@ bool CDockContainerWidget::restoreState(CDockingStateReader& s, bool Testing)
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->Layout->replaceWidget(d->RootSplitter, NewRootSplitter);
|
d->Layout->replaceWidget(d->RootSplitter, NewRootSplitter);
|
||||||
QSplitter* OldRoot = d->RootSplitter;
|
auto OldRoot = d->RootSplitter;
|
||||||
d->RootSplitter = qobject_cast<QSplitter*>(NewRootSplitter);
|
d->RootSplitter = qobject_cast<CDockSplitter*>(NewRootSplitter);
|
||||||
OldRoot->deleteLater();
|
OldRoot->deleteLater();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -2132,7 +2132,21 @@ QRect CDockContainerWidget::contentRect() const
|
|||||||
return QRect();
|
return QRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
return d->RootSplitter->geometry();
|
if (d->RootSplitter->hasVisibleContent())
|
||||||
|
{
|
||||||
|
return d->RootSplitter->geometry();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ContentRect = this->rect();
|
||||||
|
ContentRect.adjust(
|
||||||
|
sideTabBar(SideBarLeft)->sizeHint().width(),
|
||||||
|
sideTabBar(SideBarTop)->sizeHint().height(),
|
||||||
|
-sideTabBar(SideBarRight)->sizeHint().width(),
|
||||||
|
-sideTabBar(SideBarBottom)->sizeHint().height());
|
||||||
|
|
||||||
|
return ContentRect;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user