Skip to content

Commit 39bc7f1

Browse files
Properly consider pinnable flag of dock widget when painting the drop overlays - no auto hide overlay for non pinnable dock widgets
1 parent 364ee33 commit 39bc7f1

File tree

3 files changed

+49
-17
lines changed

3 files changed

+49
-17
lines changed

src/DockOverlay.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,19 +472,23 @@ DockWidgetArea CDockOverlay::dropAreaUnderCursor() const
472472
{
473473
auto Rect = rect();
474474
const QPoint pos = mapFromGlobal(QCursor::pos());
475-
if (pos.x() < d->sideBarMouseZone(SideBarLeft))
475+
if ((pos.x() < d->sideBarMouseZone(SideBarLeft))
476+
&& d->AllowedAreas.testFlag(LeftAutoHideArea))
476477
{
477478
return LeftAutoHideArea;
478479
}
479-
else if (pos.x() > (Rect.width() - d->sideBarMouseZone(SideBarRight)))
480+
else if (pos.x() > (Rect.width() - d->sideBarMouseZone(SideBarRight))
481+
&& d->AllowedAreas.testFlag(RightAutoHideArea))
480482
{
481483
return RightAutoHideArea;
482484
}
483-
else if (pos.y() < d->sideBarMouseZone(SideBarTop))
485+
else if (pos.y() < d->sideBarMouseZone(SideBarTop)
486+
&& d->AllowedAreas.testFlag(TopAutoHideArea))
484487
{
485488
return TopAutoHideArea;
486489
}
487-
else if (pos.y() > (Rect.height() - d->sideBarMouseZone(SideBarBottom)))
490+
else if (pos.y() > (Rect.height() - d->sideBarMouseZone(SideBarBottom))
491+
&& d->AllowedAreas.testFlag(BottomAutoHideArea))
488492
{
489493
return BottomAutoHideArea;
490494
}

src/FloatingDockContainer.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,22 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint &GlobalPos)
590590
}
591591

592592
int VisibleDockAreas = TopContainer->visibleDockAreaCount();
593-
DockWidgetAreas AllowedAreas = (VisibleDockAreas > 1) ? OuterDockAreas : AllDockAreas;
593+
DockWidgetAreas AllowedContainerAreas = (VisibleDockAreas > 1) ? OuterDockAreas : AllDockAreas;
594594
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
595595
// If the dock container contains only one single DockArea, then we need
596596
// to respect the allowed areas - only the center area is relevant here because
597597
// all other allowed areas are from the container
598598
if (VisibleDockAreas == 1 && DockArea)
599599
{
600-
AllowedAreas.setFlag(CenterDockWidgetArea, DockArea->allowedAreas().testFlag(CenterDockWidgetArea));
600+
AllowedContainerAreas.setFlag(CenterDockWidgetArea, DockArea->allowedAreas().testFlag(CenterDockWidgetArea));
601601
}
602-
ContainerOverlay->setAllowedAreas(AllowedAreas);
602+
603+
if (DockContainer->features().testFlag(CDockWidget::DockWidgetPinnable))
604+
{
605+
AllowedContainerAreas |= AutoHideDockAreas;
606+
}
607+
608+
ContainerOverlay->setAllowedAreas(AllowedContainerAreas);
603609

604610
DockWidgetArea ContainerArea = ContainerOverlay->showOverlay(TopContainer);
605611
ContainerOverlay->enableDropPreview(ContainerArea != InvalidDockWidgetArea);

src/FloatingDragPreview.cpp

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct FloatingDragPreviewPrivate
3535
{
3636
CFloatingDragPreview *_this;
3737
QWidget* Content;
38+
CDockWidget::DockWidgetFeatures ContentFeatures;
3839
CDockAreaWidget* ContentSourceArea = nullptr;
3940
QPoint DragStartMousePosition;
4041
CDockManager* DockManager;
@@ -79,20 +80,36 @@ struct FloatingDragPreviewPrivate
7980
* Returns true, if the content is floatable
8081
*/
8182
bool isContentFloatable() const
83+
{
84+
return this->ContentFeatures.testFlag(CDockWidget::DockWidgetFloatable);
85+
}
86+
87+
/**
88+
* Returns true, if the content is pinnable
89+
*/
90+
bool isContentPinnable() const
91+
{
92+
return this->ContentFeatures.testFlag(CDockWidget::DockWidgetPinnable);
93+
}
94+
95+
/**
96+
* Returns the content features
97+
*/
98+
CDockWidget::DockWidgetFeatures contentFeatures() const
8299
{
83100
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(Content);
84-
if (DockWidget && DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
101+
if (DockWidget)
85102
{
86-
return true;
103+
return DockWidget->features();
87104
}
88105

89106
CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(Content);
90-
if (DockArea && DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
107+
if (DockArea)
91108
{
92-
return true;
109+
return DockArea->features();
93110
}
94111

95-
return false;
112+
return CDockWidget::DockWidgetFeatures();
96113
}
97114
};
98115
// struct LedArrayPanelPrivate
@@ -152,17 +169,22 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
152169
VisibleDockAreas++;
153170
}
154171

155-
DockWidgetAreas AllowedAreas = (VisibleDockAreas > 1) ? OuterDockAreas : AllDockAreas;
172+
DockWidgetAreas AllowedContainerAreas = (VisibleDockAreas > 1) ? OuterDockAreas : AllDockAreas;
156173
//ContainerOverlay->enableDropPreview(ContainerDropArea != InvalidDockWidgetArea);
157174
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
158175
// If the dock container contains only one single DockArea, then we need
159176
// to respect the allowed areas - only the center area is relevant here because
160177
// all other allowed areas are from the container
161178
if (VisibleDockAreas == 1 && DockArea)
162179
{
163-
AllowedAreas.setFlag(CenterDockWidgetArea, DockArea->allowedAreas().testFlag(CenterDockWidgetArea));
180+
AllowedContainerAreas.setFlag(CenterDockWidgetArea, DockArea->allowedAreas().testFlag(CenterDockWidgetArea));
164181
}
165-
ContainerOverlay->setAllowedAreas(AllowedAreas);
182+
183+
if (isContentPinnable())
184+
{
185+
AllowedContainerAreas |= AutoHideDockAreas;
186+
}
187+
ContainerOverlay->setAllowedAreas(AllowedContainerAreas);
166188
ContainerOverlay->enableDropPreview(ContainerDropArea != InvalidDockWidgetArea);
167189
if (DockArea && DockArea->isVisible() && VisibleDockAreas >= 0 && DockArea != ContentSourceArea)
168190
{
@@ -259,6 +281,7 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
259281
d(new FloatingDragPreviewPrivate(this))
260282
{
261283
d->Content = Content;
284+
d->ContentFeatures = d->contentFeatures();
262285
setAttribute(Qt::WA_DeleteOnClose);
263286
if (CDockManager::testConfigFlag(CDockManager::DragPreviewHasWindowFrame))
264287
{
@@ -278,8 +301,6 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
278301
setWindowFlags(Flags);
279302
#endif
280303

281-
setWindowOpacity(0.6);
282-
283304
// Create a static image of the widget that should get undocked
284305
// This is like some kind preview image like it is uses in drag and drop
285306
// operations
@@ -437,6 +458,7 @@ void CFloatingDragPreview::paintEvent(QPaintEvent* event)
437458
}
438459

439460
QPainter painter(this);
461+
painter.setOpacity(0.6);
440462
if (CDockManager::testConfigFlag(CDockManager::DragPreviewShowsContentPixmap))
441463
{
442464
painter.drawPixmap(QPoint(0, 0), d->ContentPreviewPixmap);

0 commit comments

Comments
 (0)