From 12c92637fc8eab9688b234a045a8d342ce3e4862 Mon Sep 17 00:00:00 2001 From: Pier-Yves Lessard Date: Thu, 1 May 2025 12:39:14 -0400 Subject: [PATCH 1/3] Add a perDockWidget ContextMenu hook --- src/AutoHideTab.cpp | 5 +++++ src/DockWidget.cpp | 8 ++++++++ src/DockWidget.h | 7 +++++++ src/DockWidgetTab.cpp | 5 +++++ 4 files changed, 25 insertions(+) diff --git a/src/AutoHideTab.cpp b/src/AutoHideTab.cpp index 66d1277d7..0049ce369 100644 --- a/src/AutoHideTab.cpp +++ b/src/AutoHideTab.cpp @@ -408,6 +408,11 @@ void CAutoHideTab::contextMenuEvent(QContextMenuEvent* ev) Action = Menu.addAction(tr("Close"), this, SLOT(requestCloseDockWidget())); Action->setEnabled(d->DockWidget->features().testFlag(CDockWidget::DockWidgetClosable)); + if (d->DockWidget) + { + d->DockWidget->ExtendContextMenu(&Menu); + } + Menu.exec(ev->globalPos()); } diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index b4e0bb133..6dcad9244 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -1368,6 +1368,14 @@ CDockWidget::eToolBarStyleSource CDockWidget::toolBarStyleSource() const } +//============================================================================ +void CDockWidget::ExtendContextMenu(QMenu* Menu) const +{ + ADS_PRINT("ExtendContextMenu(): " << this->windowTitle()); + Q_UNUSED(Menu); +} + + } // namespace ads //--------------------------------------------------------------------------- diff --git a/src/DockWidget.h b/src/DockWidget.h index 04d10f8b9..4e86bf62a 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -569,6 +569,13 @@ private Q_SLOTS: */ virtual QList titleBarActions() const; + /** + * Hook called after creating the dock widget context menu from a tab or autohide side tab. + * Called before being shown to the user. Allow custom extensions of the menu. + * Initially introduced to permit the "Rename" feature + */ + virtual void ExtendContextMenu(QMenu* Menu) const; + #ifndef QT_NO_TOOLTIP /** diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index bb1bd930f..167eab6e7 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -573,6 +573,11 @@ QMenu* CDockWidgetTab::buildContextMenu(QMenu *Menu) Action = Menu->addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested())); } + if (d->DockWidget) + { + d->DockWidget->ExtendContextMenu(Menu); + } + return Menu; } //============================================================================ From a2f6f455777737527e34d47c26e25f2aebe1c117 Mon Sep 17 00:00:00 2001 From: Pier-Yves Lessard Date: Thu, 1 May 2025 12:50:21 -0400 Subject: [PATCH 2/3] Fix CI failure --- src/DockWidget.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DockWidget.h b/src/DockWidget.h index 4e86bf62a..28d976636 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -31,6 +31,7 @@ // INCLUDES //============================================================================ #include +#include #include "ads_globals.h" From 9f27f06fd86d5df287ac22e4626134b8d609bb86 Mon Sep 17 00:00:00 2001 From: Pier-Yves Lessard Date: Thu, 1 May 2025 18:07:20 -0400 Subject: [PATCH 3/3] lowercase first letter --- src/AutoHideTab.cpp | 2 +- src/DockWidget.cpp | 4 ++-- src/DockWidget.h | 2 +- src/DockWidgetTab.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AutoHideTab.cpp b/src/AutoHideTab.cpp index 0049ce369..00f273206 100644 --- a/src/AutoHideTab.cpp +++ b/src/AutoHideTab.cpp @@ -410,7 +410,7 @@ void CAutoHideTab::contextMenuEvent(QContextMenuEvent* ev) if (d->DockWidget) { - d->DockWidget->ExtendContextMenu(&Menu); + d->DockWidget->extendContextMenu(&Menu); } Menu.exec(ev->globalPos()); diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 6dcad9244..55d5be285 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -1369,9 +1369,9 @@ CDockWidget::eToolBarStyleSource CDockWidget::toolBarStyleSource() const //============================================================================ -void CDockWidget::ExtendContextMenu(QMenu* Menu) const +void CDockWidget::extendContextMenu(QMenu* Menu) const { - ADS_PRINT("ExtendContextMenu(): " << this->windowTitle()); + ADS_PRINT("extendContextMenu(): " << this->windowTitle()); Q_UNUSED(Menu); } diff --git a/src/DockWidget.h b/src/DockWidget.h index 28d976636..2b0283693 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -575,7 +575,7 @@ private Q_SLOTS: * Called before being shown to the user. Allow custom extensions of the menu. * Initially introduced to permit the "Rename" feature */ - virtual void ExtendContextMenu(QMenu* Menu) const; + virtual void extendContextMenu(QMenu* Menu) const; #ifndef QT_NO_TOOLTIP diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index 167eab6e7..6eebfe072 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -575,7 +575,7 @@ QMenu* CDockWidgetTab::buildContextMenu(QMenu *Menu) if (d->DockWidget) { - d->DockWidget->ExtendContextMenu(Menu); + d->DockWidget->extendContextMenu(Menu); } return Menu;