Skip to content

Commit 2af4b1f

Browse files
Blocked display of context menu when dragging floating widget
1 parent c0cde1e commit 2af4b1f

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

src/DockAreaTabBar.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void CDockAreaTabBar::mousePressEvent(QMouseEvent* ev)
173173
d->DragState = DraggingMousePressed;
174174
return;
175175
}
176-
QScrollArea::mousePressEvent(ev);
176+
Super::mousePressEvent(ev);
177177
}
178178

179179

@@ -193,14 +193,14 @@ void CDockAreaTabBar::mouseReleaseEvent(QMouseEvent* ev)
193193
}
194194
return;
195195
}
196-
QScrollArea::mouseReleaseEvent(ev);
196+
Super::mouseReleaseEvent(ev);
197197
}
198198

199199

200200
//============================================================================
201201
void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
202202
{
203-
QScrollArea::mouseMoveEvent(ev);
203+
Super::mouseMoveEvent(ev);
204204
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
205205
{
206206
d->DragState = DraggingInactive;
@@ -618,6 +618,7 @@ QSize CDockAreaTabBar::minimumSizeHint() const
618618
return Size;
619619
}
620620

621+
621622
//===========================================================================
622623
QSize CDockAreaTabBar::sizeHint() const
623624
{
@@ -626,6 +627,13 @@ QSize CDockAreaTabBar::sizeHint() const
626627
return Size;
627628
}
628629

630+
631+
//===========================================================================
632+
eDragState CDockAreaTabBar::dragState() const
633+
{
634+
return d->DragState;
635+
}
636+
629637
} // namespace ads
630638

631639
//---------------------------------------------------------------------------

src/DockAreaTabBar.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ private slots:
9898
*/
9999
IFloatingWidget* makeAreaFloating(const QPoint& Offset, eDragState DragState);
100100

101+
/**
102+
* Returns the current drag state
103+
*/
104+
eDragState dragState() const;
105+
101106

102107
public:
103108
using Super = QScrollArea;

src/DockAreaTitleBar.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,11 @@ void CDockAreaTitleBar::setVisible(bool Visible)
364364
//============================================================================
365365
void CDockAreaTitleBar::showContextMenu(const QPoint& pos)
366366
{
367+
if (d->TabBar->dragState() == DraggingFloatingWidget)
368+
{
369+
return;
370+
}
371+
367372
QMenu Menu(this);
368373
auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked()));
369374
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));

src/DockWidgetTab.cpp

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -317,26 +317,29 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
317317
//============================================================================
318318
void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
319319
{
320-
auto CurrentDragState = d->DragState;
321-
d->DragStartMousePosition = QPoint();
322-
d->DragState = DraggingInactive;
320+
if (ev->button() == Qt::LeftButton)
321+
{
322+
auto CurrentDragState = d->DragState;
323+
d->DragStartMousePosition = QPoint();
324+
d->DragState = DraggingInactive;
323325

324-
switch (CurrentDragState)
325-
{
326-
case DraggingTab:
327-
// End of tab moving, emit signal
328-
if (d->DockArea)
326+
switch (CurrentDragState)
329327
{
330-
emit moved(ev->globalPos());
331-
}
332-
break;
328+
case DraggingTab:
329+
// End of tab moving, emit signal
330+
if (d->DockArea)
331+
{
332+
emit moved(ev->globalPos());
333+
}
334+
break;
333335

334-
case DraggingFloatingWidget:
335-
d->FloatingWidget->finishDragging();
336-
break;
336+
case DraggingFloatingWidget:
337+
d->FloatingWidget->finishDragging();
338+
break;
337339

338-
default:; // do nothing
339-
}
340+
default:; // do nothing
341+
}
342+
}
340343

341344
Super::mouseReleaseEvent(ev);
342345
}
@@ -416,6 +419,10 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
416419
void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
417420
{
418421
ev->accept();
422+
if (d->isDraggingState(DraggingFloatingWidget))
423+
{
424+
return;
425+
}
419426

420427
d->DragStartMousePosition = ev->pos();
421428
QMenu Menu(this);

0 commit comments

Comments
 (0)