Mercurial > hg > sonic-visualiser
comparison main/MainWindow.cpp @ 97:398889687f3d
* Add separate colour mapping unit; use it in spectrogram (colour 3d plot to follow)
* Add another colour scheme resembling that of a noted commercial application
author | Chris Cannam |
---|---|
date | Wed, 31 Jan 2007 12:13:47 +0000 |
parents | 2678a1f132d2 |
children | 32b386dac447 |
comparison
equal
deleted
inserted
replaced
96:76fa8f657038 | 97:398889687f3d |
---|---|
335 void | 335 void |
336 MainWindow::setupMenus() | 336 MainWindow::setupMenus() |
337 { | 337 { |
338 if (!m_mainMenusCreated) { | 338 if (!m_mainMenusCreated) { |
339 m_rightButtonMenu = new QMenu(); | 339 m_rightButtonMenu = new QMenu(); |
340 m_rightButtonMenu->setTearOffEnabled(true); | |
340 } | 341 } |
341 | 342 |
342 if (m_rightButtonLayerMenu) { | 343 if (m_rightButtonLayerMenu) { |
343 m_rightButtonLayerMenu->clear(); | 344 m_rightButtonLayerMenu->clear(); |
344 } else { | 345 } else { |
345 m_rightButtonLayerMenu = m_rightButtonMenu->addMenu(tr("&Layer")); | 346 m_rightButtonLayerMenu = m_rightButtonMenu->addMenu(tr("&Layer")); |
347 m_rightButtonLayerMenu->setTearOffEnabled(true); | |
346 m_rightButtonMenu->addSeparator(); | 348 m_rightButtonMenu->addSeparator(); |
347 } | 349 } |
348 | 350 |
349 if (m_rightButtonTransformsMenu) { | 351 if (m_rightButtonTransformsMenu) { |
350 m_rightButtonTransformsMenu->clear(); | 352 m_rightButtonTransformsMenu->clear(); |
351 } else { | 353 } else { |
352 m_rightButtonTransformsMenu = m_rightButtonMenu->addMenu(tr("&Transform")); | 354 m_rightButtonTransformsMenu = m_rightButtonMenu->addMenu(tr("&Transform")); |
355 m_rightButtonTransformsMenu->setTearOffEnabled(true); | |
353 m_rightButtonMenu->addSeparator(); | 356 m_rightButtonMenu->addSeparator(); |
354 } | 357 } |
355 | 358 |
356 if (!m_mainMenusCreated) { | 359 if (!m_mainMenusCreated) { |
357 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu); | 360 CommandHistory::getInstance()->registerMenu(m_rightButtonMenu); |
372 MainWindow::setupFileMenu() | 375 MainWindow::setupFileMenu() |
373 { | 376 { |
374 if (m_mainMenusCreated) return; | 377 if (m_mainMenusCreated) return; |
375 | 378 |
376 QMenu *menu = menuBar()->addMenu(tr("&File")); | 379 QMenu *menu = menuBar()->addMenu(tr("&File")); |
380 menu->setTearOffEnabled(true); | |
377 QToolBar *toolbar = addToolBar(tr("File Toolbar")); | 381 QToolBar *toolbar = addToolBar(tr("File Toolbar")); |
378 | 382 |
379 QIcon icon(":icons/filenew.png"); | 383 QIcon icon(":icons/filenew.png"); |
380 icon.addFile(":icons/filenew-22.png"); | 384 icon.addFile(":icons/filenew-22.png"); |
381 QAction *action = new QAction(icon, tr("&New Session"), this); | 385 QAction *action = new QAction(icon, tr("&New Session"), this); |
462 menu->addAction(action); | 466 menu->addAction(action); |
463 | 467 |
464 menu->addSeparator(); | 468 menu->addSeparator(); |
465 | 469 |
466 m_recentFilesMenu = menu->addMenu(tr("&Recent Files")); | 470 m_recentFilesMenu = menu->addMenu(tr("&Recent Files")); |
471 m_recentFilesMenu->setTearOffEnabled(true); | |
467 setupRecentFilesMenu(); | 472 setupRecentFilesMenu(); |
468 connect(&m_recentFiles, SIGNAL(recentChanged()), | 473 connect(&m_recentFiles, SIGNAL(recentChanged()), |
469 this, SLOT(setupRecentFilesMenu())); | 474 this, SLOT(setupRecentFilesMenu())); |
470 | 475 |
471 menu->addSeparator(); | 476 menu->addSeparator(); |
497 MainWindow::setupEditMenu() | 502 MainWindow::setupEditMenu() |
498 { | 503 { |
499 if (m_mainMenusCreated) return; | 504 if (m_mainMenusCreated) return; |
500 | 505 |
501 QMenu *menu = menuBar()->addMenu(tr("&Edit")); | 506 QMenu *menu = menuBar()->addMenu(tr("&Edit")); |
507 menu->setTearOffEnabled(true); | |
502 CommandHistory::getInstance()->registerMenu(menu); | 508 CommandHistory::getInstance()->registerMenu(menu); |
503 | 509 |
504 menu->addSeparator(); | 510 menu->addSeparator(); |
505 | 511 |
506 QAction *action = new QAction(QIcon(":/icons/editcut.png"), | 512 QAction *action = new QAction(QIcon(":/icons/editcut.png"), |
605 if (m_mainMenusCreated) return; | 611 if (m_mainMenusCreated) return; |
606 | 612 |
607 QAction *action = 0; | 613 QAction *action = 0; |
608 | 614 |
609 QMenu *menu = menuBar()->addMenu(tr("&View")); | 615 QMenu *menu = menuBar()->addMenu(tr("&View")); |
616 menu->setTearOffEnabled(true); | |
610 action = new QAction(tr("Scroll &Left"), this); | 617 action = new QAction(tr("Scroll &Left"), this); |
611 action->setShortcut(tr("Left")); | 618 action->setShortcut(tr("Left")); |
612 action->setStatusTip(tr("Scroll the current pane to the left")); | 619 action->setStatusTip(tr("Scroll the current pane to the left")); |
613 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft())); | 620 connect(action, SIGNAL(triggered()), this, SLOT(scrollLeft())); |
614 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | 621 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); |
757 if (m_paneMenu) { | 764 if (m_paneMenu) { |
758 m_paneActions.clear(); | 765 m_paneActions.clear(); |
759 m_paneMenu->clear(); | 766 m_paneMenu->clear(); |
760 } else { | 767 } else { |
761 m_paneMenu = menuBar()->addMenu(tr("&Pane")); | 768 m_paneMenu = menuBar()->addMenu(tr("&Pane")); |
769 m_paneMenu->setTearOffEnabled(true); | |
762 } | 770 } |
763 | 771 |
764 if (m_layerMenu) { | 772 if (m_layerMenu) { |
765 m_layerActions.clear(); | 773 m_layerActions.clear(); |
766 m_layerMenu->clear(); | 774 m_layerMenu->clear(); |
767 } else { | 775 } else { |
768 m_layerMenu = menuBar()->addMenu(tr("&Layer")); | 776 m_layerMenu = menuBar()->addMenu(tr("&Layer")); |
777 m_layerMenu->setTearOffEnabled(true); | |
769 } | 778 } |
770 | 779 |
771 QMenu *menu = m_paneMenu; | 780 QMenu *menu = m_paneMenu; |
772 | 781 |
773 QAction *action = new QAction(QIcon(":/icons/pane.png"), tr("Add &New Pane"), this); | 782 QAction *action = new QAction(QIcon(":/icons/pane.png"), tr("Add &New Pane"), this); |
971 | 980 |
972 } else { | 981 } else { |
973 | 982 |
974 if (!submenu) { | 983 if (!submenu) { |
975 submenu = menu->addMenu(mainText); | 984 submenu = menu->addMenu(mainText); |
985 submenu->setTearOffEnabled(true); | |
976 } else if (isDefault) { | 986 } else if (isDefault) { |
977 submenu->addSeparator(); | 987 submenu->addSeparator(); |
978 } | 988 } |
979 | 989 |
980 QString actionText; | 990 QString actionText; |
1048 menu->addAction(action); | 1058 menu->addAction(action); |
1049 | 1059 |
1050 menu->addSeparator(); | 1060 menu->addSeparator(); |
1051 | 1061 |
1052 m_existingLayersMenu = menu->addMenu(tr("Add &Existing Layer")); | 1062 m_existingLayersMenu = menu->addMenu(tr("Add &Existing Layer")); |
1063 m_existingLayersMenu->setTearOffEnabled(true); | |
1053 m_rightButtonLayerMenu->addMenu(m_existingLayersMenu); | 1064 m_rightButtonLayerMenu->addMenu(m_existingLayersMenu); |
1054 | 1065 |
1055 m_sliceMenu = menu->addMenu(tr("Add S&lice of Layer")); | 1066 m_sliceMenu = menu->addMenu(tr("Add S&lice of Layer")); |
1067 m_sliceMenu->setTearOffEnabled(true); | |
1056 m_rightButtonLayerMenu->addMenu(m_sliceMenu); | 1068 m_rightButtonLayerMenu->addMenu(m_sliceMenu); |
1057 | 1069 |
1058 setupExistingLayersMenus(); | 1070 setupExistingLayersMenus(); |
1059 | 1071 |
1060 m_rightButtonLayerMenu->addSeparator(); | 1072 m_rightButtonLayerMenu->addSeparator(); |
1083 if (m_transformsMenu) { | 1095 if (m_transformsMenu) { |
1084 m_transformActions.clear(); | 1096 m_transformActions.clear(); |
1085 m_transformActionsReverse.clear(); | 1097 m_transformActionsReverse.clear(); |
1086 m_transformsMenu->clear(); | 1098 m_transformsMenu->clear(); |
1087 } else { | 1099 } else { |
1088 m_transformsMenu = menuBar()->addMenu(tr("&Transform")); | 1100 m_transformsMenu = menuBar()->addMenu(tr("&Transform")); |
1089 } | 1101 m_transformsMenu->setTearOffEnabled(true); |
1102 } | |
1090 | 1103 |
1091 TransformFactory::TransformList transforms = | 1104 TransformFactory::TransformList transforms = |
1092 TransformFactory::getInstance()->getAllTransforms(); | 1105 TransformFactory::getInstance()->getAllTransforms(); |
1093 | 1106 |
1094 vector<QString> types = | 1107 vector<QString> types = |
1101 map<QString, map<QString, QMenu *> > pluginNameMenus; | 1114 map<QString, map<QString, QMenu *> > pluginNameMenus; |
1102 | 1115 |
1103 set<SubdividingMenu *> pendingMenus; | 1116 set<SubdividingMenu *> pendingMenus; |
1104 | 1117 |
1105 m_recentTransformsMenu = m_transformsMenu->addMenu(tr("&Recent Transforms")); | 1118 m_recentTransformsMenu = m_transformsMenu->addMenu(tr("&Recent Transforms")); |
1119 m_recentTransformsMenu->setTearOffEnabled(true); | |
1106 m_rightButtonTransformsMenu->addMenu(m_recentTransformsMenu); | 1120 m_rightButtonTransformsMenu->addMenu(m_recentTransformsMenu); |
1107 connect(&m_recentTransforms, SIGNAL(recentChanged()), | 1121 connect(&m_recentTransforms, SIGNAL(recentChanged()), |
1108 this, SLOT(setupRecentTransformsMenu())); | 1122 this, SLOT(setupRecentTransformsMenu())); |
1109 | 1123 |
1110 m_transformsMenu->addSeparator(); | 1124 m_transformsMenu->addSeparator(); |
1118 } | 1132 } |
1119 | 1133 |
1120 QString byCategoryLabel = tr("%1 by Category").arg(*i); | 1134 QString byCategoryLabel = tr("%1 by Category").arg(*i); |
1121 SubdividingMenu *byCategoryMenu = new SubdividingMenu(byCategoryLabel, | 1135 SubdividingMenu *byCategoryMenu = new SubdividingMenu(byCategoryLabel, |
1122 20, 40); | 1136 20, 40); |
1137 byCategoryMenu->setTearOffEnabled(true); | |
1123 m_transformsMenu->addMenu(byCategoryMenu); | 1138 m_transformsMenu->addMenu(byCategoryMenu); |
1124 m_rightButtonTransformsMenu->addMenu(byCategoryMenu); | 1139 m_rightButtonTransformsMenu->addMenu(byCategoryMenu); |
1125 pendingMenus.insert(byCategoryMenu); | 1140 pendingMenus.insert(byCategoryMenu); |
1126 | 1141 |
1127 vector<QString> categories = | 1142 vector<QString> categories = |
1148 if (key != "") key += " > "; | 1163 if (key != "") key += " > "; |
1149 key += *k; | 1164 key += *k; |
1150 | 1165 |
1151 if (categoryMenus[*i].find(key) == categoryMenus[*i].end()) { | 1166 if (categoryMenus[*i].find(key) == categoryMenus[*i].end()) { |
1152 SubdividingMenu *m = new SubdividingMenu(*k, 20, 40); | 1167 SubdividingMenu *m = new SubdividingMenu(*k, 20, 40); |
1168 m->setTearOffEnabled(true); | |
1153 pendingMenus.insert(m); | 1169 pendingMenus.insert(m); |
1154 categoryMenus[*i][key] = m; | 1170 categoryMenus[*i][key] = m; |
1155 if (parentKey == "") { | 1171 if (parentKey == "") { |
1156 byCategoryMenu->addMenu(m); | 1172 byCategoryMenu->addMenu(m); |
1157 } else { | 1173 } else { |
1161 } | 1177 } |
1162 } | 1178 } |
1163 | 1179 |
1164 QString byPluginNameLabel = tr("%1 by Plugin Name").arg(*i); | 1180 QString byPluginNameLabel = tr("%1 by Plugin Name").arg(*i); |
1165 byPluginNameMenus[*i] = new SubdividingMenu(byPluginNameLabel); | 1181 byPluginNameMenus[*i] = new SubdividingMenu(byPluginNameLabel); |
1182 byPluginNameMenus[*i]->setTearOffEnabled(true); | |
1166 m_transformsMenu->addMenu(byPluginNameMenus[*i]); | 1183 m_transformsMenu->addMenu(byPluginNameMenus[*i]); |
1167 m_rightButtonTransformsMenu->addMenu(byPluginNameMenus[*i]); | 1184 m_rightButtonTransformsMenu->addMenu(byPluginNameMenus[*i]); |
1168 pendingMenus.insert(byPluginNameMenus[*i]); | 1185 pendingMenus.insert(byPluginNameMenus[*i]); |
1169 | 1186 |
1170 QString byMakerLabel = tr("%1 by Maker").arg(*i); | 1187 QString byMakerLabel = tr("%1 by Maker").arg(*i); |
1171 SubdividingMenu *byMakerMenu = new SubdividingMenu(byMakerLabel, 20, 40); | 1188 SubdividingMenu *byMakerMenu = new SubdividingMenu(byMakerLabel, 20, 40); |
1189 byMakerMenu->setTearOffEnabled(true); | |
1172 m_transformsMenu->addMenu(byMakerMenu); | 1190 m_transformsMenu->addMenu(byMakerMenu); |
1173 m_rightButtonTransformsMenu->addMenu(byMakerMenu); | 1191 m_rightButtonTransformsMenu->addMenu(byMakerMenu); |
1174 pendingMenus.insert(byMakerMenu); | 1192 pendingMenus.insert(byMakerMenu); |
1175 | 1193 |
1176 vector<QString> makers = | 1194 vector<QString> makers = |
1182 QString maker = *j; | 1200 QString maker = *j; |
1183 if (maker == "") maker = tr("Unknown"); | 1201 if (maker == "") maker = tr("Unknown"); |
1184 maker.replace(QRegExp(tr(" [\\(<].*$")), ""); | 1202 maker.replace(QRegExp(tr(" [\\(<].*$")), ""); |
1185 | 1203 |
1186 makerMenus[*i][maker] = new SubdividingMenu(maker, 30, 40); | 1204 makerMenus[*i][maker] = new SubdividingMenu(maker, 30, 40); |
1205 makerMenus[*i][maker]->setTearOffEnabled(true); | |
1187 byMakerMenu->addMenu(makerMenus[*i][maker]); | 1206 byMakerMenu->addMenu(makerMenus[*i][maker]); |
1188 pendingMenus.insert(makerMenus[*i][maker]); | 1207 pendingMenus.insert(makerMenus[*i][maker]); |
1189 } | 1208 } |
1190 } | 1209 } |
1191 | 1210 |
1252 | 1271 |
1253 if (pluginNameMenus[type].find(pluginName) == | 1272 if (pluginNameMenus[type].find(pluginName) == |
1254 pluginNameMenus[type].end()) { | 1273 pluginNameMenus[type].end()) { |
1255 | 1274 |
1256 SubdividingMenu *parentMenu = byPluginNameMenus[type]; | 1275 SubdividingMenu *parentMenu = byPluginNameMenus[type]; |
1276 parentMenu->setTearOffEnabled(true); | |
1257 | 1277 |
1258 if (output == "") { | 1278 if (output == "") { |
1259 parentMenu->addAction(pluginName, action); | 1279 parentMenu->addAction(pluginName, action); |
1260 } else { | 1280 } else { |
1261 pluginNameMenus[type][pluginName] = | 1281 pluginNameMenus[type][pluginName] = |
1284 MainWindow::setupHelpMenu() | 1304 MainWindow::setupHelpMenu() |
1285 { | 1305 { |
1286 if (m_mainMenusCreated) return; | 1306 if (m_mainMenusCreated) return; |
1287 | 1307 |
1288 QMenu *menu = menuBar()->addMenu(tr("&Help")); | 1308 QMenu *menu = menuBar()->addMenu(tr("&Help")); |
1309 menu->setTearOffEnabled(true); | |
1289 | 1310 |
1290 QAction *action = new QAction(tr("&Help Reference"), this); | 1311 QAction *action = new QAction(tr("&Help Reference"), this); |
1291 action->setStatusTip(tr("Open the Sonic Visualiser reference manual")); | 1312 action->setStatusTip(tr("Open the Sonic Visualiser reference manual")); |
1292 connect(action, SIGNAL(triggered()), this, SLOT(help())); | 1313 connect(action, SIGNAL(triggered()), this, SLOT(help())); |
1293 menu->addAction(action); | 1314 menu->addAction(action); |