Added dropIntoAutoHideSideBar() function

This commit is contained in:
Uwe Kindler 2023-06-28 10:19:59 +02:00
parent 21189759dd
commit f6ccaba6aa
3 changed files with 47 additions and 40 deletions

View File

@ -181,6 +181,11 @@ public:
*/ */
void dropIntoContainer(CFloatingDockContainer* FloatingWidget, DockWidgetArea area); void dropIntoContainer(CFloatingDockContainer* FloatingWidget, DockWidgetArea area);
/**
* Drop floating widget into auto hide side bar
*/
void dropIntoAutoHideSideBar(CFloatingDockContainer* FloatingWidget, DockWidgetArea area);
/** /**
* Drop floating widget into dock area * Drop floating widget into dock area
*/ */
@ -505,6 +510,23 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
} }
//============================================================================
void DockContainerWidgetPrivate::dropIntoAutoHideSideBar(CFloatingDockContainer* FloatingWidget, DockWidgetArea area)
{
auto SideBarLocation = internal::toSideBarLocation(area);
auto NewDockAreas = FloatingWidget->findChildren<CDockAreaWidget*>(
QString(), Qt::FindChildrenRecursively);
for (auto DockArea : NewDockAreas)
{
auto DockWidgets = DockArea->dockWidgets();
for (auto DockWidget : DockWidgets)
{
_this->createAndSetupAutoHideContainer(SideBarLocation, DockWidget);
}
}
}
//============================================================================ //============================================================================
void DockContainerWidgetPrivate::dropIntoCenterOfSection( void DockContainerWidgetPrivate::dropIntoCenterOfSection(
CFloatingDockContainer* FloatingWidget, CDockAreaWidget* TargetArea) CFloatingDockContainer* FloatingWidget, CDockAreaWidget* TargetArea)
@ -1661,18 +1683,8 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
{ {
if (internal::isSideBarArea(ContainerDropArea)) if (internal::isSideBarArea(ContainerDropArea))
{ {
auto SideBarLocation = internal::toSideBarLocation(ContainerDropArea); ADS_PRINT("Container Drop Content: " << ContainerDropArea);
std::cout << "Drop into sidebar " << std::endl; d->dropIntoAutoHideSideBar(FloatingWidget, ContainerDropArea);
auto NewDockAreas = FloatingWidget->findChildren<CDockAreaWidget*>(
QString(), Qt::FindChildrenRecursively);
for (auto DockArea : NewDockAreas)
{
auto DockWidgets = DockArea->dockWidgets();
for (auto DockWidget : DockWidgets)
{
createAndSetupAutoHideContainer(SideBarLocation, DockWidget);
}
}
} }
else else
{ {
@ -1712,10 +1724,29 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
d->DockManager->notifyFloatingWidgetDrop(FloatingWidget); d->DockManager->notifyFloatingWidgetDrop(FloatingWidget);
} }
/*
* else if (internal::isSideBarArea(ContainerDropArea))
{
// Drop into AutoHideArea
auto DockWidget = qobject_cast<CDockWidget*>(d->Content);
auto DockArea = qobject_cast<CDockAreaWidget*>(d->Content);
auto SideBarLocation = internal::toSideBarLocation(ContainerDropArea);
if (DockWidget)
{
DockWidget->toggleAutoHide(SideBarLocation);
}
else if (DockArea)
{
DockArea->toggleAutoHide(SideBarLocation);
}
}
*/
//============================================================================ //============================================================================
void CDockContainerWidget::dropWidget(QWidget* Widget, DockWidgetArea DropArea, CDockAreaWidget* TargetAreaWidget) void CDockContainerWidget::dropWidget(QWidget* Widget, DockWidgetArea DropArea, CDockAreaWidget* TargetAreaWidget)
{ {
std::cout << "CDockContainerWidget::dropWidget" << std::endl;
CDockWidget* SingleDockWidget = topLevelDockWidget(); CDockWidget* SingleDockWidget = topLevelDockWidget();
if (TargetAreaWidget) if (TargetAreaWidget)
{ {

View File

@ -35,7 +35,6 @@
#include <QDebug> #include <QDebug>
#include <QMap> #include <QMap>
#include <QWindow> #include <QWindow>
#include <QSvgRenderer>
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
#include "DockAreaTitleBar.h" #include "DockAreaTitleBar.h"
@ -459,8 +458,6 @@ DockWidgetArea CDockOverlay::dropAreaUnderCursor() const
{ {
auto Rect = rect(); auto Rect = rect();
const QPoint pos = mapFromGlobal(QCursor::pos()); const QPoint pos = mapFromGlobal(QCursor::pos());
std::cout << "pos.y: " << pos.y() << " d->sideBarMouseZone(SideBarTop) " << d->sideBarMouseZone(SideBarTop) << std::endl;
if (pos.x() < d->sideBarMouseZone(SideBarLeft)) if (pos.x() < d->sideBarMouseZone(SideBarLeft))
{ {
return LeftAutoHideArea; return LeftAutoHideArea;
@ -584,7 +581,6 @@ void CDockOverlay::paintEvent(QPaintEvent* event)
double Factor = (CDockOverlay::ModeContainerOverlay == d->Mode) ? double Factor = (CDockOverlay::ModeContainerOverlay == d->Mode) ?
3 : 2; 3 : 2;
std::cout << "paint: da: " << da << std::endl;
switch (da) switch (da)
{ {
case TopDockWidgetArea: r.setHeight(r.height() / Factor); break; case TopDockWidgetArea: r.setHeight(r.height() / Factor); break;

View File

@ -128,8 +128,6 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
auto DockAreaOverlay = DockManager->dockAreaOverlay(); auto DockAreaOverlay = DockManager->dockAreaOverlay();
auto DockDropArea = DockAreaOverlay->dropAreaUnderCursor(); auto DockDropArea = DockAreaOverlay->dropAreaUnderCursor();
auto ContainerDropArea = ContainerOverlay->dropAreaUnderCursor(); auto ContainerDropArea = ContainerOverlay->dropAreaUnderCursor();
std::cout << "ContainerDropArea " << ContainerDropArea << std::endl;
std::cout << "DockDropArea " << DockDropArea << std::endl;
if (!TopContainer) if (!TopContainer)
{ {
@ -349,7 +347,6 @@ void CFloatingDragPreview::startFloating(const QPoint &DragStartMousePos,
void CFloatingDragPreview::finishDragging() void CFloatingDragPreview::finishDragging()
{ {
ADS_PRINT("CFloatingDragPreview::finishDragging"); ADS_PRINT("CFloatingDragPreview::finishDragging");
std::cout << "CFloatingDragPreview::finishDragging" << std::endl;
auto DockDropArea = d->DockManager->dockAreaOverlay()->visibleDropAreaUnderCursor(); auto DockDropArea = d->DockManager->dockAreaOverlay()->visibleDropAreaUnderCursor();
auto ContainerDropArea = d->DockManager->containerOverlay()->visibleDropAreaUnderCursor(); auto ContainerDropArea = d->DockManager->containerOverlay()->visibleDropAreaUnderCursor();
@ -372,32 +369,15 @@ void CFloatingDragPreview::finishDragging()
} }
else if (ContainerDropArea != InvalidDockWidgetArea) else if (ContainerDropArea != InvalidDockWidgetArea)
{ {
std::cout << "ContainerDropArea != InvalidDockWidgetArea " << ContainerDropArea << std::endl; CDockAreaWidget* DockArea = nullptr;
// If there is only one single dock area, and we drop into the center // If there is only one single dock area, and we drop into the center
// then we tabify the dropped widget into the only visible dock area // then we tabify the dropped widget into the only visible dock area
if (d->DropContainer->visibleDockAreaCount() <= 1 && CenterDockWidgetArea == ContainerDropArea) if (d->DropContainer->visibleDockAreaCount() <= 1 && CenterDockWidgetArea == ContainerDropArea)
{ {
d->DropContainer->dropWidget(d->Content, ContainerDropArea, d->DropContainer->dockAreaAt(QCursor::pos())); DockArea = d->DropContainer->dockAreaAt(QCursor::pos());
}
else if (internal::isSideBarArea(ContainerDropArea))
{
// Drop into AutoHideArea
auto DockWidget = qobject_cast<CDockWidget*>(d->Content);
auto DockArea = qobject_cast<CDockAreaWidget*>(d->Content);
auto SideBarLocation = internal::toSideBarLocation(ContainerDropArea);
if (DockWidget)
{
DockWidget->toggleAutoHide(SideBarLocation);
}
else if (DockArea)
{
DockArea->toggleAutoHide(SideBarLocation);
}
}
else
{
d->DropContainer->dropWidget(d->Content, ContainerDropArea, nullptr);
} }
d->DropContainer->dropWidget(d->Content, ContainerDropArea, DockArea);
} }
else else
{ {