Skip to content

Commit

Permalink
Implemented fix to prevent display of drop overlays and overlay icons…
Browse files Browse the repository at this point in the history
… when resizing a floating widget
  • Loading branch information
Uwe Kindler committed Sep 5, 2017
1 parent 11a3080 commit 412f13e
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions src/FloatingDockContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct FloatingDockContainerPrivate
unsigned int zOrderIndex = ++zOrderCounter;
QPointer<CDockManager> DockManager;
bool DraggingActive = false;
bool NonClientAreaMouseButtonPress = false;
QPoint DragStartMousePosition;
CDockContainerWidget* DropContainer = nullptr;
CDockAreaWidget* SingleDockArea = nullptr;
Expand Down Expand Up @@ -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());
if (Rect.isValid())
{
_this->resize(Rect.size());
}
DropContainer->dropFloatingWidget(_this, QCursor::pos());
}
DropContainer->dropFloatingWidget(_this, QCursor::pos());

DockManager->containerOverlay()->hideOverlay();
DockManager->dockAreaOverlay()->hideOverlay();
}
Expand Down Expand Up @@ -192,6 +198,10 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos)
void FloatingDockContainerPrivate::setDraggingActive(bool Active)
{
DraggingActive = Active;
if (!DraggingActive)
{
NonClientAreaMouseButtonPress = false;
}
}


Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down

0 comments on commit 412f13e

Please sign in to comment.