diff widgets/PropertyStack.cpp @ 1582:01a41a37bd26

Add a tab-bar context menu signal to the property stack
author Chris Cannam
date Wed, 25 Mar 2020 12:08:34 +0000
parents 284a38c43721
children
line wrap: on
line diff
--- a/widgets/PropertyStack.cpp	Fri Jan 24 15:11:08 2020 +0000
+++ b/widgets/PropertyStack.cpp	Wed Mar 25 12:08:34 2020 +0000
@@ -45,6 +45,10 @@
     connect(bar, SIGNAL(mouseLeft()), this, SLOT(mouseLeftTabBar()));
     connect(bar, SIGNAL(activeTabClicked()), this, SLOT(activeTabClicked()));
 
+    bar->setContextMenuPolicy(Qt::CustomContextMenu);
+    connect(bar, SIGNAL(customContextMenuRequested(const QPoint &)),
+            this, SLOT(tabBarContextMenuRequested(const QPoint &)));
+    
     setTabBar(bar);
 
     setElideMode(Qt::ElideNone); 
@@ -164,6 +168,19 @@
     blockSignals(false);
 }
 
+void
+PropertyStack::tabBarContextMenuRequested(const QPoint &pos)
+{
+    int tab = tabBar()->tabAt(pos);
+    if (!in_range_for(m_boxes, tab)) {
+        return;
+    }
+
+    emit propertyContainerContextMenuRequested(m_client,
+                                               m_boxes[tab]->getContainer(),
+                                               mapToGlobal(pos));
+}
+
 bool
 PropertyStack::containsContainer(PropertyContainer *pc) const
 {