setAllowedAreas for individual DockAreaWidget (#107)

* setAllowedAreas for individual DockAreaWidget

* alligning tab policy with master
This commit is contained in:
mvidelgauz 2020-02-02 16:56:31 +02:00 committed by GitHub
parent 9fe8f291fb
commit 6c3f82547d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 6 deletions

View File

@ -276,7 +276,14 @@ void MainWindowPrivate::createContent()
QMenu* ViewMenu = ui.menuView; QMenu* ViewMenu = ui.menuView;
auto DockWidget = createCalendarDockWidget(ViewMenu); auto DockWidget = createCalendarDockWidget(ViewMenu);
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false); DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget); auto SpecialDockArea = DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
// For this Special Dock Area we want to avoid dropping on the center of it (i.e. we don't want this widget to be ever tabbified):
{
SpecialDockArea->setAllowedAreas(ads::OuterDockAreas);
//SpecialDockArea->setAllowedAreas({ads::LeftDockWidgetArea, ads::RightDockWidgetArea}); // just for testing
}
DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu)); DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu));
auto FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu); auto FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
auto ToolBar = FileSystemWidget->createDefaultToolBar(); auto ToolBar = FileSystemWidget->createDefaultToolBar();

View File

@ -245,6 +245,7 @@ struct DockAreaWidgetPrivate
CDockAreaTitleBar* TitleBar = nullptr; CDockAreaTitleBar* TitleBar = nullptr;
CDockManager* DockManager = nullptr; CDockManager* DockManager = nullptr;
bool UpdateTitleBarButtons = false; bool UpdateTitleBarButtons = false;
DockWidgetAreas AllowedAreas = AllDockAreas;
/** /**
* Private data constructor * Private data constructor
@ -812,6 +813,15 @@ void CDockAreaWidget::setVisible(bool Visible)
} }
} }
void CDockAreaWidget::setAllowedAreas(DockWidgetAreas areas)
{
d->AllowedAreas = areas;
}
DockWidgetAreas CDockAreaWidget::allowedAreas() const
{
return d->AllowedAreas;
}
//============================================================================ //============================================================================
QAbstractButton* CDockAreaWidget::titleBarButton(TitleBarButton which) const QAbstractButton* CDockAreaWidget::titleBarButton(TitleBarButton which) const

View File

@ -254,6 +254,16 @@ public:
*/ */
virtual void setVisible(bool Visible) override; virtual void setVisible(bool Visible) override;
/**
* Configures the areas of this particular dock area that are allowed for docking
*/
void setAllowedAreas(DockWidgetAreas areas);
/**
* Returns flags with all allowed drop areas of this particular dock area
*/
DockWidgetAreas allowedAreas() const;
public slots: public slots:
/** /**
* This activates the tab for the given tab index. * This activates the tab for the given tab index.

View File

@ -334,7 +334,7 @@ eDropMode DockContainerWidgetPrivate::getDropMode(const QPoint& TargetPos)
if (DockArea) if (DockArea)
{ {
auto dropOverlay = DockManager->dockAreaOverlay(); auto dropOverlay = DockManager->dockAreaOverlay();
dropOverlay->setAllowedAreas(AllDockAreas); dropOverlay->setAllowedAreas(DockArea->allowedAreas());
dropArea = dropOverlay->showOverlay(DockArea); dropArea = dropOverlay->showOverlay(DockArea);
if (ContainerDropArea != InvalidDockWidgetArea && if (ContainerDropArea != InvalidDockWidgetArea &&
ContainerDropArea != dropArea) ContainerDropArea != dropArea)
@ -1392,7 +1392,7 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
if (DockArea) if (DockArea)
{ {
auto dropOverlay = d->DockManager->dockAreaOverlay(); auto dropOverlay = d->DockManager->dockAreaOverlay();
dropOverlay->setAllowedAreas(AllDockAreas); dropOverlay->setAllowedAreas(DockArea->allowedAreas());
dropArea = dropOverlay->showOverlay(DockArea); dropArea = dropOverlay->showOverlay(DockArea);
if (ContainerDropArea != InvalidDockWidgetArea && if (ContainerDropArea != InvalidDockWidgetArea &&
ContainerDropArea != dropArea) ContainerDropArea != dropArea)
@ -1447,7 +1447,7 @@ void CDockContainerWidget::dropWidget(QWidget* Widget, const QPoint& TargetPos)
if (DockArea) if (DockArea)
{ {
auto dropOverlay = d->DockManager->dockAreaOverlay(); auto dropOverlay = d->DockManager->dockAreaOverlay();
dropOverlay->setAllowedAreas(AllDockAreas); dropOverlay->setAllowedAreas(DockArea->allowedAreas());
dropArea = dropOverlay->showOverlay(DockArea); dropArea = dropOverlay->showOverlay(DockArea);
if (ContainerDropArea != InvalidDockWidgetArea && if (ContainerDropArea != InvalidDockWidgetArea &&
ContainerDropArea != dropArea) ContainerDropArea != dropArea)

View File

@ -207,7 +207,7 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint &GlobalPos)
{ {
DockAreaOverlay->enableDropPreview(true); DockAreaOverlay->enableDropPreview(true);
DockAreaOverlay->setAllowedAreas( DockAreaOverlay->setAllowedAreas(
(VisibleDockAreas == 1) ? NoDockWidgetArea : AllDockAreas); (VisibleDockAreas == 1) ? NoDockWidgetArea : DockArea->allowedAreas());
DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea); DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea);
// A CenterDockWidgetArea for the dockAreaOverlay() indicates that // A CenterDockWidgetArea for the dockAreaOverlay() indicates that

View File

@ -127,7 +127,7 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
{ {
DockAreaOverlay->enableDropPreview(true); DockAreaOverlay->enableDropPreview(true);
DockAreaOverlay->setAllowedAreas( DockAreaOverlay->setAllowedAreas(
(VisibleDockAreas == 1) ? NoDockWidgetArea : AllDockAreas); (VisibleDockAreas == 1) ? NoDockWidgetArea : DockArea->allowedAreas());
DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea); DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea);
// A CenterDockWidgetArea for the dockAreaOverlay() indicates that // A CenterDockWidgetArea for the dockAreaOverlay() indicates that