Mercurial > hg > svgui
changeset 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 | a2ff9c01889e |
children | 2e720fdcab0a |
files | view/PaneStack.cpp view/PaneStack.h widgets/PropertyStack.cpp widgets/PropertyStack.h |
diffstat | 4 files changed, 46 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/view/PaneStack.cpp Fri Jan 24 15:11:08 2020 +0000 +++ b/view/PaneStack.cpp Wed Mar 25 12:08:34 2020 +0000 @@ -146,6 +146,8 @@ properties = new PropertyStack(frame, pane); connect(properties, SIGNAL(propertyContainerSelected(View *, PropertyContainer *)), this, SLOT(propertyContainerSelected(View *, PropertyContainer *))); + connect(properties, SIGNAL(propertyContainerContextMenuRequested(View *, PropertyContainer *, QPoint)), + this, SLOT(propertyContainerContextMenuRequested(View *, PropertyContainer *, QPoint))); connect(properties, SIGNAL(viewSelected(View *)), this, SLOT(viewSelected(View *))); connect(properties, SIGNAL(contextHelpChanged(const QString &)), @@ -588,6 +590,23 @@ } void +PaneStack::propertyContainerContextMenuRequested(View *client, + PropertyContainer *pc, + QPoint pos) +{ + Pane *pane = dynamic_cast<Pane *>(client); + Layer *layer = dynamic_cast<Layer *>(pc); + + if (pane) { + if (layer) { + emit layerPropertiesRightButtonMenuRequested(pane, layer, pos); + } else { + emit panePropertiesRightButtonMenuRequested(pane, pos); + } + } +} + +void PaneStack::viewSelected(View *v) { Pane *p = dynamic_cast<Pane *>(v); @@ -607,7 +626,7 @@ { Pane *pane = dynamic_cast<Pane *>(sender()); if (!pane) return; - emit rightButtonMenuRequested(pane, position); + emit paneRightButtonMenuRequested(pane, position); } void
--- a/view/PaneStack.h Fri Jan 24 15:11:08 2020 +0000 +++ b/view/PaneStack.h Wed Mar 25 12:08:34 2020 +0000 @@ -92,7 +92,9 @@ signals: void currentPaneChanged(Pane *pane); void currentLayerChanged(Pane *pane, Layer *layer); - void rightButtonMenuRequested(Pane *pane, QPoint position); + void paneRightButtonMenuRequested(Pane *pane, QPoint position); + void panePropertiesRightButtonMenuRequested(Pane *, QPoint); + void layerPropertiesRightButtonMenuRequested(Pane *, Layer *, QPoint); void propertyStacksResized(int width); void propertyStacksResized(); void contextHelpChanged(const QString &); @@ -115,6 +117,8 @@ void propertyContainerAdded(PropertyContainer *); void propertyContainerRemoved(PropertyContainer *); void propertyContainerSelected(View *client, PropertyContainer *); + void propertyContainerContextMenuRequested(View *, PropertyContainer *, + QPoint); void viewSelected(View *v); void paneInteractedWith(); void rightButtonMenuRequested(QPoint);
--- 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 {
--- a/widgets/PropertyStack.h Fri Jan 24 15:11:08 2020 +0000 +++ b/widgets/PropertyStack.h Wed Mar 25 12:08:34 2020 +0000 @@ -40,6 +40,9 @@ signals: void viewSelected(View *client); void propertyContainerSelected(View *client, PropertyContainer *container); + void propertyContainerContextMenuRequested(View *client, + PropertyContainer *container, + QPoint pos); void contextHelpChanged(const QString &); public slots: @@ -54,6 +57,7 @@ void mouseEnteredTabBar(); void mouseLeftTabBar(); void activeTabClicked(); + void tabBarContextMenuRequested(const QPoint &); protected slots: void selectedContainerChanged(int);