mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 23:31:32 +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();
|
||||
ToolBar->addAction(ui.actionSaveState);
|
||||
ToolBar->addAction(ui.actionRestoreState);
|
||||
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
|
||||
appendFeaturStringToWindowTitle(FileSystemWidget);
|
||||
DockManager->addDockWidget(ads::BottomDockWidgetArea, FileSystemWidget);
|
||||
|
||||
FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
|
||||
@ -484,9 +486,9 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
// a QToolButton instead of a QPushButton
|
||||
// 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
|
||||
CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
|
||||
// CDockManager::setConfigFlags(CDockManager::DefaultOpaqueConfig);
|
||||
|
||||
// uncomment the following line if you want a fixed tab width that does
|
||||
// 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
|
||||
// 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;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@
|
||||
|
||||
namespace ads
|
||||
{
|
||||
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultOpaqueConfig;
|
||||
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultNonOpaqueConfig;
|
||||
|
||||
/**
|
||||
* Private data class of CDockManager class (pimpl)
|
||||
|
@ -368,8 +368,13 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
||||
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
|
||||
// tab because it looks strange if it remains on its dragged position
|
||||
|
@ -291,25 +291,33 @@ void CFloatingDragPreview::finishDragging()
|
||||
else
|
||||
{
|
||||
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(d->Content);
|
||||
CFloatingDockContainer* FloatingWidget;
|
||||
if (DockWidget)
|
||||
CFloatingDockContainer* FloatingWidget = nullptr;
|
||||
|
||||
if (DockWidget && DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||
{
|
||||
FloatingWidget = new CFloatingDockContainer(DockWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(d->Content);
|
||||
FloatingWidget = new CFloatingDockContainer(DockArea);
|
||||
if (DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||
{
|
||||
FloatingWidget = new CFloatingDockContainer(DockArea);
|
||||
}
|
||||
}
|
||||
FloatingWidget->setGeometry(this->geometry());
|
||||
FloatingWidget->show();
|
||||
if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame))
|
||||
|
||||
if (FloatingWidget)
|
||||
{
|
||||
QApplication::processEvents();
|
||||
int FrameHeight = FloatingWidget->frameGeometry().height() - FloatingWidget->geometry().height();
|
||||
QRect FixedGeometry = this->geometry();
|
||||
FixedGeometry.adjust(0, FrameHeight, 0, 0);
|
||||
FloatingWidget->setGeometry(FixedGeometry);
|
||||
FloatingWidget->setGeometry(this->geometry());
|
||||
FloatingWidget->show();
|
||||
if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame))
|
||||
{
|
||||
QApplication::processEvents();
|
||||
int FrameHeight = FloatingWidget->frameGeometry().height() - FloatingWidget->geometry().height();
|
||||
QRect FixedGeometry = this->geometry();
|
||||
FixedGeometry.adjust(0, FrameHeight, 0, 0);
|
||||
FloatingWidget->setGeometry(FixedGeometry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user