Fixed resizing of dropped widget to the size of the dock overlay, small improve to improve performance when dropping into a container with many widgets

This commit is contained in:
Uwe Kindler 2018-09-14 15:02:47 +02:00
parent 9f1b2c122a
commit fcb1846bf5
2 changed files with 11 additions and 7 deletions

View File

@ -281,7 +281,6 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
Splitter->addWidget(TargetArea);
TargetAreaSplitter = Splitter;
}
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
auto Widget = FloatingWidget->dockContainer()->findChild<QWidget*>(QString(), Qt::FindDirectChildrenOnly);
auto FloatingSplitter = dynamic_cast<QSplitter*>(Widget);
@ -316,8 +315,8 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
}
}
insertWidgetIntoSplitter(NewSplitter, TargetArea, !InsertParam.append());
TargetAreaSplitter->insertWidget(AreaIndex, NewSplitter);
insertWidgetIntoSplitter(NewSplitter, TargetArea, !InsertParam.append());
}
FloatingWidget->deleteLater();

View File

@ -43,7 +43,6 @@
#include "DockWidget.h"
#include "DockOverlay.h"
namespace ads
{
static unsigned int zOrderCounter = 0;
@ -119,15 +118,21 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
{
// Resize the floating widget to the size of the highlighted drop area
// rectangle
QRect Rect = DockManager->containerOverlay()->dropOverlayRect();
if (!Rect.isValid())
CDockOverlay* Overlay = DockManager->containerOverlay();
if (!Overlay->dropOverlayRect().isValid())
{
Rect = DockManager->dockAreaOverlay()->rect();
Overlay = DockManager->dockAreaOverlay();
}
QRect Rect = Overlay->dropOverlayRect();
int FrameWidth = (_this->frameSize().width() - _this->rect().width()) / 2;
int TitleBarHeight = _this->frameSize().height() - _this->rect().height() - FrameWidth;
if (Rect.isValid())
{
_this->resize(Rect.size());
QPoint TopLeft = Overlay->mapToGlobal(Rect.topLeft());
TopLeft.ry() += TitleBarHeight;
_this->setGeometry(QRect(TopLeft, QSize(Rect.width(), Rect.height() - TitleBarHeight)));
QApplication::processEvents();
}
DropContainer->dropFloatingWidget(_this, QCursor::pos());
}