Skip to content

Commit d10d59a

Browse files
Porperly moved title bar context menu code from DockAreaTabBar into DockAreaTitleBar
1 parent b61f509 commit d10d59a

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

src/DockAreaTitleBar.cpp

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,6 @@ void DockAreaTitleBarPrivate::createTabBar()
259259
_this->connect(TabBar, SIGNAL(currentChanged(int)), SLOT(onCurrentTabChanged(int)));
260260
_this->connect(TabBar, SIGNAL(tabBarClicked(int)), SIGNAL(tabBarClicked(int)));
261261
_this->connect(TabBar, SIGNAL(elidedChanged(bool)), SLOT(markTabsMenuOutdated()));
262-
263-
TabBar->setContextMenuPolicy(Qt::CustomContextMenu);
264-
_this->connect(TabBar, SIGNAL(customContextMenuRequested(const QPoint&)),
265-
SLOT(showContextMenu(const QPoint&)));
266262
}
267263

268264

@@ -519,25 +515,6 @@ void CDockAreaTitleBar::setVisible(bool Visible)
519515
}
520516

521517

522-
//============================================================================
523-
void CDockAreaTitleBar::showContextMenu(const QPoint& pos)
524-
{
525-
if (d->DragState == DraggingFloatingWidget)
526-
{
527-
return;
528-
}
529-
530-
QMenu Menu(this);
531-
auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked()));
532-
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
533-
Menu.addSeparator();
534-
Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked()));
535-
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
536-
Menu.addAction(tr("Close Other Areas"), d->DockArea, SLOT(closeOtherAreas()));
537-
Menu.exec(mapToGlobal(pos));
538-
}
539-
540-
541518
//============================================================================
542519
void CDockAreaTitleBar::mousePressEvent(QMouseEvent* ev)
543520
{
@@ -637,6 +614,26 @@ void CDockAreaTitleBar::mouseDoubleClickEvent(QMouseEvent *event)
637614
}
638615

639616

617+
//============================================================================
618+
void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
619+
{
620+
ev->accept();
621+
if (d->isDraggingState(DraggingFloatingWidget))
622+
{
623+
return;
624+
}
625+
626+
QMenu Menu(this);
627+
auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked()));
628+
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
629+
Menu.addSeparator();
630+
Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked()));
631+
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
632+
Menu.addAction(tr("Close Other Areas"), d->DockArea, SLOT(closeOtherAreas()));
633+
Menu.exec(ev->globalPos());
634+
}
635+
636+
640637
} // namespace ads
641638

642639
#include "DockAreaTitleBar.moc"

src/DockAreaTitleBar.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ private slots:
6060
void onUndockButtonClicked();
6161
void onTabsMenuActionTriggered(QAction* Action);
6262
void onCurrentTabChanged(int Index);
63-
void showContextMenu(const QPoint& pos);
6463

6564
protected:
6665
/**
@@ -84,6 +83,11 @@ private slots:
8483
*/
8584
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
8685

86+
/**
87+
* Show context menu
88+
*/
89+
virtual void contextMenuEvent(QContextMenuEvent *event);
90+
8791
public slots:
8892
/**
8993
* Call this slot to tell the title bar that it should update the tabs menu

0 commit comments

Comments
 (0)