comparison main/MainWindow.cpp @ 2479:acd2dcecc674

Add context menus to AudioDials; tidy
author Chris Cannam
date Thu, 26 Mar 2020 12:11:28 +0000
parents f08485694541
children 1a04140acf60
comparison
equal deleted inserted replaced
2478:f08485694541 2479:acd2dcecc674
82 #include "base/Clipboard.h" 82 #include "base/Clipboard.h"
83 #include "base/UnitDatabase.h" 83 #include "base/UnitDatabase.h"
84 #include "layer/ColourDatabase.h" 84 #include "layer/ColourDatabase.h"
85 #include "widgets/ModelDataTableDialog.h" 85 #include "widgets/ModelDataTableDialog.h"
86 #include "widgets/CSVExportDialog.h" 86 #include "widgets/CSVExportDialog.h"
87 #include "widgets/MenuTitle.h"
87 #include "rdf/PluginRDFIndexer.h" 88 #include "rdf/PluginRDFIndexer.h"
88 89
89 #include "Surveyer.h" 90 #include "Surveyer.h"
90 #include "NetworkPermissionTester.h" 91 #include "NetworkPermissionTester.h"
91 #include "framework/VersionTester.h" 92 #include "framework/VersionTester.h"
5056 { 5057 {
5057 m_paneStack->setCurrentPane(pane); 5058 m_paneStack->setCurrentPane(pane);
5058 m_rightButtonMenu->popup(position); 5059 m_rightButtonMenu->popup(position);
5059 } 5060 }
5060 5061
5061 #ifdef Q_OS_LINUX
5062 #define MENU_LEFT_INDENT \
5063 (m_viewManager->scalePixelSize(5) + \
5064 2 * qApp->style()->pixelMetric(QStyle::PM_SmallIconSize))
5065 #else
5066 #ifdef Q_OS_WIN
5067 #define MENU_LEFT_INDENT \
5068 (9 + qApp->style()->pixelMetric(QStyle::PM_SmallIconSize))
5069 #else
5070 #define MENU_LEFT_INDENT 16
5071 #endif
5072 #endif
5073
5074 void 5062 void
5075 MainWindow::panePropertiesRightButtonMenuRequested(Pane *pane, QPoint position) 5063 MainWindow::panePropertiesRightButtonMenuRequested(Pane *pane, QPoint position)
5076 { 5064 {
5077 if (m_lastRightButtonPropertyMenu) { 5065 if (m_lastRightButtonPropertyMenu) {
5078 delete m_lastRightButtonPropertyMenu; 5066 delete m_lastRightButtonPropertyMenu;
5081 m_paneStack->setCurrentLayer(pane, nullptr); 5069 m_paneStack->setCurrentLayer(pane, nullptr);
5082 5070
5083 QMenu *m = new QMenu; 5071 QMenu *m = new QMenu;
5084 IconLoader il; 5072 IconLoader il;
5085 5073
5086 QWidgetAction *wa = new QWidgetAction(m); 5074 MenuTitle::addTitle(m, tr("Pane"));
5087 QLabel *title = new QLabel;
5088 title->setText(tr("<b>Pane</b>"));
5089 title->setMargin(m_viewManager->scalePixelSize(3));
5090 title->setIndent(MENU_LEFT_INDENT);
5091 wa->setDefaultWidget(title);
5092 m->addAction(wa);
5093
5094 m->addSeparator();
5095 5075
5096 // We repeat the setCurrentLayer call here just in case some 5076 // We repeat the setCurrentLayer call here just in case some
5097 // unexpected UI interaction (scripting?) changes it while the 5077 // unexpected UI interaction (scripting?) changes it while the
5098 // menu is visible 5078 // menu is visible
5099 5079
5118 m_paneStack->setCurrentLayer(pane, layer); 5098 m_paneStack->setCurrentLayer(pane, layer);
5119 5099
5120 QMenu *m = new QMenu; 5100 QMenu *m = new QMenu;
5121 IconLoader il; 5101 IconLoader il;
5122 5102
5123 QWidgetAction *wa = new QWidgetAction(m); 5103 MenuTitle::addTitle(m, layer->getLayerPresentationName());
5124 QLabel *title = new QLabel;
5125 title->setText
5126 (tr("<b>%2</b>")
5127 .arg(XmlExportable::encodeEntities
5128 (layer->getLayerPresentationName())));
5129 title->setMargin(m_viewManager->scalePixelSize(3));
5130 title->setIndent(MENU_LEFT_INDENT);
5131 wa->setDefaultWidget(title);
5132 m->addAction(wa);
5133
5134 m->addSeparator();
5135 5104
5136 // We repeat the setCurrentLayer calls here just in case some 5105 // We repeat the setCurrentLayer calls here just in case some
5137 // unexpected UI interaction (scripting?) changes it while the 5106 // unexpected UI interaction (scripting?) changes it while the
5138 // menu is visible 5107 // menu is visible
5139 5108