Fixed #481 issue Undocking an autohide dock widget does not close the AutoHideTab from the sidebar

This commit is contained in:
Uwe Kindler 2023-01-20 09:44:18 +01:00
parent bbfe99ce7d
commit 378c647952
3 changed files with 26 additions and 13 deletions

View File

@ -262,12 +262,16 @@ IFloatingWidget* DockAreaTitleBarPrivate::makeAreaFloating(const QPoint& Offset,
{ {
QSize Size = DockArea->size(); QSize Size = DockArea->size();
this->DragState = DragState; this->DragState = DragState;
bool OpaqueUndocking = CDockManager::testConfigFlag(CDockManager::OpaqueUndocking) || bool CreateFloatingDockContainer = CDockManager::testConfigFlag(
(DraggingFloatingWidget != DragState); CDockManager::OpaqueUndocking) || (DraggingFloatingWidget != DragState);
CFloatingDockContainer* FloatingDockContainer = nullptr; CFloatingDockContainer* FloatingDockContainer = nullptr;
IFloatingWidget* FloatingWidget; IFloatingWidget* FloatingWidget;
if (OpaqueUndocking) if (CreateFloatingDockContainer)
{ {
if (DockArea->autoHideDockContainer())
{
DockArea->autoHideDockContainer()->cleanupAndDelete();
}
FloatingWidget = FloatingDockContainer = new CFloatingDockContainer(DockArea); FloatingWidget = FloatingDockContainer = new CFloatingDockContainer(DockArea);
} }
else else
@ -297,7 +301,7 @@ IFloatingWidget* DockAreaTitleBarPrivate::makeAreaFloating(const QPoint& Offset,
//============================================================================ //============================================================================
void DockAreaTitleBarPrivate::startFloating(const QPoint& Offset) void DockAreaTitleBarPrivate::startFloating(const QPoint& Offset)
{ {
if (DockArea->autoHideDockContainer() != nullptr) if (DockArea->autoHideDockContainer())
{ {
DockArea->autoHideDockContainer()->hide(); DockArea->autoHideDockContainer()->hide();
} }
@ -428,11 +432,6 @@ void CDockAreaTitleBar::onUndockButtonClicked()
{ {
if (d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable)) if (d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
{ {
if (d->DockArea->autoHideDockContainer())
{
d->DockArea->autoHideDockContainer()->cleanupAndDelete();
}
d->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive); d->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive);
} }
} }
@ -590,6 +589,10 @@ void CDockAreaTitleBar::mouseReleaseEvent(QMouseEvent* ev)
if (ev->button() == Qt::LeftButton) if (ev->button() == Qt::LeftButton)
{ {
ADS_PRINT("CDockAreaTitleBar::mouseReleaseEvent"); ADS_PRINT("CDockAreaTitleBar::mouseReleaseEvent");
if (CDockManager::testConfigFlag(CDockManager::OpaqueUndocking))
{
releaseMouse();
}
ev->accept(); ev->accept();
auto CurrentDragState = d->DragState; auto CurrentDragState = d->DragState;
d->DragStartMousePos = QPoint(); d->DragStartMousePos = QPoint();
@ -650,6 +653,10 @@ void CDockAreaTitleBar::mouseMoveEvent(QMouseEvent* ev)
d->startFloating(d->DragStartMousePos); d->startFloating(d->DragStartMousePos);
auto Overlay = d->DockArea->dockManager()->containerOverlay(); auto Overlay = d->DockArea->dockManager()->containerOverlay();
Overlay->setAllowedAreas(OuterDockAreas); Overlay->setAllowedAreas(OuterDockAreas);
if (CDockManager::testConfigFlag(CDockManager::OpaqueUndocking))
{
grabMouse();
}
} }
return; return;
@ -671,10 +678,6 @@ void CDockAreaTitleBar::mouseDoubleClickEvent(QMouseEvent *event)
{ {
return; return;
} }
if (d->DockArea->autoHideDockContainer())
{
d->DockArea->autoHideDockContainer()->cleanupAndDelete();
}
d->makeAreaFloating(event->pos(), DraggingInactive); d->makeAreaFloating(event->pos(), DraggingInactive);
} }

View File

@ -392,6 +392,10 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
{ {
if (ev->button() == Qt::LeftButton) if (ev->button() == Qt::LeftButton)
{ {
if (CDockManager::testConfigFlag(CDockManager::OpaqueUndocking))
{
releaseMouse();
}
auto CurrentDragState = d->DragState; auto CurrentDragState = d->DragState;
d->GlobalDragStartMousePosition = QPoint(); d->GlobalDragStartMousePosition = QPoint();
d->DragStartMousePosition = QPoint(); d->DragStartMousePosition = QPoint();
@ -490,6 +494,10 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
parentWidget()->layout()->update(); parentWidget()->layout()->update();
} }
d->startFloating(); d->startFloating();
if (CDockManager::testConfigFlag(CDockManager::OpaqueUndocking))
{
grabMouse();
}
} }
return; return;
} }

View File

@ -38,6 +38,8 @@
#include <QStyle> #include <QStyle>
#include <QMouseEvent> #include <QMouseEvent>
#include <iostream>
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
#include <xcb/xcb.h> #include <xcb/xcb.h>
#endif #endif