From 412f13e1c4837571c753fbf3c759bd4671419aa0 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 5 Sep 2017 14:03:43 +0200 Subject: [PATCH] Implemented fix to prevent display of drop overlays and overlay icons when resizing a floating widget --- src/FloatingDockContainer.cpp | 39 +++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index ad2891f..85fb12a 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -59,6 +59,7 @@ struct FloatingDockContainerPrivate unsigned int zOrderIndex = ++zOrderCounter; QPointer DockManager; bool DraggingActive = false; + bool NonClientAreaMouseButtonPress = false; QPoint DragStartMousePosition; CDockContainerWidget* DropContainer = nullptr; CDockAreaWidget* SingleDockArea = nullptr; @@ -92,19 +93,24 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent() return; } - // Resize the floating widget to the size of the highlighted drop area - // rectangle - QRect Rect = DockManager->containerOverlay()->dropOverlayRect(); - if (!Rect.isValid()) + if (DockManager->dockAreaOverlay()->dropAreaUnderCursor() != InvalidDockWidgetArea + || DockManager->containerOverlay()->dropAreaUnderCursor() != InvalidDockWidgetArea) { - Rect = DockManager->dockAreaOverlay()->rect(); + // Resize the floating widget to the size of the highlighted drop area + // rectangle + QRect Rect = DockManager->containerOverlay()->dropOverlayRect(); + if (!Rect.isValid()) + { + Rect = DockManager->dockAreaOverlay()->rect(); + } + + if (Rect.isValid()) + { + _this->resize(Rect.size()); + } + DropContainer->dropFloatingWidget(_this, QCursor::pos()); } - if (Rect.isValid()) - { - _this->resize(Rect.size()); - } - DropContainer->dropFloatingWidget(_this, QCursor::pos()); DockManager->containerOverlay()->hideOverlay(); DockManager->dockAreaOverlay()->hideOverlay(); } @@ -192,6 +198,10 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos) void FloatingDockContainerPrivate::setDraggingActive(bool Active) { DraggingActive = Active; + if (!DraggingActive) + { + NonClientAreaMouseButtonPress = false; + } } @@ -331,12 +341,13 @@ void CFloatingDockContainer::showEvent(QShowEvent *event) //============================================================================ bool CFloatingDockContainer::event(QEvent *e) { - if ((e->type() == QEvent::NonClientAreaMouseButtonPress)) + if (e->type() == QEvent::NonClientAreaMouseButtonPress) { if (QGuiApplication::mouseButtons() == Qt::LeftButton) { qDebug() << "FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type(); d->setDraggingActive(true); + d->NonClientAreaMouseButtonPress = true; } } else if (e->type() == QEvent::NonClientAreaMouseButtonDblClick) @@ -349,6 +360,12 @@ bool CFloatingDockContainer::event(QEvent *e) qDebug() << "FloatingWidget::event QEvent::NonClientAreaMouseButtonRelease"; d->titleMouseReleaseEvent(); } + else if (d->NonClientAreaMouseButtonPress && (e->type() == QEvent::Resize)) + { + // If user resizes the floating widget, we do not want to show any + // drop overlays or drop overlay icons + d->setDraggingActive(false); + } return QWidget::event(e); }