@@ -66,6 +66,12 @@ struct FloatingDragPreviewPrivate
66
66
DockManager->dockAreaOverlay ()->hideOverlay ();
67
67
_this->close ();
68
68
}
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 ();
69
75
};
70
76
// struct LedArrayPanelPrivate
71
77
@@ -173,6 +179,40 @@ FloatingDragPreviewPrivate::FloatingDragPreviewPrivate(CFloatingDragPreview *_pu
173
179
174
180
}
175
181
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
+
176
216
// ============================================================================
177
217
CFloatingDragPreview::CFloatingDragPreview (QWidget* Content, QWidget* parent) :
178
218
QWidget (parent),
@@ -288,42 +328,25 @@ void CFloatingDragPreview::finishDragging()
288
328
ADS_PRINT (" CFloatingDragPreview::finishDragging" );
289
329
auto DockDropArea = d->DockManager ->dockAreaOverlay ()->visibleDropAreaUnderCursor ();
290
330
auto ContainerDropArea = d->DockManager ->containerOverlay ()->visibleDropAreaUnderCursor ();
291
- if (d->DropContainer && (DockDropArea != InvalidDockWidgetArea) )
331
+ if (! d->DropContainer )
292
332
{
293
- d->DropContainer -> dropWidget (d-> Content , DockDropArea, d-> DropContainer -> dockAreaAt ( QCursor::pos ()) );
333
+ d->createFloatingWidget ( );
294
334
}
295
- else if (d-> DropContainer && (ContainerDropArea != InvalidDockWidgetArea) )
335
+ else if (DockDropArea != InvalidDockWidgetArea)
296
336
{
297
- d->DropContainer ->dropWidget (d->Content , ContainerDropArea, nullptr );
337
+ d->DropContainer ->dropWidget (d->Content , DockDropArea, d-> DropContainer -> dockAreaAt ( QCursor::pos ()) );
298
338
}
299
- else
339
+ else if (ContainerDropArea != InvalidDockWidgetArea)
300
340
{
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)
311
344
{
312
- FloatingWidget = new CFloatingDockContainer (DockArea );
345
+ d-> DropContainer -> dropWidget (d-> Content , ContainerDropArea, d-> DropContainer -> dockAreaAt ( QCursor::pos ()) );
313
346
}
314
-
315
- if (FloatingWidget)
347
+ else
316
348
{
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 );
327
350
}
328
351
}
329
352
0 commit comments