@@ -66,6 +66,12 @@ struct FloatingDragPreviewPrivate
6666 DockManager->dockAreaOverlay ()->hideOverlay ();
6767 _this->close ();
6868 }
69+
70+ /* *
71+ * Creates the real floating widget in case the mouse is released outside
72+ * outside of any drop area
73+ */
74+ void createFloatingWidget ();
6975};
7076// struct LedArrayPanelPrivate
7177
@@ -173,6 +179,40 @@ FloatingDragPreviewPrivate::FloatingDragPreviewPrivate(CFloatingDragPreview *_pu
173179
174180}
175181
182+
183+ // ============================================================================
184+ void FloatingDragPreviewPrivate::createFloatingWidget ()
185+ {
186+ CDockWidget* DockWidget = qobject_cast<CDockWidget*>(Content);
187+ CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(Content);
188+
189+ CFloatingDockContainer* FloatingWidget = nullptr ;
190+
191+ if (DockWidget && DockWidget->features ().testFlag (CDockWidget::DockWidgetFloatable))
192+ {
193+ FloatingWidget = new CFloatingDockContainer (DockWidget);
194+ }
195+ else if (DockArea && DockArea->features ().testFlag (CDockWidget::DockWidgetFloatable))
196+ {
197+ FloatingWidget = new CFloatingDockContainer (DockArea);
198+ }
199+
200+ if (FloatingWidget)
201+ {
202+ FloatingWidget->setGeometry (_this->geometry ());
203+ FloatingWidget->show ();
204+ if (!CDockManager::configFlags ().testFlag (CDockManager::DragPreviewHasWindowFrame))
205+ {
206+ QApplication::processEvents ();
207+ int FrameHeight = FloatingWidget->frameGeometry ().height () - FloatingWidget->geometry ().height ();
208+ QRect FixedGeometry = _this->geometry ();
209+ FixedGeometry.adjust (0 , FrameHeight, 0 , 0 );
210+ FloatingWidget->setGeometry (FixedGeometry);
211+ }
212+ }
213+ }
214+
215+
176216// ============================================================================
177217CFloatingDragPreview::CFloatingDragPreview (QWidget* Content, QWidget* parent) :
178218 QWidget (parent),
@@ -288,42 +328,25 @@ void CFloatingDragPreview::finishDragging()
288328 ADS_PRINT (" CFloatingDragPreview::finishDragging" );
289329 auto DockDropArea = d->DockManager ->dockAreaOverlay ()->visibleDropAreaUnderCursor ();
290330 auto ContainerDropArea = d->DockManager ->containerOverlay ()->visibleDropAreaUnderCursor ();
291- if (d->DropContainer && (DockDropArea != InvalidDockWidgetArea) )
331+ if (! d->DropContainer )
292332 {
293- d->DropContainer -> dropWidget (d-> Content , DockDropArea, d-> DropContainer -> dockAreaAt ( QCursor::pos ()) );
333+ d->createFloatingWidget ( );
294334 }
295- else if (d-> DropContainer && (ContainerDropArea != InvalidDockWidgetArea) )
335+ else if (DockDropArea != InvalidDockWidgetArea)
296336 {
297- d->DropContainer ->dropWidget (d->Content , ContainerDropArea, nullptr );
337+ d->DropContainer ->dropWidget (d->Content , DockDropArea, d-> DropContainer -> dockAreaAt ( QCursor::pos ()) );
298338 }
299- else
339+ else if (ContainerDropArea != InvalidDockWidgetArea)
300340 {
301- CDockWidget* DockWidget = qobject_cast<CDockWidget*>(d->Content );
302- CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(d->Content );
303-
304- CFloatingDockContainer* FloatingWidget = nullptr ;
305-
306- if (DockWidget && DockWidget->features ().testFlag (CDockWidget::DockWidgetFloatable))
307- {
308- FloatingWidget = new CFloatingDockContainer (DockWidget);
309- }
310- else if (DockArea && DockArea->features ().testFlag (CDockWidget::DockWidgetFloatable))
341+ // If there is only one single dock area, and we drop into the center
342+ // then we tabify the dropped widget into the only visible dock area
343+ if (d->DropContainer ->visibleDockAreaCount () <= 1 && CenterDockWidgetArea == ContainerDropArea)
311344 {
312- FloatingWidget = new CFloatingDockContainer (DockArea );
345+ d-> DropContainer -> dropWidget (d-> Content , ContainerDropArea, d-> DropContainer -> dockAreaAt ( QCursor::pos ()) );
313346 }
314-
315- if (FloatingWidget)
347+ else
316348 {
317- FloatingWidget->setGeometry (this ->geometry ());
318- FloatingWidget->show ();
319- if (!CDockManager::configFlags ().testFlag (CDockManager::DragPreviewHasWindowFrame))
320- {
321- QApplication::processEvents ();
322- int FrameHeight = FloatingWidget->frameGeometry ().height () - FloatingWidget->geometry ().height ();
323- QRect FixedGeometry = this ->geometry ();
324- FixedGeometry.adjust (0 , FrameHeight, 0 , 0 );
325- FloatingWidget->setGeometry (FixedGeometry);
326- }
349+ d->DropContainer ->dropWidget (d->Content , ContainerDropArea, nullptr );
327350 }
328351 }
329352
0 commit comments