Skip to content

Commit a2a328e

Browse files
Ensure that auto hide widget will be closed if user starts dragging floating widget or docked widget
1 parent dba6e6c commit a2a328e

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

src/AutoHideDockContainer.cpp

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -513,23 +513,10 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
513513
}
514514
else if (event->type() == QEvent::MouseButtonPress)
515515
{
516-
// If the user clicked into another window, then we collapse the
517-
// auto hide widget
518-
/*qDebug() << 1;
519-
qDebug() << "is_ancestor_of " << is_ancestor_of(watched, this);
520-
auto widget = qobject_cast<QWidget*>(watched);
521-
qDebug() << "isAnchestorOf" << isAncestorOf(widget);
522-
if (widget && widget->window() != this->window())
523-
{
524-
collapseView(true);
525-
return Super::eventFilter(watched, event);
526-
}*/
527-
528516
// We check, if the mouse button press is inside the container
529517
// widget. If it is not, i.e. if someone resizes the main window or
530518
// clicks into the application menu or toolbar, then we ignore the
531519
// event
532-
qDebug() << 2;
533520
auto Container = dockContainer();
534521
QMouseEvent* me = static_cast<QMouseEvent*>(event);
535522
auto GlobalPos = internal::globalPositionOf(me);
@@ -543,7 +530,6 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
543530
// If the click is inside of this auto hide container, then we can also
544531
// ignore the event, because the auto hide overlay should not get collapsed if
545532
// user works in it
546-
qDebug() << 3;
547533
pos = mapFromGlobal(GlobalPos);
548534
if (rect().contains(pos))
549535
{
@@ -554,7 +540,6 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
554540
// because the side tab click handler will call collapseView(). If we
555541
// do not ignore this here, then we will collapse the container and the side tab
556542
// click handler will uncollapse it
557-
qDebug() << 4;
558543
auto SideTab = d->SideTab;
559544
pos = SideTab->mapFromGlobal(GlobalPos);
560545
if (SideTab->rect().contains(pos))
@@ -565,13 +550,21 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
565550
// If the mouse button down event is in the dock manager but outside
566551
// of the open auto hide container, then the auto hide dock widget
567552
// should get collapsed
568-
qDebug() << 5;
569553
collapseView(true);
570554
}
571-
else if (event->type() == internal::FloatingWidgetDragStartEvent
572-
|| event->type() == internal::DockedWidgetDragStartEvent)
555+
else if (event->type() == internal::FloatingWidgetDragStartEvent)
556+
{
557+
// If we are dragging our own floating widget, the we do not need to
558+
// collapse the view
559+
auto FloatingWidget = dockContainer()->floatingWidget();
560+
if (FloatingWidget != watched)
561+
{
562+
collapseView(true);
563+
}
564+
}
565+
else if (event->type() == internal::DockedWidgetDragStartEvent)
573566
{
574-
collapseView(true);
567+
collapseView(true);
575568
}
576569

577570
return Super::eventFilter(watched, event);

src/DockAreaTitleBar.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ void DockAreaTitleBarPrivate::startFloating(const QPoint& Offset)
302302
DockArea->autoHideDockContainer()->hide();
303303
}
304304
FloatingWidget = makeAreaFloating(Offset, DraggingFloatingWidget);
305+
qApp->postEvent(DockArea, new QEvent((QEvent::Type)internal::DockedWidgetDragStartEvent));
305306
}
306307

307308

src/DockWidgetTab.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
337337
auto Overlay = DockManager->containerOverlay();
338338
Overlay->setAllowedAreas(OuterDockAreas);
339339
this->FloatingWidget = FloatingWidget;
340-
qApp->postEvent(DockManager, new QEvent((QEvent::Type)internal::DockedWidgetDragStartEvent));
340+
qApp->postEvent(DockWidget, new QEvent((QEvent::Type)internal::DockedWidgetDragStartEvent));
341341
}
342342
else
343343
{

src/FloatingDockContainer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ struct FloatingDockContainerPrivate
418418
DraggingState = StateId;
419419
if (DraggingFloatingWidget == DraggingState)
420420
{
421-
qApp->postEvent(DockManager, new QEvent((QEvent::Type)internal::FloatingWidgetDragStartEvent));
421+
qApp->postEvent(_this, new QEvent((QEvent::Type)internal::FloatingWidgetDragStartEvent));
422422
}
423423
}
424424

0 commit comments

Comments
 (0)