Fixed setting of splitter sizes for transparent docking

This commit is contained in:
Uwe Kindler 2019-11-27 21:43:36 +01:00
parent 8ea7c265a7
commit 07f9c6d016
2 changed files with 17 additions and 10 deletions

View File

@ -603,13 +603,13 @@ void DockContainerWidgetPrivate::moveIntoCenterOfSection(QWidget* Widget, CDockA
//============================================================================
void DockContainerWidgetPrivate::moveToNewSection(QWidget* Widget, CDockAreaWidget* TargetDockArea, DockWidgetArea area)
void DockContainerWidgetPrivate::moveToNewSection(QWidget* Widget, CDockAreaWidget* TargetArea, DockWidgetArea area)
{
// Dropping into center means all dock widgets in the dropped floating
// widget will become tabs of the drop area
if (CenterDockWidgetArea == area)
{
moveIntoCenterOfSection(Widget, TargetDockArea);
moveIntoCenterOfSection(Widget, TargetArea);
return;
}
@ -634,21 +634,29 @@ void DockContainerWidgetPrivate::moveToNewSection(QWidget* Widget, CDockAreaWidg
}
auto InsertParam = internal::dockAreaInsertParameters(area);
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetDockArea);
int index = TargetAreaSplitter ->indexOf(TargetDockArea);
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetArea);
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
auto Sizes = TargetAreaSplitter->sizes();
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
{
ADS_PRINT("TargetAreaSplitter->orientation() == InsertParam.orientation()");
TargetAreaSplitter->insertWidget(index + InsertParam.insertOffset(), NewDockArea);
int TargetAreaSize = (InsertParam.orientation() == Qt::Horizontal) ? TargetArea->width() : TargetArea->height();
TargetAreaSplitter->insertWidget(AreaIndex + InsertParam.insertOffset(), NewDockArea);
int Size = (TargetAreaSize - TargetAreaSplitter->handleWidth()) / 2;
Sizes[AreaIndex] = Size;
Sizes.insert(AreaIndex, Size);
}
else
{
ADS_PRINT("TargetAreaSplitter->orientation() != InsertParam.orientation()");
auto Sizes = TargetAreaSplitter->sizes();
int TargetAreaSize = (InsertParam.orientation() == Qt::Horizontal) ? TargetArea->width() : TargetArea->height();
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
NewSplitter->addWidget(TargetDockArea);
NewSplitter->addWidget(TargetArea);
insertWidgetIntoSplitter(NewSplitter, NewDockArea, InsertParam.append());
TargetAreaSplitter->insertWidget(index, NewSplitter);
int Size = TargetAreaSize / 2;
NewSplitter->setSizes({Size, Size});
TargetAreaSplitter->insertWidget(AreaIndex, NewSplitter);
}
TargetAreaSplitter->setSizes(Sizes);
addDockAreasToList({NewDockArea});
}

View File

@ -47,7 +47,6 @@
#endif
// Define ADS_DEBUG_PRINT to enable a lot of debug output
#define ADS_DEBUG_PRINT
#ifdef ADS_DEBUG_PRINT
#define ADS_PRINT(s) qDebug() << s
#else