changeset 2475:169cc70492bb

Implement pane and layer property tab context menus. Some layout work needed
author Chris Cannam
date Wed, 25 Mar 2020 12:10:48 +0000
parents de62cf88806b
children 6a46b1d4f0cd
files main/MainWindow.cpp main/MainWindow.h repoint-lock.json
diffstat 3 files changed, 100 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/main/MainWindow.cpp	Mon Mar 16 08:48:24 2020 +0000
+++ b/main/MainWindow.cpp	Wed Mar 25 12:10:48 2020 +0000
@@ -126,6 +126,7 @@
 #include <QDialogButtonBox>
 #include <QFileSystemWatcher>
 #include <QTextEdit>
+#include <QWidgetAction>
 
 #include <iostream>
 #include <cstdio>
@@ -153,6 +154,7 @@
     m_rightButtonLayerMenu(nullptr),
     m_rightButtonTransformsMenu(nullptr),
     m_rightButtonPlaybackMenu(nullptr),
+    m_lastRightButtonPropertyMenu(nullptr),
     m_soloAction(nullptr),
     m_rwdStartAction(nullptr),
     m_rwdSimilarAction(nullptr),
@@ -5050,14 +5052,103 @@
 }
 
 void
-MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
+MainWindow::paneRightButtonMenuRequested(Pane *pane, QPoint position)
 {
-//    SVDEBUG << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << endl;
     m_paneStack->setCurrentPane(pane);
     m_rightButtonMenu->popup(position);
 }
 
 void
+MainWindow::panePropertiesRightButtonMenuRequested(Pane *pane, QPoint position)
+{
+    if (m_lastRightButtonPropertyMenu) {
+        delete m_lastRightButtonPropertyMenu;
+    }
+
+    m_paneStack->setCurrentLayer(pane, nullptr);
+    
+    QMenu *m = new QMenu;
+    IconLoader il;
+
+    QWidgetAction *wa = new QWidgetAction(m);
+    QLabel *title = new QLabel;
+    title->setText(tr("<b>Pane</b>"));
+    title->setMargin(m_viewManager->scalePixelSize(2));
+    title->setIndent(m_viewManager->scalePixelSize(12));
+    wa->setDefaultWidget(title);
+    m->addAction(wa);
+
+    m->addSeparator();
+
+    // We repeat the setCurrentLayer call here just in case some
+    // unexpected UI interaction (scripting?) changes it while the
+    // menu is visible
+    
+    m->addAction(il.load("editdelete"),
+                 tr("&Delete Pane"),
+                 [=]() {
+                     m_paneStack->setCurrentLayer(pane, nullptr);
+                     deleteCurrentPane();
+                 });
+
+    m->popup(position);
+    m_lastRightButtonPropertyMenu = m;
+}
+
+void
+MainWindow::layerPropertiesRightButtonMenuRequested(Pane *pane, Layer *layer, QPoint position)
+{
+    if (m_lastRightButtonPropertyMenu) {
+        delete m_lastRightButtonPropertyMenu;
+    }
+
+    m_paneStack->setCurrentLayer(pane, layer);
+    
+    QMenu *m = new QMenu;
+    IconLoader il;
+
+    QWidgetAction *wa = new QWidgetAction(m);
+    QLabel *title = new QLabel;
+    title->setText
+        (tr("<b>%2</b>")
+         .arg(XmlExportable::encodeEntities
+              (layer->getLayerPresentationName())));
+    title->setMargin(m_viewManager->scalePixelSize(2));
+    title->setIndent(m_viewManager->scalePixelSize(12));
+    wa->setDefaultWidget(title);
+    m->addAction(wa);
+    
+    m->addSeparator();
+
+    // We repeat the setCurrentLayer calls here just in case some
+    // unexpected UI interaction (scripting?) changes it while the
+    // menu is visible
+    
+    m->addAction(tr("&Rename Layer..."),
+                 [=]() {
+                     m_paneStack->setCurrentLayer(pane, layer);
+                     renameCurrentLayer();
+                 });
+
+    m->addAction(tr("Edit Layer Data"),
+                 [=]() {
+                     m_paneStack->setCurrentLayer(pane, layer);
+                     editCurrentLayer();
+                 })
+        ->setEnabled(layer->isLayerEditable());
+    
+    m->addAction(il.load("editdelete"),
+                 tr("&Delete Layer"),
+                 [=]() {
+                     m_paneStack->setCurrentLayer(pane, layer);
+                     deleteCurrentLayer();
+                 });
+
+    m->popup(position);
+    m_lastRightButtonPropertyMenu = m;
+}
+
+void
 MainWindow::showLayerTree()
 {
     if (!m_layerTreeDialog.isNull()) {
--- a/main/MainWindow.h	Mon Mar 16 08:48:24 2020 +0000
+++ b/main/MainWindow.h	Wed Mar 25 12:10:48 2020 +0000
@@ -101,7 +101,9 @@
     void modelRegenerationWarning(QString, QString, QString) override;
     void alignmentFailed(QString) override;
 
-    void rightButtonMenuRequested(Pane *, QPoint point) override;
+    void paneRightButtonMenuRequested(Pane *, QPoint point) override;
+    void panePropertiesRightButtonMenuRequested(Pane *, QPoint point) override;
+    void layerPropertiesRightButtonMenuRequested(Pane *, Layer *, QPoint point) override;
 
     virtual void propertyStacksResized(int);
 
@@ -190,6 +192,7 @@
     QMenu                   *m_rightButtonLayerMenu;
     QMenu                   *m_rightButtonTransformsMenu;
     QMenu                   *m_rightButtonPlaybackMenu;
+    QMenu                   *m_lastRightButtonPropertyMenu;
 
     QAction                 *m_deleteSelectedAction;
     QAction                 *m_soloAction;
--- a/repoint-lock.json	Mon Mar 16 08:48:24 2020 +0000
+++ b/repoint-lock.json	Wed Mar 25 12:10:48 2020 +0000
@@ -7,10 +7,10 @@
       "pin": "a4dce53b3353"
     },
     "svgui": {
-      "pin": "a2ff9c01889e"
+      "pin": "01a41a37bd26"
     },
     "svapp": {
-      "pin": "497d80d3b9c4"
+      "pin": "7b1d30af4b38"
     },
     "checker": {
       "pin": "ef64b3f171d9"
@@ -34,7 +34,7 @@
       "pin": "c2fb51b31fe4"
     },
     "bqaudioio": {
-      "pin": "0d9d36e5d063"
+      "pin": "4fe94361597f"
     },
     "bqaudiostream": {
       "pin": "a0926b93e771"