@@ -68,6 +68,7 @@ struct DockWidgetTabPrivate
68
68
QLabel* IconLabel = nullptr ;
69
69
tTabLabel* TitleLabel;
70
70
QPoint GlobalDragStartMousePosition;
71
+ QPoint DragStartMousePosition;
71
72
bool IsActiveTab = false ;
72
73
CDockAreaWidget* DockArea = nullptr ;
73
74
eDragState DragState = DraggingInactive;
@@ -150,6 +151,15 @@ struct DockWidgetTabPrivate
150
151
return w;
151
152
}
152
153
}
154
+
155
+ /* *
156
+ * Saves the drag start position in global and local coordinates
157
+ */
158
+ void saveDragStartMousePosition (const QPoint& GlobalPos)
159
+ {
160
+ GlobalDragStartMousePosition = GlobalPos;
161
+ DragStartMousePosition = _this->mapFromGlobal (GlobalPos);
162
+ }
153
163
};
154
164
// struct DockWidgetTabPrivate
155
165
@@ -229,7 +239,6 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
229
239
230
240
ADS_PRINT (" startFloating" );
231
241
DragState = DraggingState;
232
- auto DragStartMousePosition = _this->mapFromGlobal (GlobalDragStartMousePosition);
233
242
QSize Size = DockArea->size ();
234
243
IFloatingWidget* FloatingWidget = nullptr ;
235
244
bool OpaqueUndocking = CDockManager::configFlags ().testFlag (CDockManager::OpaqueUndocking) ||
@@ -287,7 +296,7 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
287
296
if (ev->button () == Qt::LeftButton)
288
297
{
289
298
ev->accept ();
290
- d->GlobalDragStartMousePosition = ev->globalPos ();
299
+ d->saveDragStartMousePosition ( ev->globalPos () );
291
300
d->DragState = DraggingMousePressed;
292
301
emit clicked ();
293
302
return ;
@@ -304,6 +313,7 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
304
313
{
305
314
auto CurrentDragState = d->DragState ;
306
315
d->GlobalDragStartMousePosition = QPoint ();
316
+ d->DragStartMousePosition = QPoint ();
307
317
d->DragState = DraggingInactive;
308
318
309
319
switch (CurrentDragState)
@@ -412,7 +422,7 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
412
422
return ;
413
423
}
414
424
415
- d->GlobalDragStartMousePosition = ev->globalPos ();
425
+ d->saveDragStartMousePosition ( ev->globalPos () );
416
426
QMenu Menu (this );
417
427
418
428
const bool isFloatable = d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetFloatable);
@@ -542,7 +552,7 @@ void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
542
552
if ((!d->DockArea ->dockContainer ()->isFloating () || d->DockArea ->dockWidgetsCount () > 1 )
543
553
&& d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetFloatable))
544
554
{
545
- d->GlobalDragStartMousePosition = event->globalPos ();
555
+ d->saveDragStartMousePosition ( event->globalPos () );
546
556
d->startFloating (DraggingInactive);
547
557
}
548
558
@@ -585,7 +595,8 @@ void CDockWidgetTab::detachDockWidget()
585
595
{
586
596
return ;
587
597
}
588
- d->GlobalDragStartMousePosition = QCursor::pos ();
598
+
599
+ d->saveDragStartMousePosition (QCursor::pos ());
589
600
d->startFloating (DraggingInactive);
590
601
}
591
602
0 commit comments