MCPcopy Create free account
hub / github.com/KDE/labplot / mouseMoveEvent

Method mouseMoveEvent

src/3rdparty/Qt-Advanced-Docking-System/src/DockWidgetTab.cpp:449–520  ·  view source on GitHub ↗

============================================================================

Source from the content-addressed store, hash-verified

447
448//============================================================================
449void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
450{
451 if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
452 {
453 d->DragState = DraggingInactive;
454 Super::mouseMoveEvent(ev);
455 return;
456 }
457
458 // move floating window
459 if (d->isDraggingState(DraggingFloatingWidget))
460 {
461 d->FloatingWidget->moveFloating();
462 Super::mouseMoveEvent(ev);
463 return;
464 }
465
466 // move tab
467 if (d->isDraggingState(DraggingTab))
468 {
469 // Moving the tab is always allowed because it does not mean moving the
470 // dock widget around
471 d->moveTab(ev);
472 }
473
474 auto MappedPos = mapToParent(ev->pos());
475 bool MouseOutsideBar = (MappedPos.x() < 0) || (MappedPos.x() > parentWidget()->rect().right());
476 // Maybe a fixed drag distance is better here ?
477 int DragDistanceY = qAbs(d->GlobalDragStartMousePosition.y() - internal::globalPositionOf(ev).y());
478 if (DragDistanceY >= CDockManager::startDragDistance() || MouseOutsideBar)
479 {
480 // If this is the last dock area in a dock container with only
481 // one single dock widget it does not make sense to move it to a new
482 // floating widget and leave this one empty
483 if (d->DockArea->dockContainer()->isFloating()
484 && d->DockArea->openDockWidgetsCount() == 1
485 && d->DockArea->dockContainer()->visibleDockAreaCount() == 1)
486 {
487 return;
488 }
489
490
491 // Floating is only allowed for widgets that are floatable
492 // We can create the drag preview if the widget is movable.
493 auto Features = d->DockWidget->features();
494 if (Features.testFlag(CDockWidget::DockWidgetFloatable) || (Features.testFlag(CDockWidget::DockWidgetMovable)))
495 {
496 // If we undock, we need to restore the initial position of this
497 // tab because it looks strange if it remains on its dragged position
498 if (d->isDraggingState(DraggingTab))
499 {
500 parentWidget()->layout()->update();
501 }
502 d->startFloating();
503 }
504 return;
505 }
506 else if (d->DockArea->openDockWidgetsCount() > 1

Callers

nothing calls this directly

Calls 14

globalPositionOfFunction · 0.85
moveTabMethod · 0.80
xMethod · 0.80
rectMethod · 0.80
openDockWidgetsCountMethod · 0.80
visibleDockAreaCountMethod · 0.80
isDraggingStateMethod · 0.45
moveFloatingMethod · 0.45
yMethod · 0.45
isFloatingMethod · 0.45
dockContainerMethod · 0.45
featuresMethod · 0.45

Tested by

no test coverage detected