Mercurial > hg > sonic-visualiser
comparison main/MainWindow.cpp @ 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 | 2197ba438a3f |
children | 6a46b1d4f0cd |
comparison
equal
deleted
inserted
replaced
2470:de62cf88806b | 2475:169cc70492bb |
---|---|
124 #include <QScrollArea> | 124 #include <QScrollArea> |
125 #include <QCloseEvent> | 125 #include <QCloseEvent> |
126 #include <QDialogButtonBox> | 126 #include <QDialogButtonBox> |
127 #include <QFileSystemWatcher> | 127 #include <QFileSystemWatcher> |
128 #include <QTextEdit> | 128 #include <QTextEdit> |
129 #include <QWidgetAction> | |
129 | 130 |
130 #include <iostream> | 131 #include <iostream> |
131 #include <cstdio> | 132 #include <cstdio> |
132 #include <errno.h> | 133 #include <errno.h> |
133 | 134 |
151 m_templatesMenu(nullptr), | 152 m_templatesMenu(nullptr), |
152 m_rightButtonMenu(nullptr), | 153 m_rightButtonMenu(nullptr), |
153 m_rightButtonLayerMenu(nullptr), | 154 m_rightButtonLayerMenu(nullptr), |
154 m_rightButtonTransformsMenu(nullptr), | 155 m_rightButtonTransformsMenu(nullptr), |
155 m_rightButtonPlaybackMenu(nullptr), | 156 m_rightButtonPlaybackMenu(nullptr), |
157 m_lastRightButtonPropertyMenu(nullptr), | |
156 m_soloAction(nullptr), | 158 m_soloAction(nullptr), |
157 m_rwdStartAction(nullptr), | 159 m_rwdStartAction(nullptr), |
158 m_rwdSimilarAction(nullptr), | 160 m_rwdSimilarAction(nullptr), |
159 m_rwdAction(nullptr), | 161 m_rwdAction(nullptr), |
160 m_ffwdAction(nullptr), | 162 m_ffwdAction(nullptr), |
5048 .arg(message), | 5050 .arg(message), |
5049 QMessageBox::Ok); | 5051 QMessageBox::Ok); |
5050 } | 5052 } |
5051 | 5053 |
5052 void | 5054 void |
5053 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position) | 5055 MainWindow::paneRightButtonMenuRequested(Pane *pane, QPoint position) |
5054 { | 5056 { |
5055 // SVDEBUG << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << endl; | |
5056 m_paneStack->setCurrentPane(pane); | 5057 m_paneStack->setCurrentPane(pane); |
5057 m_rightButtonMenu->popup(position); | 5058 m_rightButtonMenu->popup(position); |
5059 } | |
5060 | |
5061 void | |
5062 MainWindow::panePropertiesRightButtonMenuRequested(Pane *pane, QPoint position) | |
5063 { | |
5064 if (m_lastRightButtonPropertyMenu) { | |
5065 delete m_lastRightButtonPropertyMenu; | |
5066 } | |
5067 | |
5068 m_paneStack->setCurrentLayer(pane, nullptr); | |
5069 | |
5070 QMenu *m = new QMenu; | |
5071 IconLoader il; | |
5072 | |
5073 QWidgetAction *wa = new QWidgetAction(m); | |
5074 QLabel *title = new QLabel; | |
5075 title->setText(tr("<b>Pane</b>")); | |
5076 title->setMargin(m_viewManager->scalePixelSize(2)); | |
5077 title->setIndent(m_viewManager->scalePixelSize(12)); | |
5078 wa->setDefaultWidget(title); | |
5079 m->addAction(wa); | |
5080 | |
5081 m->addSeparator(); | |
5082 | |
5083 // We repeat the setCurrentLayer call here just in case some | |
5084 // unexpected UI interaction (scripting?) changes it while the | |
5085 // menu is visible | |
5086 | |
5087 m->addAction(il.load("editdelete"), | |
5088 tr("&Delete Pane"), | |
5089 [=]() { | |
5090 m_paneStack->setCurrentLayer(pane, nullptr); | |
5091 deleteCurrentPane(); | |
5092 }); | |
5093 | |
5094 m->popup(position); | |
5095 m_lastRightButtonPropertyMenu = m; | |
5096 } | |
5097 | |
5098 void | |
5099 MainWindow::layerPropertiesRightButtonMenuRequested(Pane *pane, Layer *layer, QPoint position) | |
5100 { | |
5101 if (m_lastRightButtonPropertyMenu) { | |
5102 delete m_lastRightButtonPropertyMenu; | |
5103 } | |
5104 | |
5105 m_paneStack->setCurrentLayer(pane, layer); | |
5106 | |
5107 QMenu *m = new QMenu; | |
5108 IconLoader il; | |
5109 | |
5110 QWidgetAction *wa = new QWidgetAction(m); | |
5111 QLabel *title = new QLabel; | |
5112 title->setText | |
5113 (tr("<b>%2</b>") | |
5114 .arg(XmlExportable::encodeEntities | |
5115 (layer->getLayerPresentationName()))); | |
5116 title->setMargin(m_viewManager->scalePixelSize(2)); | |
5117 title->setIndent(m_viewManager->scalePixelSize(12)); | |
5118 wa->setDefaultWidget(title); | |
5119 m->addAction(wa); | |
5120 | |
5121 m->addSeparator(); | |
5122 | |
5123 // We repeat the setCurrentLayer calls here just in case some | |
5124 // unexpected UI interaction (scripting?) changes it while the | |
5125 // menu is visible | |
5126 | |
5127 m->addAction(tr("&Rename Layer..."), | |
5128 [=]() { | |
5129 m_paneStack->setCurrentLayer(pane, layer); | |
5130 renameCurrentLayer(); | |
5131 }); | |
5132 | |
5133 m->addAction(tr("Edit Layer Data"), | |
5134 [=]() { | |
5135 m_paneStack->setCurrentLayer(pane, layer); | |
5136 editCurrentLayer(); | |
5137 }) | |
5138 ->setEnabled(layer->isLayerEditable()); | |
5139 | |
5140 m->addAction(il.load("editdelete"), | |
5141 tr("&Delete Layer"), | |
5142 [=]() { | |
5143 m_paneStack->setCurrentLayer(pane, layer); | |
5144 deleteCurrentLayer(); | |
5145 }); | |
5146 | |
5147 m->popup(position); | |
5148 m_lastRightButtonPropertyMenu = m; | |
5058 } | 5149 } |
5059 | 5150 |
5060 void | 5151 void |
5061 MainWindow::showLayerTree() | 5152 MainWindow::showLayerTree() |
5062 { | 5153 { |