Skip to content

Commit aa7976d

Browse files
Fixed issue #164 - Single DockArea cannot be split
1 parent b7e7c0c commit aa7976d

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

src/DockAreaTitleBar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ void CDockAreaTitleBar::mouseMoveEvent(QMouseEvent* ev)
589589
return;
590590
}
591591

592-
// If this is the last dock area in a dock container it does not make
592+
// If this is the last dock area in a floating dock container it does not make
593593
// sense to move it to a new floating widget and leave this one
594594
// empty
595595
if (d->DockArea->dockContainer()->isFloating()
@@ -612,7 +612,7 @@ void CDockAreaTitleBar::mouseMoveEvent(QMouseEvent* ev)
612612
int DragDistance = (d->DragStartMousePos - ev->pos()).manhattanLength();
613613
if (DragDistance >= CDockManager::startDragDistance())
614614
{
615-
ADS_PRINT("CTabsScrollArea::startFloating");
615+
ADS_PRINT("CDockAreaTitlBar::startFloating");
616616
d->startFloating(d->DragStartMousePos);
617617
auto Overlay = d->DockArea->dockManager()->containerOverlay();
618618
Overlay->setAllowedAreas(OuterDockAreas);

src/FloatingDragPreview.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ struct FloatingDragPreviewPrivate
3333
CFloatingDragPreview *_this;
3434
QWidget* Content;
3535
CDockAreaWidget* ContentSourceArea = nullptr;
36-
CDockContainerWidget* ContenSourceContainer = nullptr;
3736
QPoint DragStartMousePosition;
3837
CDockManager* DockManager;
3938
CDockContainerWidget *DropContainer = nullptr;
@@ -123,22 +122,8 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
123122
int VisibleDockAreas = TopContainer->visibleDockAreaCount();
124123
ContainerOverlay->setAllowedAreas(
125124
VisibleDockAreas > 1 ? OuterDockAreas : AllDockAreas);
126-
127-
DockWidgetArea ContainerArea = InvalidDockWidgetArea;
128-
// If there is only one single visible dock area in a container, then
129-
// it does not make sense to show a dock overlay because the dock area
130-
// would be removed and inserted at the same position
131-
if (VisibleDockAreas <= 1)
132-
{
133-
ContainerOverlay->hideOverlay();
134-
}
135-
else
136-
{
137-
ContainerArea = ContainerOverlay->showOverlay(TopContainer);
138-
}
139-
ContainerOverlay->enableDropPreview(ContainerArea != InvalidDockWidgetArea);
140125
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
141-
if (DockArea && DockArea->isVisible() && VisibleDockAreas > 0 && DockArea != ContentSourceArea)
126+
if (DockArea && DockArea->isVisible() && VisibleDockAreas >= 0 && DockArea != ContentSourceArea)
142127
{
143128
DockAreaOverlay->enableDropPreview(true);
144129
DockAreaOverlay->setAllowedAreas(
@@ -149,8 +134,7 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
149134
// the mouse is in the title bar. If the ContainerArea is valid
150135
// then we ignore the dock area of the dockAreaOverlay() and disable
151136
// the drop preview
152-
if ((Area == CenterDockWidgetArea)
153-
&& (ContainerArea != InvalidDockWidgetArea))
137+
if ((Area == CenterDockWidgetArea) && (ContainerDropArea != InvalidDockWidgetArea))
154138
{
155139
DockAreaOverlay->enableDropPreview(false);
156140
ContainerOverlay->enableDropPreview(true);
@@ -159,10 +143,24 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
159143
{
160144
ContainerOverlay->enableDropPreview(InvalidDockWidgetArea == Area);
161145
}
146+
ContainerOverlay->showOverlay(TopContainer);
162147
}
163148
else
164149
{
165150
DockAreaOverlay->hideOverlay();
151+
// If there is only one single visible dock area in a container, then
152+
// it does not make sense to show a dock overlay because the dock area
153+
// would be removed and inserted at the same position
154+
if (VisibleDockAreas <= 1)
155+
{
156+
ContainerOverlay->hideOverlay();
157+
}
158+
else
159+
{
160+
ContainerOverlay->showOverlay(TopContainer);
161+
}
162+
163+
166164
if (DockArea == ContentSourceArea && InvalidDockWidgetArea == ContainerDropArea)
167165
{
168166
DropContainer = nullptr;
@@ -270,7 +268,6 @@ CFloatingDragPreview::CFloatingDragPreview(CDockWidget* Content)
270268
if (Content->dockAreaWidget()->openDockWidgetsCount() == 1)
271269
{
272270
d->ContentSourceArea = Content->dockAreaWidget();
273-
d->ContenSourceContainer = Content->dockContainer();
274271
}
275272
setWindowTitle(Content->windowTitle());
276273
}
@@ -282,7 +279,6 @@ CFloatingDragPreview::CFloatingDragPreview(CDockAreaWidget* Content)
282279
{
283280
d->DockManager = Content->dockManager();
284281
d->ContentSourceArea = Content;
285-
d->ContenSourceContainer = Content->dockContainer();
286282
setWindowTitle(Content->currentDockWidget()->windowTitle());
287283
}
288284

0 commit comments

Comments
 (0)