DockWidgetMovable feature implemented

In my implementation DockWidgetMovable feature also not allows tab to float.
This commit is contained in:
Opostol 2018-08-10 13:54:09 +03:00 committed by GitHub
parent f823b67a4a
commit 3fc7c195c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -240,6 +240,7 @@ void CDockWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev)
// End of tab moving, change order now // End of tab moving, change order now
if (d->isDraggingState(DraggingTab) && d->DockArea) if (d->isDraggingState(DraggingTab) && d->DockArea)
{ {
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
// Find tab under mouse // Find tab under mouse
QPoint pos = d->DockArea->mapFromGlobal(ev->globalPos()); QPoint pos = d->DockArea->mapFromGlobal(ev->globalPos());
int fromIndex = d->DockArea->tabIndex(d->DockWidget); int fromIndex = d->DockArea->tabIndex(d->DockWidget);
@ -252,6 +253,8 @@ void CDockWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev)
d->DockArea->reorderDockWidget(fromIndex, toIndex); d->DockArea->reorderDockWidget(fromIndex, toIndex);
} }
}
if (!d->DragStartMousePosition.isNull()) if (!d->DragStartMousePosition.isNull())
{ {
emit clicked(); emit clicked();
@ -275,7 +278,9 @@ void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
if (d->isDraggingState(DraggingFloatingWidget)) if (d->isDraggingState(DraggingFloatingWidget))
{ {
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
d->FloatingWidget->moveFloating(); d->FloatingWidget->moveFloating();
}
QFrame::mouseMoveEvent(ev); QFrame::mouseMoveEvent(ev);
return; return;
} }
@ -283,19 +288,25 @@ void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
// move tab // move tab
if (d->isDraggingState(DraggingTab)) if (d->isDraggingState(DraggingTab))
{ {
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
d->moveTab(ev); d->moveTab(ev);
} }
}
bool MouseInsideTitleArea = d->titleAreaGeometryContains(ev->globalPos()); bool MouseInsideTitleArea = d->titleAreaGeometryContains(ev->globalPos());
if (!MouseInsideTitleArea) if (!MouseInsideTitleArea)
{ {
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
d->startFloating(); d->startFloating();
}
return; return;
} }
else if (d->DockArea->count() > 1 else if (d->DockArea->count() > 1
&& (ev->pos() - d->DragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving && (ev->pos() - d->DragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
{ {
if (d->DockWidget->features() & CDockWidget::DockWidgetMovable) {
d->DragState = DraggingTab; d->DragState = DraggingTab;
}
return; return;
} }