diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 7d48aba..2af7860 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -259,10 +259,6 @@ void DockAreaTitleBarPrivate::createTabBar() _this->connect(TabBar, SIGNAL(currentChanged(int)), SLOT(onCurrentTabChanged(int))); _this->connect(TabBar, SIGNAL(tabBarClicked(int)), SIGNAL(tabBarClicked(int))); _this->connect(TabBar, SIGNAL(elidedChanged(bool)), SLOT(markTabsMenuOutdated())); - - TabBar->setContextMenuPolicy(Qt::CustomContextMenu); - _this->connect(TabBar, SIGNAL(customContextMenuRequested(const QPoint&)), - SLOT(showContextMenu(const QPoint&))); } @@ -519,25 +515,6 @@ void CDockAreaTitleBar::setVisible(bool Visible) } -//============================================================================ -void CDockAreaTitleBar::showContextMenu(const QPoint& pos) -{ - if (d->DragState == DraggingFloatingWidget) - { - return; - } - - QMenu Menu(this); - auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked())); - Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable)); - Menu.addSeparator(); - Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked())); - Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable)); - Menu.addAction(tr("Close Other Areas"), d->DockArea, SLOT(closeOtherAreas())); - Menu.exec(mapToGlobal(pos)); -} - - //============================================================================ void CDockAreaTitleBar::mousePressEvent(QMouseEvent* ev) { @@ -637,6 +614,26 @@ void CDockAreaTitleBar::mouseDoubleClickEvent(QMouseEvent *event) } +//============================================================================ +void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev) +{ + ev->accept(); + if (d->isDraggingState(DraggingFloatingWidget)) + { + return; + } + + QMenu Menu(this); + auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked())); + Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable)); + Menu.addSeparator(); + Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked())); + Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable)); + Menu.addAction(tr("Close Other Areas"), d->DockArea, SLOT(closeOtherAreas())); + Menu.exec(ev->globalPos()); +} + + } // namespace ads #include "DockAreaTitleBar.moc" diff --git a/src/DockAreaTitleBar.h b/src/DockAreaTitleBar.h index b77d139..7bd09ef 100644 --- a/src/DockAreaTitleBar.h +++ b/src/DockAreaTitleBar.h @@ -60,7 +60,6 @@ private slots: void onUndockButtonClicked(); void onTabsMenuActionTriggered(QAction* Action); void onCurrentTabChanged(int Index); - void showContextMenu(const QPoint& pos); protected: /** @@ -84,6 +83,11 @@ protected: */ virtual void mouseDoubleClickEvent(QMouseEvent *event) override; + /** + * Show context menu + */ + virtual void contextMenuEvent(QContextMenuEvent *event); + public slots: /** * Call this slot to tell the title bar that it should update the tabs menu