From d9936796fa829ea8099a9b95759d1facc467abf8 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Wed, 28 Jun 2023 10:19:59 +0200 Subject: [PATCH] Added dropIntoAutoHideSideBar() function --- src/DockContainerWidget.cpp | 55 +++++++++++++++++++++++++++++-------- src/DockOverlay.cpp | 4 --- src/FloatingDragPreview.cpp | 28 +++---------------- 3 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index fa21da1..8817c34 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -181,6 +181,11 @@ public: */ 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 */ @@ -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( + QString(), Qt::FindChildrenRecursively); + for (auto DockArea : NewDockAreas) + { + auto DockWidgets = DockArea->dockWidgets(); + for (auto DockWidget : DockWidgets) + { + _this->createAndSetupAutoHideContainer(SideBarLocation, DockWidget); + } + } +} + + //============================================================================ void DockContainerWidgetPrivate::dropIntoCenterOfSection( CFloatingDockContainer* FloatingWidget, CDockAreaWidget* TargetArea) @@ -1661,18 +1683,8 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi { if (internal::isSideBarArea(ContainerDropArea)) { - auto SideBarLocation = internal::toSideBarLocation(ContainerDropArea); - std::cout << "Drop into sidebar " << std::endl; - auto NewDockAreas = FloatingWidget->findChildren( - QString(), Qt::FindChildrenRecursively); - for (auto DockArea : NewDockAreas) - { - auto DockWidgets = DockArea->dockWidgets(); - for (auto DockWidget : DockWidgets) - { - createAndSetupAutoHideContainer(SideBarLocation, DockWidget); - } - } + ADS_PRINT("Container Drop Content: " << ContainerDropArea); + d->dropIntoAutoHideSideBar(FloatingWidget, ContainerDropArea); } else { @@ -1712,10 +1724,29 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi d->DockManager->notifyFloatingWidgetDrop(FloatingWidget); } +/* + * else if (internal::isSideBarArea(ContainerDropArea)) + { + // Drop into AutoHideArea + auto DockWidget = qobject_cast(d->Content); + auto DockArea = qobject_cast(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) { + std::cout << "CDockContainerWidget::dropWidget" << std::endl; CDockWidget* SingleDockWidget = topLevelDockWidget(); if (TargetAreaWidget) { diff --git a/src/DockOverlay.cpp b/src/DockOverlay.cpp index 4f30705..492b036 100644 --- a/src/DockOverlay.cpp +++ b/src/DockOverlay.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include "DockAreaWidget.h" #include "DockAreaTitleBar.h" @@ -459,8 +458,6 @@ DockWidgetArea CDockOverlay::dropAreaUnderCursor() const { auto Rect = rect(); 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)) { return LeftAutoHideArea; @@ -584,7 +581,6 @@ void CDockOverlay::paintEvent(QPaintEvent* event) double Factor = (CDockOverlay::ModeContainerOverlay == d->Mode) ? 3 : 2; - std::cout << "paint: da: " << da << std::endl; switch (da) { case TopDockWidgetArea: r.setHeight(r.height() / Factor); break; diff --git a/src/FloatingDragPreview.cpp b/src/FloatingDragPreview.cpp index 987577e..8ca6926 100644 --- a/src/FloatingDragPreview.cpp +++ b/src/FloatingDragPreview.cpp @@ -128,8 +128,6 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos) auto DockAreaOverlay = DockManager->dockAreaOverlay(); auto DockDropArea = DockAreaOverlay->dropAreaUnderCursor(); auto ContainerDropArea = ContainerOverlay->dropAreaUnderCursor(); - std::cout << "ContainerDropArea " << ContainerDropArea << std::endl; - std::cout << "DockDropArea " << DockDropArea << std::endl; if (!TopContainer) { @@ -349,7 +347,6 @@ void CFloatingDragPreview::startFloating(const QPoint &DragStartMousePos, void CFloatingDragPreview::finishDragging() { ADS_PRINT("CFloatingDragPreview::finishDragging"); - std::cout << "CFloatingDragPreview::finishDragging" << std::endl; auto DockDropArea = d->DockManager->dockAreaOverlay()->visibleDropAreaUnderCursor(); auto ContainerDropArea = d->DockManager->containerOverlay()->visibleDropAreaUnderCursor(); @@ -372,32 +369,15 @@ void CFloatingDragPreview::finishDragging() } 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 // then we tabify the dropped widget into the only visible dock area if (d->DropContainer->visibleDockAreaCount() <= 1 && CenterDockWidgetArea == ContainerDropArea) { - d->DropContainer->dropWidget(d->Content, ContainerDropArea, d->DropContainer->dockAreaAt(QCursor::pos())); - } - else if (internal::isSideBarArea(ContainerDropArea)) - { - // Drop into AutoHideArea - auto DockWidget = qobject_cast(d->Content); - auto DockArea = qobject_cast(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); + DockArea = d->DropContainer->dockAreaAt(QCursor::pos()); } + + d->DropContainer->dropWidget(d->Content, ContainerDropArea, DockArea); } else {