@@ -67,7 +67,7 @@ struct DockWidgetTabPrivate
67
67
CDockWidget* DockWidget;
68
68
QLabel* IconLabel = nullptr ;
69
69
tTabLabel* TitleLabel;
70
- QPoint DragStartMousePosition ;
70
+ QPoint GlobalDragStartMousePosition ;
71
71
bool IsActiveTab = false ;
72
72
CDockAreaWidget* DockArea = nullptr ;
73
73
eDragState DragState = DraggingInactive;
@@ -219,7 +219,7 @@ void DockWidgetTabPrivate::createLayout()
219
219
void DockWidgetTabPrivate::moveTab (QMouseEvent* ev)
220
220
{
221
221
ev->accept ();
222
- QPoint Distance = ev->globalPos () - DragStartMousePosition ;
222
+ QPoint Distance = ev->globalPos () - GlobalDragStartMousePosition ;
223
223
Distance.setY (0 );
224
224
auto TargetPos = Distance + TabDragStartPosition;
225
225
_this->move (TargetPos);
@@ -246,6 +246,7 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
246
246
247
247
ADS_PRINT (" startFloating" );
248
248
DragState = DraggingState;
249
+ auto DragStartMousePosition = _this->mapFromGlobal (GlobalDragStartMousePosition);
249
250
QSize Size = DockArea->size ();
250
251
IFloatingWidget* FloatingWidget = nullptr ;
251
252
bool OpaqueUndocking = CDockManager::configFlags ().testFlag (CDockManager::OpaqueUndocking) ||
@@ -265,16 +266,14 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
265
266
266
267
if (DraggingFloatingWidget == DraggingState)
267
268
{
268
- FloatingWidget->startFloating (_this->mapFromGlobal (DragStartMousePosition),
269
- Size , DraggingFloatingWidget, _this);
269
+ FloatingWidget->startFloating (DragStartMousePosition, Size , DraggingFloatingWidget, _this);
270
270
auto Overlay = DockWidget->dockManager ()->containerOverlay ();
271
271
Overlay->setAllowedAreas (OuterDockAreas);
272
272
this ->FloatingWidget = FloatingWidget;
273
273
}
274
274
else
275
275
{
276
- FloatingWidget->startFloating (_this->mapFromGlobal (DragStartMousePosition),
277
- Size , DraggingInactive, nullptr );
276
+ FloatingWidget->startFloating (DragStartMousePosition, Size , DraggingInactive, nullptr );
278
277
}
279
278
280
279
return true ;
@@ -305,7 +304,7 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
305
304
if (ev->button () == Qt::LeftButton)
306
305
{
307
306
ev->accept ();
308
- d->DragStartMousePosition = ev->globalPos ();
307
+ d->GlobalDragStartMousePosition = ev->globalPos ();
309
308
d->DragState = DraggingMousePressed;
310
309
emit clicked ();
311
310
return ;
@@ -321,7 +320,7 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
321
320
if (ev->button () == Qt::LeftButton)
322
321
{
323
322
auto CurrentDragState = d->DragState ;
324
- d->DragStartMousePosition = QPoint ();
323
+ d->GlobalDragStartMousePosition = QPoint ();
325
324
d->DragState = DraggingInactive;
326
325
327
326
switch (CurrentDragState)
@@ -373,7 +372,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
373
372
}
374
373
375
374
// Maybe a fixed drag distance is better here ?
376
- int DragDistanceY = qAbs (d->DragStartMousePosition .y () - ev->globalPos ().y ());
375
+ int DragDistanceY = qAbs (d->GlobalDragStartMousePosition .y () - ev->globalPos ().y ());
377
376
if (DragDistanceY >= CDockManager::startDragDistance ())
378
377
{
379
378
// If this is the last dock area in a dock container with only
@@ -400,7 +399,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
400
399
return ;
401
400
}
402
401
else if (d->DockArea ->openDockWidgetsCount () > 1
403
- && (ev->globalPos () - d->DragStartMousePosition ).manhattanLength () >= QApplication::startDragDistance ()) // Wait a few pixels before start moving
402
+ && (ev->globalPos () - d->GlobalDragStartMousePosition ).manhattanLength () >= QApplication::startDragDistance ()) // Wait a few pixels before start moving
404
403
{
405
404
// If we start dragging the tab, we save its inital position to
406
405
// restore it later
@@ -425,7 +424,7 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
425
424
return ;
426
425
}
427
426
428
- d->DragStartMousePosition = ev->globalPos ();
427
+ d->GlobalDragStartMousePosition = ev->globalPos ();
429
428
QMenu Menu (this );
430
429
auto Action = Menu.addAction (tr (" Detach" ), this , SLOT (detachDockWidget ()));
431
430
Action->setEnabled (d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetFloatable));
@@ -550,7 +549,7 @@ void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
550
549
if ((!d->DockArea ->dockContainer ()->isFloating () || d->DockArea ->dockWidgetsCount () > 1 )
551
550
&& d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetFloatable))
552
551
{
553
- d->DragStartMousePosition = event->globalPos ();
552
+ d->GlobalDragStartMousePosition = event->globalPos ();
554
553
d->startFloating (DraggingInactive);
555
554
}
556
555
@@ -588,7 +587,7 @@ void CDockWidgetTab::detachDockWidget()
588
587
{
589
588
return ;
590
589
}
591
- d->DragStartMousePosition = QCursor::pos ();
590
+ d->GlobalDragStartMousePosition = QCursor::pos ();
592
591
d->startFloating (DraggingInactive);
593
592
}
594
593
0 commit comments