mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Properly implemented handling of DockWidget flag DockWidgetIsMovable for NonOpaque undocking - creating the drag preview is allowed even if the DockWidget is not floatable
This commit is contained in:
parent
2c15d5dacd
commit
d4a18003d9
@ -331,6 +331,8 @@ void MainWindowPrivate::createContent()
|
|||||||
auto ToolBar = FileSystemWidget->createDefaultToolBar();
|
auto ToolBar = FileSystemWidget->createDefaultToolBar();
|
||||||
ToolBar->addAction(ui.actionSaveState);
|
ToolBar->addAction(ui.actionSaveState);
|
||||||
ToolBar->addAction(ui.actionRestoreState);
|
ToolBar->addAction(ui.actionRestoreState);
|
||||||
|
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
|
||||||
|
appendFeaturStringToWindowTitle(FileSystemWidget);
|
||||||
DockManager->addDockWidget(ads::BottomDockWidgetArea, FileSystemWidget);
|
DockManager->addDockWidget(ads::BottomDockWidgetArea, FileSystemWidget);
|
||||||
|
|
||||||
FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
|
FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
|
||||||
@ -484,9 +486,9 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
|||||||
// a QToolButton instead of a QPushButton
|
// a QToolButton instead of a QPushButton
|
||||||
// CDockManager::setConfigFlags(CDockManager::configFlags() | CDockManager::TabCloseButtonIsToolButton);
|
// CDockManager::setConfigFlags(CDockManager::configFlags() | CDockManager::TabCloseButtonIsToolButton);
|
||||||
|
|
||||||
// comment the following line if you want to use opaque undocking and
|
// uncomment the following line if you want to use opaque undocking and
|
||||||
// opaque splitter resizing
|
// opaque splitter resizing
|
||||||
CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
|
// CDockManager::setConfigFlags(CDockManager::DefaultOpaqueConfig);
|
||||||
|
|
||||||
// uncomment the following line if you want a fixed tab width that does
|
// uncomment the following line if you want a fixed tab width that does
|
||||||
// not change if the visibility of the close button changes
|
// not change if the visibility of the close button changes
|
||||||
|
@ -600,7 +600,11 @@ void CDockAreaTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
|
|
||||||
// If one single dock widget in this area is not floatable then the whole
|
// If one single dock widget in this area is not floatable then the whole
|
||||||
// area is not floatable
|
// area is not floatable
|
||||||
if (!d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
|
// If we do non opaque undocking, then we can create the floating drag
|
||||||
|
// preview if the dock widget is movable
|
||||||
|
auto Features = d->DockArea->features();
|
||||||
|
if (!Features.testFlag(CDockWidget::DockWidgetFloatable)
|
||||||
|
&& !(Features.testFlag(CDockWidget::DockWidgetMovable) && !CDockManager::testConfigFlag(CDockManager::OpaqueUndocking)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultOpaqueConfig;
|
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultNonOpaqueConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data class of CDockManager class (pimpl)
|
* Private data class of CDockManager class (pimpl)
|
||||||
|
@ -368,8 +368,13 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Floating is only allowed for widgets that are movable
|
|
||||||
if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
|
// Floating is only allowed for widgets that are floatable
|
||||||
|
// If we do non opaque undocking, then can create the drag preview
|
||||||
|
// if the widget is movable.
|
||||||
|
auto Features = d->DockWidget->features();
|
||||||
|
if (Features.testFlag(CDockWidget::DockWidgetFloatable)
|
||||||
|
|| (Features.testFlag(CDockWidget::DockWidgetMovable) && !CDockManager::testConfigFlag(CDockManager::OpaqueUndocking)))
|
||||||
{
|
{
|
||||||
// If we undock, we need to restore the initial position of this
|
// If we undock, we need to restore the initial position of this
|
||||||
// tab because it looks strange if it remains on its dragged position
|
// tab because it looks strange if it remains on its dragged position
|
||||||
|
@ -291,16 +291,23 @@ void CFloatingDragPreview::finishDragging()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(d->Content);
|
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(d->Content);
|
||||||
CFloatingDockContainer* FloatingWidget;
|
CFloatingDockContainer* FloatingWidget = nullptr;
|
||||||
if (DockWidget)
|
|
||||||
|
if (DockWidget && DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||||
{
|
{
|
||||||
FloatingWidget = new CFloatingDockContainer(DockWidget);
|
FloatingWidget = new CFloatingDockContainer(DockWidget);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(d->Content);
|
CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(d->Content);
|
||||||
|
if (DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||||
|
{
|
||||||
FloatingWidget = new CFloatingDockContainer(DockArea);
|
FloatingWidget = new CFloatingDockContainer(DockArea);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FloatingWidget)
|
||||||
|
{
|
||||||
FloatingWidget->setGeometry(this->geometry());
|
FloatingWidget->setGeometry(this->geometry());
|
||||||
FloatingWidget->show();
|
FloatingWidget->show();
|
||||||
if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame))
|
if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame))
|
||||||
@ -312,6 +319,7 @@ void CFloatingDragPreview::finishDragging()
|
|||||||
FloatingWidget->setGeometry(FixedGeometry);
|
FloatingWidget->setGeometry(FixedGeometry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->close();
|
this->close();
|
||||||
d->DockManager->containerOverlay()->hideOverlay();
|
d->DockManager->containerOverlay()->hideOverlay();
|
||||||
|
Loading…
Reference in New Issue
Block a user